CentOS Stream 8
Sponsored Link

Minikube : インストール2021/04/07

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

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

kubectl 1.20.5 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.18.1
commit: 09ee84d530de4a92f00f1c5dbc34cead092b95bc
[4] Minikube を利用する任意のユーザーを [libvirt] グループに登録しておきます。
[root@dlp ~]#
usermod -aG libvirt cent

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

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

* minikube v1.18.1 on Centos 8 (kvm/amd64)
* Using the kvm2 driver based on user configuration
* Downloading VM boot image ...
    > minikube-v1.18.0.iso.sha256: 65 B / 65 B [-------------] 100.00% ? p/s 0s
    > minikube-v1.18.0.iso: 212.99 MiB / 212.99 MiB [] 100.00% 48.80 MiB p/s 4s
* Starting control plane node minikube in cluster minikube
* Downloading Kubernetes v1.20.2 preload ...
    > preloaded-images-k8s-v9-v1....: 491.22 MiB / 491.22 MiB  100.00% 28.38 Mi
* Creating kvm2 VM (CPUs=2, Memory=3900MB, Disk=20000MB) ...
* Preparing Kubernetes v1.20.2 on Docker 20.10.3 ...
  - Generating certificates and keys ...
  - Booting up control plane ...
  - Configuring RBAC rules ...
* Verifying Kubernetes components...
  - Using image gcr.io/k8s-minikube/storage-provisioner:v4
* Enabled addons: storage-provisioner, default-storageclass
* Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default

# 状態確認

[cent@dlp ~]$
minikube status

minikube
type: Control Plane
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured
timeToStop: Nonexistent

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.217: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 control plane is running at https://192.168.39.217:8443
KubeDNS is running at https://192.168.39.217: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    control-plane,master   2m21s   v1.20.2

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

[cent@dlp ~]$
minikube ssh

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

$
hostname

minikube
$
docker ps

CONTAINER ID   IMAGE                  COMMAND                  CREATED         STATUS         PORTS     NAMES
8ca787d5bfe4   85069258b98a           "/storage-provisioner"   2 minutes ago   Up 2 minutes             k8s_storage-provisioner_storage-provisioner_kube-system_162ede17-911b-434e-ab61-aac61efb3512_0
aee34fdb1fcc   k8s.gcr.io/pause:3.2   "/pause"                 2 minutes ago   Up 2 minutes             k8s_POD_storage-provisioner_kube-system_162ede17-911b-434e-ab61-aac61efb3512_0
6c675e18b651   bfe3a36ebd25           "/coredns -conf /etc…"   2 minutes ago   Up 2 minutes             k8s_coredns_coredns-74ff55c5b-vpd7s_kube-system_ab816b2e-25fa-47a5-82a2-5c963fbed9d0_0
cfdc8b994bf3   43154ddb57a8           "/usr/local/bin/kube…"   2 minutes ago   Up 2 minutes             k8s_kube-proxy_kube-proxy-h6ltx_kube-system_a924ed5b-3c53-4645-b8d9-dc0eb17c28e7_0
5ce000faeea9   k8s.gcr.io/pause:3.2   "/pause"                 2 minutes ago   Up 2 minutes             k8s_POD_coredns-74ff55c5b-vpd7s_kube-system_ab816b2e-25fa-47a5-82a2-5c963fbed9d0_0
ae46a881ec78   k8s.gcr.io/pause:3.2   "/pause"                 2 minutes ago   Up 2 minutes             k8s_POD_kube-proxy-h6ltx_kube-system_a924ed5b-3c53-4645-b8d9-dc0eb17c28e7_0
cd8614ee5934   0369cf4303ff           "etcd --advertise-cl…"   2 minutes ago   Up 2 minutes             k8s_etcd_etcd-minikube_kube-system_fbcb933157241f87844dcfb78bd9e404_0
d01f997bd556   a8c2fdb8bf76           "kube-apiserver --ad…"   2 minutes ago   Up 2 minutes             k8s_kube-apiserver_kube-apiserver-minikube_kube-system_841b5e9b4f4bbf9f7ed9cce17a183644_0
8550ed926048   a27166429d98           "kube-controller-man…"   2 minutes ago   Up 2 minutes             k8s_kube-controller-manager_kube-controller-manager-minikube_kube-system_474c55dfb64741cc485e46b6bb9f2dc0_0
45965d91c499   ed2c44fbdd78           "kube-scheduler --au…"   2 minutes ago   Up 2 minutes             k8s_kube-scheduler_kube-scheduler-minikube_kube-system_6b4a0ee8b3d15a1c2e47c15d32e6eb0d_0
b57772a6bc5e   k8s.gcr.io/pause:3.2   "/pause"                 3 minutes ago   Up 2 minutes             k8s_POD_kube-scheduler-minikube_kube-system_6b4a0ee8b3d15a1c2e47c15d32e6eb0d_0
e1c9fddd9389   k8s.gcr.io/pause:3.2   "/pause"                 3 minutes ago   Up 2 minutes             k8s_POD_kube-controller-manager-minikube_kube-system_474c55dfb64741cc485e46b6bb9f2dc0_0
d2c412702812   k8s.gcr.io/pause:3.2   "/pause"                 3 minutes ago   Up 2 minutes             k8s_POD_kube-apiserver-minikube_kube-system_841b5e9b4f4bbf9f7ed9cce17a183644_0
4bbbecfe086d   k8s.gcr.io/pause:3.2   "/pause"                 3 minutes ago   Up 2 minutes             k8s_POD_etcd-minikube_kube-system_fbcb933157241f87844dcfb78bd9e404_0

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

[cent@dlp ~]$
minikube stop

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

[cent@dlp ~]$
minikube start

* minikube v1.18.1 on Centos 8 (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.20.2 on Docker 20.10.3 ...
* Verifying Kubernetes components...
  - Using image gcr.io/k8s-minikube/storage-provisioner:v4
* Enabled addons: storage-provisioner, default-storageclass
* Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default

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

[cent@dlp ~]$
minikube delete

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