CentOS 8
Sponsored Link

Minikube : インストール2020/08/07

 
シングルノードで Kubernetes クラスターを構成可能な Minikube をインストールします。
[1]
仮想マシンを利用するため、Minikube でサポートするハイパーバイザーをインストールしておきます。
当例では こちらの [1] の通り KVM をインストールして進めます
[2]
[3] Minikube と その他 必要なツールをインストールします。
# kubectl インストール

[root@dlp ~]#
snap install kubectl --classic

kubectl 1.18.6 from Canonical installed
[root@dlp ~]#
wget https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 -O minikube

[root@dlp ~]#
wget https://storage.googleapis.com/minikube/releases/latest/docker-machine-driver-kvm2

[root@dlp ~]#
chmod 755 minikube docker-machine-driver-kvm2

[root@dlp ~]#
mv minikube docker-machine-driver-kvm2 /usr/local/bin/
[root@dlp ~]#
minikube version

minikube version: v1.12.2 commit: be7c19d391302656d27f1f213657d925c4e1cfc2-dirty
[4] Minikube を利用する任意のユーザーを [libvirt] グループに登録しておきます。
[root@dlp ~]#
usermod -aG libvirt cent

[5] [libvirt] グループに登録した任意のユーザーで Minikube を起動します。
# minikube 起動

[cent@dlp ~]$
minikube start --vm-driver=kvm2

* minikube v1.12.2 on Centos 8.2.2004
* Using the kvm2 driver based on user configuration
* Downloading VM boot image ...
    > minikube-v1.12.2.iso.sha256: 65 B / 65 B [-------------] 100.00% ? p/s 0s
    > minikube-v1.12.2.iso: 173.73 MiB / 173.73 MiB [] 100.00% 41.05 MiB p/s 5s
* Starting control plane node minikube in cluster minikube
* Downloading Kubernetes v1.18.3 preload ...
    > preloaded-images-k8s-v5-v1.18.3-docker-overlay2-amd64.tar.lz4: 510.91 MiB
* Creating kvm2 VM (CPUs=2, Memory=3900MB, Disk=20000MB) ...
* Preparing Kubernetes v1.18.3 on Docker 19.03.12 ...
* Verifying Kubernetes components...
* Enabled addons: default-storageclass, storage-provisioner
* Done! kubectl is now configured to use "minikube"

# 状態確認

[cent@dlp ~]$
minikube status

minikube
type: Control Plane
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured
ubuntu@dlp:~$
minikube service list

|-------------|------------|--------------|-----|
|  NAMESPACE  |    NAME    | TARGET PORT  | URL |
|-------------|------------|--------------|-----|
| default     | kubernetes | No node port |
| kube-system | kube-dns   | No node port |
|-------------|------------|--------------|-----|

[cent@dlp ~]$
minikube docker-env

export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.39.10:2376"
export DOCKER_CERT_PATH="/home/cent/.minikube/certs"
export MINIKUBE_ACTIVE_DOCKERD="minikube"

# To point your shell to minikube's docker-daemon, run:
# eval $(minikube -p minikube docker-env)

[cent@dlp ~]$
kubectl cluster-info

Kubernetes master is running at https://192.168.39.10:8443
KubeDNS is running at https://192.168.39.10:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.

[cent@dlp ~]$
kubectl get nodes

NAME       STATUS   ROLES    AGE     VERSION
minikube   Ready    master   3m20s   v1.18.3

# 仮想マシンへ SSH アクセス

[cent@dlp ~]$
minikube ssh

                         _             _
            _         _ ( )           ( )
  ___ ___  (_)  ___  (_)| |/')  _   _ | |_      __
/' _ ` _ `\| |/' _ `\| || , <  ( ) ( )| '_`\  /'__`\
| ( ) ( ) || || ( ) || || |\`\ | (_) || |_) )(  ___/
(_) (_) (_)(_)(_) (_)(_)(_) (_)`\___/'(_,__/'`\____)

$
hostname

minikube
$
docker ps

