Minikube : インストール2021/08/30 |
シングルノードで Kubernetes クラスターを構成可能な Minikube をインストールします。
|
[1] | 仮想マシンを利用するため、Minikube でサポートするハイパーバイザーをインストールしておきます。 当例では KVM をインストールして進めます。 その他、VirtualBox, VMware Fusion, HyperKit が利用可能です。 |
root@dlp:~# apt -y install qemu-kvm libvirt-daemon-system libvirt-daemon bridge-utils kubernetes-client
|
[2] | Minikube をインストールします。 |
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:~#
root@dlp:~# mv minikube docker-machine-driver-kvm2 /usr/local/bin/
minikube version minikube version: v1.22.0 commit: a03fbcf166e6f74ef224d4a63be4277d017bb62e |
[3] | Minikube を利用する任意のユーザーを [libvirt] グループに登録しておきます。 |
root@dlp:~# usermod -aG libvirt debian |
[4] | [libvirt] グループに登録した任意のユーザーで Minikube を起動します。 |
# minikube 起動 debian@dlp:~$ minikube start --vm-driver=kvm2 * minikube v1.22.0 on Debian 11.0 (kvm/amd64) * Using the kvm2 driver based on user configuration * Downloading VM boot image ... > minikube-v1.22.0.iso.sha256: 65 B / 65 B [-------------] 100.00% ? p/s 0s > minikube-v1.22.0.iso: 242.95 MiB / 242.95 MiB 100.00% 25.87 MiB p/s 9.6s * Starting control plane node minikube in cluster minikube * Downloading Kubernetes v1.21.2 preload ... > preloaded-images-k8s-v11-v1...: 502.14 MiB / 502.14 MiB 100.00% 30.84 Mi * Creating kvm2 VM (CPUs=2, Memory=4000MB, Disk=20000MB) ... * Preparing Kubernetes v1.21.2 on Docker 20.10.6 ... - Generating certificates and keys ... - Booting up control plane ... - Configuring RBAC rules ... * Verifying Kubernetes components... - Using image gcr.io/k8s-minikube/storage-provisioner:v5 * Enabled addons: storage-provisioner, default-storageclass * Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default # 状態確認 debian@dlp:~$ minikube status minikube type: Control Plane host: Running kubelet: Running apiserver: Running kubeconfig: Configureddebian@dlp:~$ minikube service list |-------------|------------|--------------|-----| | NAMESPACE | NAME | TARGET PORT | URL | |-------------|------------|--------------|-----| | default | kubernetes | No node port | | kube-system | kube-dns | No node port | |-------------|------------|--------------|-----|debian@dlp:~$ minikube docker-env export DOCKER_TLS_VERIFY="1" export DOCKER_HOST="tcp://192.168.39.79:2376" export DOCKER_CERT_PATH="/home/debian/.minikube/certs" export MINIKUBE_ACTIVE_DOCKERD="minikube" # To point your shell to minikube's docker-daemon, run: # eval $(minikube -p minikube docker-env)debian@dlp:~$ kubectl cluster-info Kubernetes control plane is running at https://192.168.39.79:8443 CoreDNS is running at https://192.168.39.79:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.debian@dlp:~$ kubectl get nodes NAME STATUS ROLES AGE VERSION minikube Ready control-plane,master 2m3s v1.21.2 # 仮想マシンへ SSH アクセス debian@dlp:~$ minikube ssh _ _ _ _ ( ) ( ) ___ ___ (_) ___ (_)| |/') _ _ | |_ __ /' _ ` _ `\| |/' _ `\| || , < ( ) ( )| '_`\ /'__`\ | ( ) ( ) || || ( ) || || |\`\ | (_) || |_) )( ___/ (_) (_) (_)(_)(_) (_)(_)(_) (_)`\___/'(_,__/'`\____)
$
$ hostname minikube docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 8e2ec8bb0f01 6e38f40d628d "/storage-provisioner" 2 minutes ago Up 2 minutes k8s_storage-provisioner_storage-provisioner_kube-system_7be43627-aed8-4b8a-95d7-5ee9c4005edc_0 d88055e658e8 296a6d5035e2 "/coredns -conf /etc…" 2 minutes ago Up 2 minutes k8s_coredns_coredns-558bd4d5db-j8fwg_kube-system_fc047f42-8e3e-443e-8f40-8771331f3164_0 1237aa6523f9 a6ebd1c1ad98 "/usr/local/bin/kube…" 2 minutes ago Up 2 minutes k8s_kube-proxy_kube-proxy-j8wzl_kube-system_d739dece-7dda-4027-b16a-d6dd76ad2430_0 cad2fdaa69dd k8s.gcr.io/pause:3.4.1 "/pause" 2 minutes ago Up 2 minutes k8s_POD_storage-provisioner_kube-system_7be43627-aed8-4b8a-95d7-5ee9c4005edc_0 f941baa285b5 k8s.gcr.io/pause:3.4.1 "/pause" 2 minutes ago Up 2 minutes k8s_POD_coredns-558bd4d5db-j8fwg_kube-system_fc047f42-8e3e-443e-8f40-8771331f3164_0 0bc5ce70f1c6 k8s.gcr.io/pause:3.4.1 "/pause" 2 minutes ago Up 2 minutes k8s_POD_kube-proxy-j8wzl_kube-system_d739dece-7dda-4027-b16a-d6dd76ad2430_0 0282edd9826f f917b8c8f55b "kube-scheduler --au…" 3 minutes ago Up 3 minutes k8s_kube-scheduler_kube-scheduler-minikube_kube-system_a2acd1bccd50fd7790183537181f658e_0 a05d9210b35a 0369cf4303ff "etcd --advertise-cl…" 3 minutes ago Up 3 minutes k8s_etcd_etcd-minikube_kube-system_5d226e339e761597482c6dcc349594b2_0 e542b0875585 106ff58d4308 "kube-apiserver --ad…" 3 minutes ago Up 3 minutes k8s_kube-apiserver_kube-apiserver-minikube_kube-system_1f992a1611d681209c3aabfa02c821f1_0 3694d1635647 ae24db9aa2cc "kube-controller-man…" 3 minutes ago Up 3 minutes k8s_kube-controller-manager_kube-controller-manager-minikube_kube-system_533a59bbe1f287c135099b24dd8b3b1c_0 d6f4eeb78d8e k8s.gcr.io/pause:3.4.1 "/pause" 3 minutes ago Up 3 minutes k8s_POD_kube-scheduler-minikube_kube-system_a2acd1bccd50fd7790183537181f658e_0 6ba9996e93fc k8s.gcr.io/pause:3.4.1 "/pause" 3 minutes ago Up 3 minutes k8s_POD_kube-apiserver-minikube_kube-system_1f992a1611d681209c3aabfa02c821f1_0 b7b43c3dfb00 k8s.gcr.io/pause:3.4.1 "/pause" 3 minutes ago Up 3 minutes k8s_POD_etcd-minikube_kube-system_5d226e339e761597482c6dcc349594b2_0 e47165e94308 k8s.gcr.io/pause:3.4.1 "/pause" 3 minutes ago Up 3 minutes k8s_POD_kube-controller-manager-minikube_kube-system_533a59bbe1f287c135099b24dd8b3b1c_0
$
exit
# minikube を停止する場合は以下 debian@dlp:~$ minikube stop * Stopping node "minikube" ... * 1 nodes stopped. # minikube を開始する場合は以下 debian@dlp:~$ minikube start * minikube v1.22.0 on Debian 11.0 (kvm/amd64) * 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.21.2 on Docker 20.10.6 ... * Verifying Kubernetes components... - Using image gcr.io/k8s-minikube/storage-provisioner:v5 * Enabled addons: storage-provisioner, default-storageclass * Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default # minikube 仮想マシンを削除する場合は以下 debian@dlp:~$ minikube delete Deleting local Kubernetes cluster... Machine deleted. |
Sponsored Link |
|