Ubuntu 24.04
Sponsored Link

Minikube : インストール2024/05/13

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

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

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

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

* minikube v1.33.0 on Ubuntu 24.04 (kvm/amd64)
* Using the kvm2 driver based on user configuration
* Downloading VM boot image ...
    > minikube-v1.33.0-amd64.iso....:  65 B / 65 B [---------] 100.00% ? p/s 0s
    > minikube-v1.33.0-amd64.iso:  314.16 MiB / 314.16 MiB  100.00% 30.86 MiB p
* Starting "minikube" primary control-plane node in "minikube" cluster
* Downloading Kubernetes v1.30.0 preload ...
    > preloaded-images-k8s-v18-v1...:  342.90 MiB / 342.90 MiB  100.00% 26.57 M
* Creating kvm2 VM (CPUs=2, Memory=3900MB, Disk=20000MB) ...
* Preparing Kubernetes v1.30.0 on Docker 26.0.1 ...
  - Generating certificates and keys ...
  - Booting up control plane ...
  - Configuring RBAC rules ...
* Configuring bridge CNI (Container Networking Interface) ...
* 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.62: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.62:8443
CoreDNS is running at https://192.168.39.62: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   2m55s   v1.30.0

# 仮想マシン [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
33db0a7f6652   6e38f40d628d                "/storage-provisioner"   32 minutes ago   Up 32 minutes             k8s_storage-provisioner_storage-provisioner_kube-system_0d187c17-5c06-4ab9-a381-126f4a6b1d50_1
030760ed8ae9   cbb01a7bd410                "/coredns -conf /etc…"   33 minutes ago   Up 33 minutes             k8s_coredns_coredns-7db6d8ff4d-bwxmv_kube-system_a4a79ecc-7e98-4bf0-b349-fbb97f63eeb4_0
ad4d370506e3   a0bf559e280c                "/usr/local/bin/kube…"   33 minutes ago   Up 33 minutes             k8s_kube-proxy_kube-proxy-7vjpm_kube-system_249ae6be-818d-4ef3-9d99-e6b402cf6aa1_0
2c80e572e5da   registry.k8s.io/pause:3.9   "/pause"                 33 minutes ago   Up 33 minutes             k8s_POD_coredns-7db6d8ff4d-bwxmv_kube-system_a4a79ecc-7e98-4bf0-b349-fbb97f63eeb4_0
d211c444ffbd   registry.k8s.io/pause:3.9   "/pause"                 33 minutes ago   Up 33 minutes             k8s_POD_kube-proxy-7vjpm_kube-system_249ae6be-818d-4ef3-9d99-e6b402cf6aa1_0
25337aa8a102   registry.k8s.io/pause:3.9   "/pause"                 33 minutes ago   Up 33 minutes             k8s_POD_storage-provisioner_kube-system_0d187c17-5c06-4ab9-a381-126f4a6b1d50_0
dabce2953cd8   259c8277fcbb                "kube-scheduler --au…"   33 minutes ago   Up 33 minutes             k8s_kube-scheduler_kube-scheduler-minikube_kube-system_f9c8e1d0d74b1727abdb4b4a31d3a7c1_0
e85e1704cebc   c7aad43836fa                "kube-controller-man…"   33 minutes ago   Up 33 minutes             k8s_kube-controller-manager_kube-controller-manager-minikube_kube-system_b2f93c4e2ec4e1950aa41a71fd8273b0_0
3c7c5c5cbac8   3861cfcd7c04                "etcd --advertise-cl…"   33 minutes ago   Up 33 minutes             k8s_etcd_etcd-minikube_kube-system_10cb81fa5309922a3c3ac988dcf0dc4c_0
7c842f6f8c88   c42f13656d0b                "kube-apiserver --ad…"   33 minutes ago   Up 33 minutes             k8s_kube-apiserver_kube-apiserver-minikube_kube-system_63e6376c2b1b0f6d5a0644b3b3a9632c_0
5848515fe952   registry.k8s.io/pause:3.9   "/pause"                 33 minutes ago   Up 33 minutes             k8s_POD_kube-scheduler-minikube_kube-system_f9c8e1d0d74b1727abdb4b4a31d3a7c1_0
9ee0eb332cad   registry.k8s.io/pause:3.9   "/pause"                 33 minutes ago   Up 33 minutes             k8s_POD_kube-controller-manager-minikube_kube-system_b2f93c4e2ec4e1950aa41a71fd8273b0_0
86aa5885f8ad   registry.k8s.io/pause:3.9   "/pause"                 33 minutes ago   Up 33 minutes             k8s_POD_kube-apiserver-minikube_kube-system_63e6376c2b1b0f6d5a0644b3b3a9632c_0
e3f6aba11d57   registry.k8s.io/pause:3.9   "/pause"                 33 minutes ago   Up 33 minutes             k8s_POD_etcd-minikube_kube-system_10cb81fa5309922a3c3ac988dcf0dc4c_0

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

ubuntu@dlp:~$
minikube stop

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

ubuntu@dlp:~$
minikube start

* minikube v1.33.0 on Ubuntu 24.04 (kvm/amd64)
* Using the kvm2 driver based on existing profile
* Starting "minikube" primary control-plane node in "minikube" cluster
* Restarting existing kvm2 VM for "minikube" ...
* Preparing Kubernetes v1.30.0 on Docker 26.0.1 ...
* 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 仮想マシンを削除する場合は以下

ubuntu@dlp:~$
minikube delete

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

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

関連コンテンツ