Ubuntu 22.04
Sponsored Link

Minikube : インストール2022/09/02

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

root@dlp:~#
snap install kubectl --classic

kubectl 1.24.4 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.26.1
commit: 62e108c3dfdec8029a890ad6d8ef96b6461426dc
[4] 任意のユーザーで Minikube を起動します。
# minikube 起動

ubuntu@dlp:~$
minikube start --vm-driver=kvm2

* minikube v1.26.1 on Ubuntu 22.04 (kvm/amd64)
* Using the kvm2 driver based on user configuration
* Downloading VM boot image ...
    > minikube-v1.26.1-amd64.iso....:  65 B / 65 B [---------] 100.00% ? p/s 0s
    > minikube-v1.26.1-amd64.iso:  270.83 MiB / 270.83 MiB  100.00% 33.66 MiB p
* Starting control plane node minikube in cluster minikube
* Downloading Kubernetes v1.24.3 preload ...
    > preloaded-images-k8s-v18-v1...:  405.75 MiB / 405.75 MiB  100.00% 35.00 M
* Creating kvm2 VM (CPUs=2, Memory=4000MB, Disk=20000MB) ...
* Preparing Kubernetes v1.24.3 on Docker 20.10.17 ...
  - 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: default-storageclass, storage-provisioner
* Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default

# 状態確認

ubuntu@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 |
|-------------|------------|--------------|-----|

ubuntu@dlp:~$
minikube docker-env

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

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

ubuntu@dlp:~$
kubectl cluster-info

Kubernetes control plane is running at https://192.168.39.137:8443
CoreDNS is running at https://192.168.39.137:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

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

ubuntu@dlp:~$
kubectl get nodes

NAME       STATUS   ROLES           AGE     VERSION
minikube   Ready    control-plane   2m20s   v1.24.3

# 仮想マシン [minikube] が起動

ubuntu@dlp:~$
virsh list

 Id   Name       State
--------------------------
 1    minikube   running

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

ubuntu@dlp:~$
minikube ssh

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

$
hostname

minikube
$
docker ps

CONTAINER ID   IMAGE                  COMMAND                  CREATED         STATUS         PORTS     NAMES
ba2df987dbd4   6e38f40d628d           "/storage-provisioner"   2 minutes ago   Up 2 minutes             k8s_storage-provisioner_storage-provisioner_kube-system_a4f316b2-135a-4e62-807e-840884787ca2_1
affc76530cad   a4ca41631cc7           "/coredns -conf /etc…"   2 minutes ago   Up 2 minutes             k8s_coredns_coredns-6d4b75cb6d-9rmvr_kube-system_7edf8f2c-0854-4abd-8b5b-282ac404c648_0
d4f57dece8cf   2ae1ba6417cb           "/usr/local/bin/kube…"   2 minutes ago   Up 2 minutes             k8s_kube-proxy_kube-proxy-v7nw2_kube-system_065252cb-00b4-4d42-9aa1-1e0d082061d0_0
47f5ed394665   k8s.gcr.io/pause:3.6   "/pause"                 2 minutes ago   Up 2 minutes             k8s_POD_coredns-6d4b75cb6d-9rmvr_kube-system_7edf8f2c-0854-4abd-8b5b-282ac404c648_0
291f0c42fa76   k8s.gcr.io/pause:3.6   "/pause"                 2 minutes ago   Up 2 minutes             k8s_POD_storage-provisioner_kube-system_a4f316b2-135a-4e62-807e-840884787ca2_0
4d913a4ff693   k8s.gcr.io/pause:3.6   "/pause"                 2 minutes ago   Up 2 minutes             k8s_POD_kube-proxy-v7nw2_kube-system_065252cb-00b4-4d42-9aa1-1e0d082061d0_0
241694551ccb   3a5aa3a515f5           "kube-scheduler --au…"   3 minutes ago   Up 3 minutes             k8s_kube-scheduler_kube-scheduler-minikube_kube-system_2e95d5efbc70e877d20097c03ba4ff89_0
0dcd9a257722   586c112956df           "kube-controller-man…"   3 minutes ago   Up 3 minutes             k8s_kube-controller-manager_kube-controller-manager-minikube_kube-system_4f82078a5dfd579f16196dd9ef946750_0
fa273da5f334   aebe758cef4c           "etcd --advertise-cl…"   3 minutes ago   Up 3 minutes             k8s_etcd_etcd-minikube_kube-system_14e9e190fb437f166f99d456e822620c_0
f2e203d8d469   d521dd763e2e           "kube-apiserver --ad…"   3 minutes ago   Up 3 minutes             k8s_kube-apiserver_kube-apiserver-minikube_kube-system_dcc1d668a2ae9bf4dd040a9a8565027e_0
55718f04b123   k8s.gcr.io/pause:3.6   "/pause"                 3 minutes ago   Up 3 minutes             k8s_POD_kube-controller-manager-minikube_kube-system_4f82078a5dfd579f16196dd9ef946750_0
720397b4f602   k8s.gcr.io/pause:3.6   "/pause"                 3 minutes ago   Up 3 minutes             k8s_POD_kube-scheduler-minikube_kube-system_2e95d5efbc70e877d20097c03ba4ff89_0
61925267ebf0   k8s.gcr.io/pause:3.6   "/pause"                 3 minutes ago   Up 3 minutes             k8s_POD_etcd-minikube_kube-system_14e9e190fb437f166f99d456e822620c_0
1304235aa14e   k8s.gcr.io/pause:3.6   "/pause"                 3 minutes ago   Up 3 minutes             k8s_POD_kube-apiserver-minikube_kube-system_dcc1d668a2ae9bf4dd040a9a8565027e_0

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

ubuntu@dlp:~$
minikube stop

* Stopping "minikube" in kvm2 ...
* Node "minikube" stopped.
# minikube を開始する場合は以下

ubuntu@dlp:~$
minikube start

* minikube v1.26.1 on Ubuntu 22.04 (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.24.3 on Docker 20.10.17 ...
* 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 仮想マシンを削除する場合は以下

ubuntu@dlp:~$
minikube delete

Deleting local Kubernetes cluster...
Machine deleted.
ubuntu@dlp:~$
virsh list --all

 Id   Name       State
--------------------------

関連コンテンツ