Minikube : インストール2023/06/21 |
シングルノードで Kubernetes クラスターを構成可能な Minikube をインストールします。
|
[1] |
仮想マシンを利用するため、Minikube でサポートするハイパーバイザーをインストールしておきます。
当例では KVM をインストールして進めます。 その他、VirtualBox, VMware Fusion, HyperKit が利用可能です。 |
[2] | |
[3] | Minikube と その他 必要なツールをインストールします。 |
# kubectl インストール root@dlp:~# snap install kubectl --classic kubectl 1.27.3 from Canonical✓ installed 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.30.1 commit: 08896fd1dc362c097c925146c4a0d0dac715ace0 一般ユーザーで利用する場合は [libvirt] グループに追加 root@dlp:~# usermod -aG libvirt debian |
[4] | 任意のユーザーで Minikube を起動します。 |
# minikube 起動 debian@dlp:~$ minikube start --vm-driver=kvm2 * minikube v1.30.1 on Debian 12.0 (kvm/amd64) * Using the kvm2 driver based on user configuration * Downloading VM boot image ... > minikube-v1.30.1-amd64.iso....: 65 B / 65 B [---------] 100.00% ? p/s 0s > minikube-v1.30.1-amd64.iso: 282.84 MiB / 282.84 MiB 100.00% 34.15 MiB p * Starting control plane node minikube in cluster minikube * Downloading Kubernetes v1.26.3 preload ... > preloaded-images-k8s-v18-v1...: 397.02 MiB / 397.02 MiB 100.00% 38.09 M * Creating kvm2 VM (CPUs=2, Memory=3900MB, Disk=20000MB) ... * Preparing Kubernetes v1.26.3 on Docker 20.10.23 ... - Generating certificates and keys ... - Booting up control plane ... - Configuring RBAC rules ... * Configuring bridge CNI (Container Networking Interface) ... - Using image gcr.io/k8s-minikube/storage-provisioner:v5 * Verifying Kubernetes components... * 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.42: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.42:8443 CoreDNS is running at https://192.168.39.42: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 2m4s v1.26.3 # 仮想マシン [minikube] が起動 debian@dlp:~$ sudo virsh list Id Name State -------------------------- 1 minikube running # 仮想マシンへ SSH アクセス debian@dlp:~$ minikube ssh _ _ _ _ ( ) ( ) ___ ___ (_) ___ (_)| |/') _ _ | |_ __ /' _ ` _ `\| |/' _ `\| || , < ( ) ( )| '_`\ /'__`\ | ( ) ( ) || || ( ) || || |\`\ | (_) || |_) )( ___/ (_) (_) (_)(_)(_) (_)(_)(_) (_)`\___/'(_,__/'`\____)
$
$ hostname minikube docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 4582fb53b223 5185b96f0bec "/coredns -conf /etc…" 2 minutes ago Up 2 minutes k8s_coredns_coredns-787d4945fb-fhlnr_kube-system_ea777e06-da13-4c0c-809a-90409f888259_0 9193904e839f registry.k8s.io/pause:3.9 "/pause" 2 minutes ago Up 2 minutes k8s_POD_coredns-787d4945fb-fhlnr_kube-system_ea777e06-da13-4c0c-809a-90409f888259_0 d5444e4911d2 6e38f40d628d "/storage-provisioner" 2 minutes ago Up 2 minutes k8s_storage-provisioner_storage-provisioner_kube-system_c11506ec-72e9-42f0-b87a-7adc5bc77e71_0 d528456e7ab1 92ed2bec97a6 "/usr/local/bin/kube…" 2 minutes ago Up 2 minutes k8s_kube-proxy_kube-proxy-mzds8_kube-system_80754b13-0d66-422a-b7e4-f584b0d66745_0 5c0cca8c1af4 registry.k8s.io/pause:3.9 "/pause" 2 minutes ago Up 2 minutes k8s_POD_storage-provisioner_kube-system_c11506ec-72e9-42f0-b87a-7adc5bc77e71_0 3b350e970332 registry.k8s.io/pause:3.9 "/pause" 2 minutes ago Up 2 minutes k8s_POD_kube-proxy-mzds8_kube-system_80754b13-0d66-422a-b7e4-f584b0d66745_0 209a2934c18d fce326961ae2 "etcd --advertise-cl…" 3 minutes ago Up 3 minutes k8s_etcd_etcd-minikube_kube-system_284d33246f81afe3f4e224f449e64f2e_0 eeacd6c4ea58 ce8c2293ef09 "kube-controller-man…" 3 minutes ago Up 3 minutes k8s_kube-controller-manager_kube-controller-manager-minikube_kube-system_52fd999db5ff4014b83a4ad42c06b3b5_0 725040ce437a 5a7904736932 "kube-scheduler --au…" 3 minutes ago Up 3 minutes k8s_kube-scheduler_kube-scheduler-minikube_kube-system_0818f4b1a57de9c3f9c82667e7fcc870_0 6d75deeb2913 1d9b3cbae03c "kube-apiserver --ad…" 3 minutes ago Up 3 minutes k8s_kube-apiserver_kube-apiserver-minikube_kube-system_c8fb1e120f04ba61cb934126a250b35e_0 0a46ac1ae435 registry.k8s.io/pause:3.9 "/pause" 3 minutes ago Up 3 minutes k8s_POD_kube-scheduler-minikube_kube-system_0818f4b1a57de9c3f9c82667e7fcc870_0 927f5e751723 registry.k8s.io/pause:3.9 "/pause" 3 minutes ago Up 3 minutes k8s_POD_kube-controller-manager-minikube_kube-system_52fd999db5ff4014b83a4ad42c06b3b5_0 20789a32cef2 registry.k8s.io/pause:3.9 "/pause" 3 minutes ago Up 3 minutes k8s_POD_kube-apiserver-minikube_kube-system_c8fb1e120f04ba61cb934126a250b35e_0 ecbfd3d6ce06 registry.k8s.io/pause:3.9 "/pause" 3 minutes ago Up 3 minutes k8s_POD_etcd-minikube_kube-system_284d33246f81afe3f4e224f449e64f2e_0
$
exit
# minikube を停止する場合は以下 debian@dlp:~$ minikube stop * Stopping "minikube" in kvm2 ... * Node "minikube" stopped. # minikube を開始する場合は以下 debian@dlp:~$ minikube start * minikube v1.30.1 on Debian 12.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.26.3 on Docker 20.10.23 ... * Configuring bridge CNI (Container Networking Interface) ... * 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. sudo virsh list --all Id Name State -------------------------- |
Sponsored Link |
|