Ubuntu Minikubeをインストールする方法

環境
Ubuntu 24.04

概要
シングルノードで Kubernetes クラスターを構成可能な Minikube をインストールします。

1.kubectlをインストール

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# snap install kubectl --classic
kubectl 1.29.4 from Canonical✓ installed
# snap install kubectl --classic kubectl 1.29.4 from Canonical✓ installed
# snap install kubectl --classic
kubectl 1.29.4 from Canonical✓ installed

2.Minikube と その他 必要なツールをインストールします。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# wget https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 -O minikube
# wget https://storage.googleapis.com/minikube/releases/latest/docker-machine-driver-kvm2
# wget https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 -O minikube # wget https://storage.googleapis.com/minikube/releases/latest/docker-machine-driver-kvm2
# wget https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 -O minikube
# wget https://storage.googleapis.com/minikube/releases/latest/docker-machine-driver-kvm2

# chmod 755 minikube docker-machine-driver-kvm2
# mv minikube docker-machine-driver-kvm2 /usr/local/bin/
バージョンを確認します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# minikube version
minikube version: v1.33.0
commit: 75fc9d54fca63f295d8737c8eacdbb7987e89c67
# minikube version minikube version: v1.33.0 commit: 75fc9d54fca63f295d8737c8eacdbb7987e89c67
# minikube version
minikube version: v1.33.0
commit: 75fc9d54fca63f295d8737c8eacdbb7987e89c67

3.minikubeを起動します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
$ minikube start --vm-driver=kvm2
$ minikube start --vm-driver=kvm2
$ minikube start --vm-driver=kvm2

状態確認

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
$ minikube status
minikube
type: Control Plane
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured
$ minikube status minikube type: Control Plane host: Running kubelet: Running apiserver: Running kubeconfig: Configured
$ minikube status
minikube
type: Control Plane
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured

$ minikube service list

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
|-------------|------------|--------------|-----|
| NAMESPACE | NAME | TARGET PORT | URL |
|-------------|------------|--------------|-----|
| default | kubernetes | No node port | |
| kube-system | kube-dns | No node port | |
|-------------|------------|--------------|-----|
|-------------|------------|--------------|-----| | NAMESPACE | NAME | TARGET PORT | URL | |-------------|------------|--------------|-----| | default | kubernetes | No node port | | | kube-system | kube-dns | No node port | | |-------------|------------|--------------|-----|
|-------------|------------|--------------|-----|
| NAMESPACE | NAME | TARGET PORT | URL |
|-------------|------------|--------------|-----|
| default | kubernetes | No node port | |
| kube-system | kube-dns | No node port | |
|-------------|------------|--------------|-----|

$ minikube docker-env

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.21.44: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)
export DOCKER_TLS_VERIFY="1" export DOCKER_HOST="tcp://192.168.21.44: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)
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.21.44: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)

 

$ kubectl cluster-info

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Kubernetes control plane is running at https://192.168.21.44:8443
CoreDNS is running at https://192.168.21.44:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
Kubernetes control plane is running at https://192.168.21.44:8443 CoreDNS is running at https://192.168.21.44:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
Kubernetes control plane is running at https://192.168.21.44:8443
CoreDNS is running at https://192.168.21.44:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

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

 

$ kubectl get nodes

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
NAME STATUS ROLES AGE VERSION
minikube Ready control-plane 2m55s v1.30.0
NAME STATUS ROLES AGE VERSION minikube Ready control-plane 2m55s v1.30.0
NAME STATUS ROLES AGE VERSION
minikube Ready control-plane 2m55s v1.30.0

 

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

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
$ virsh list
Id Name State
--------------------------
1 minikube running
$ virsh list Id Name State -------------------------- 1 minikube running
$ virsh list
 Id   Name       State
--------------------------
 1    minikube   running

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

IT

Posted by arkgame