CONTAINER ID        IMAGE                  COMMAND                  CREATED             STATUS              PORTS               NAMES
a80d9651ddf9        67da37a9a360           "/coredns -conf /etc…"   3 minutes ago       Up 3 minutes                            k8s_coredns_coredns-66bff467f8-vgdr5_kube-system_bd2eb6c3-2b38-4a76-bd0e-3525d20e2472_0
8f1e0b90acd7        k8s.gcr.io/pause:3.2   "/pause"                 3 minutes ago       Up 3 minutes                            k8s_POD_coredns-66bff467f8-vgdr5_kube-system_bd2eb6c3-2b38-4a76-bd0e-3525d20e2472_0
974e50e95e3b        9c3ca9f065bb           "/storage-provisioner"   3 minutes ago       Up 3 minutes                            k8s_storage-provisioner_storage-provisioner_kube-system_addbac2e-2a7c-4559-902f-74a9c5365107_0
2c006bb2352f        k8s.gcr.io/pause:3.2   "/pause"                 3 minutes ago       Up 3 minutes                            k8s_POD_storage-provisioner_kube-system_addbac2e-2a7c-4559-902f-74a9c5365107_0
82d6e1b5ba94        3439b7546f29           "/usr/local/bin/kube…"   4 minutes ago       Up 4 minutes                            k8s_kube-proxy_kube-proxy-lrccx_kube-system_74423dd9-1e01-49f9-bbac-01f1beba4340_0
fe7b3b4343a3        k8s.gcr.io/pause:3.2   "/pause"                 4 minutes ago       Up 4 minutes                            k8s_POD_kube-proxy-lrccx_kube-system_74423dd9-1e01-49f9-bbac-01f1beba4340_0
ab28a803cb79        76216c34ed0c           "kube-scheduler --au…"   4 minutes ago       Up 4 minutes                            k8s_kube-scheduler_kube-scheduler-minikube_kube-system_dcddbd0cc8c89e2cbf4de5d3cca8769f_0
503b665d949e        da26705ccb4b           "kube-controller-man…"   4 minutes ago       Up 4 minutes                            k8s_kube-controller-manager_kube-controller-manager-minikube_kube-system_ba963bc1bff8609dc4fc4d359349c120_0
c8d81600d005        303ce5db0e90           "etcd --advertise-cl…"   4 minutes ago       Up 4 minutes                            k8s_etcd_etcd-minikube_kube-system_72afc3170ee1a04916feee5056498e4c_0
16b9f903cfb4        7e28efa976bd           "kube-apiserver --ad…"   4 minutes ago       Up 4 minutes                            k8s_kube-apiserver_kube-apiserver-minikube_kube-system_5fba823e15c81e5d38018261e6034e3c_0
b6aa1ac65e77        k8s.gcr.io/pause:3.2   "/pause"                 4 minutes ago       Up 4 minutes                            k8s_POD_etcd-minikube_kube-system_72afc3170ee1a04916feee5056498e4c_0
6397bb1cb087        k8s.gcr.io/pause:3.2   "/pause"                 4 minutes ago       Up 4 minutes                            k8s_POD_kube-scheduler-minikube_kube-system_dcddbd0cc8c89e2cbf4de5d3cca8769f_0
db6174868f94        k8s.gcr.io/pause:3.2   "/pause"                 4 minutes ago       Up 4 minutes                            k8s_POD_kube-controller-manager-minikube_kube-system_ba963bc1bff8609dc4fc4d359349c120_0
7d6416804e12        k8s.gcr.io/pause:3.2   "/pause"                 4 minutes ago       Up 4 minutes                            k8s_POD_kube-apiserver-minikube_kube-system_5fba823e15c81e5d38018261e6034e3c_0

$
exit
# minikube を停止する場合は以下

[cent@dlp ~]$
minikube stop

* Stopping node "minikube" ...
* 1 nodes stopped.
# minikube を開始する場合は以下

[cent@dlp ~]$
minikube start

* minikube v1.12.2 on Centos 8.2.2004
* Using the kvm2 driver based on existing profile
* Starting control plane node minikube in cluster minikube
* Restarting existing kvm2 VM for "minikube" ...
* Preparing Kubernetes v1.18.3 on Docker 19.03.12 ...
* Verifying Kubernetes components...
* Enabled addons: default-storageclass, storage-provisioner
* Done! kubectl is now configured to use "minikube"

# minikube 仮想マシンを削除する場合は以下

[cent@dlp ~]$
minikube delete

* Deleting "minikube" in kvm2 ...
* Removed all traces of the "minikube" cluster.
関連コンテンツ