[1] Minikube – instalacja

9 lutego 2021 Wyłączono przez Adam [zicherka] Nogły

Zainstaluj Minikube, aby skonfigurować klaster Kubernetes na jednym węźle.

[1] Zainstaluj Hypervisora, który jest wspierany przez Minikube. W tym przykładzie zainstalowano KVM: [1] Instalacja KVM

[2] Zainstaluj Snapy: [18] Snappy – Instalacja

[3] Zainstaluj Minikube i pozostałe wymagane narzędzia.

# zainstaluj kubectl
[root@vlsr01 ~]# snap install kubectl --classic
kubectl 1.20.2 from Canonical✓ installed

[root@vlsr01 ~]# wget https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 -O minikube
[root@vlsr01 ~]# wget https://storage.googleapis.com/minikube/releases/latest/docker-machine-driver-kvm2
[root@vlsr01 ~]# chmod 755 minikube docker-machine-driver-kvm2
[root@vlsr01 ~]# mv minikube docker-machine-driver-kvm2 /usr/local/bin/

[root@vlsr01 ~]# minikube version
minikube version: v1.17.1
commit: 043bdca07e54ab6e4fc0457e3064048f34133d7e

4 Dodaj użytkownika, który będzie używał Minikube do grupy [libvirt].

[root@vlsr01 ~]# usermod -G libvirt user01

5 Uruchom Minikubez jako użytkownik, którego dodałeś do grupy [libvirt].

[user01@vlsr01 ~]$ minikube start --vm-driver=kvm2
* minikube v1.17.1 na Centos 8
* Using the kvm2 driver based on user configuration
* Pobieranie obrazu maszyny wirtualnej ...
> minikube-v1.17.0.iso.sha256: 65 B / 65 B [-------------] 100.00% ? p/s 0s
> minikube-v1.17.0.iso: 212.69 MiB / 212.69 MiB [] 100.00% 5.75 MiB p/s 37s
* Starting control plane node minikube in cluster minikube
* Downloading Kubernetes v1.20.2 preload ...
> preloaded-images-k8s-v8-v1....: 491.22 MiB / 491.22 MiB 100.00% 5.71 MiB
* Creating kvm2 VM (CPUs=2, Memory=2200MB, Disk=20000MB) ...
* Przygotowywanie Kubernetesa v1.20.2 na Docker 20.10.2...
- Generating certificates and keys ...
- Booting up control plane ...
- Configuring RBAC rules ...
* Verifying Kubernetes components...
* Enabled addons: default-storageclass, storage-provisioner
* Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default

# pokaż status
[user01@vlsr01 ~]$ minikube status
minikube
type: Control Plane
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured
timeToStop: Nonexistent

[user01@vlsr01 ~]$ minikube service list
|-------------|------------|--------------|-----|
| NAMESPACE | NAME | TARGET PORT | URL |
|-------------|------------|--------------|-----|
| default | kubernetes | No node port |
| kube-system | kube-dns | No node port |
|-------------|------------|--------------|-----|

[user01@vlsr01 ~]$ minikube docker-env
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.39.151:2376"
export DOCKER_CERT_PATH="/home/user01/.minikube/certs"
export MINIKUBE_ACTIVE_DOCKERD="minikube"

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

[user01@vlsr01 ~]$ kubectl cluster-info
Kubernetes control plane is running at https://192.168.39.151:8443
KubeDNS is running at https://192.168.39.151:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

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

[user01@vlsr01 ~]$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
minikube Ready control-plane,master 3m51s v1.20.2

# jest możliwy dostęp za pomocą SSH do maszyny wirtualnej
[user01@vlsr01 ~]$ minikube ssh
_ _
_ _ ( ) ( )
___ ___ (_) ___ (_)| |/') _ _ | |_ __
/' _ ` _ `\| |/' _ `\| || , < ( ) ( )| '_`\ /'__`\
| ( ) ( ) || || ( ) || || |\`\ | (_) || |_) )( ___/
(_) (_) (_)(_)(_) (_)(_)(_) (_)`\___/'(_,__/'`\____)

$ hostname # sprawdź nazwę hosta
minikube
$ docker ps # lista usług/procesów
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
aca8a23aeeca 85069258b98a "/storage-provisioner" 5 minutes ago Up 5 minutes k8s_storage-provisioner_storage-provisioner_kube-system_eb43456c-263b-4c05-8a20-922d84683f8c_1
7ef818dd6af7 bfe3a36ebd25 "/coredns -conf /etc…" 5 minutes ago Up 5 minutes k8s_coredns_coredns-74ff55c5b-z5xgf_kube-system_c0c81438-6f1a-4d22-ae95-2ac321b2eaf5_0
94c3f3164b40 43154ddb57a8 "/usr/local/bin/kube…" 5 minutes ago Up 5 minutes k8s_kube-proxy_kube-proxy-z7tf8_kube-system_bca4344a-fb3e-4c53-9503-bed6732573cc_0
5c8c434ad3aa k8s.gcr.io/pause:3.2 "/pause" 5 minutes ago Up 5 minutes k8s_POD_coredns-74ff55c5b-z5xgf_kube-system_c0c81438-6f1a-4d22-ae95-2ac321b2eaf5_0
76032d6a4c73 k8s.gcr.io/pause:3.2 "/pause" 5 minutes ago Up 5 minutes k8s_POD_kube-proxy-z7tf8_kube-system_bca4344a-fb3e-4c53-9503-bed6732573cc_0
a2089c6ccdf7 k8s.gcr.io/pause:3.2 "/pause" 5 minutes ago Up 5 minutes k8s_POD_storage-provisioner_kube-system_eb43456c-263b-4c05-8a20-922d84683f8c_0
3e64209717e8 a8c2fdb8bf76 "kube-apiserver --ad…" 6 minutes ago Up 6 minutes k8s_kube-apiserver_kube-apiserver-minikube_kube-system_0d03c0cd1dfc268235e9f5afaaadc5b8_0
01f99a3ae492 ed2c44fbdd78 "kube-scheduler --au…" 6 minutes ago Up 6 minutes k8s_kube-scheduler_kube-scheduler-minikube_kube-system_6b4a0ee8b3d15a1c2e47c15d32e6eb0d_0
7d654307f620 0369cf4303ff "etcd --advertise-cl…" 6 minutes ago Up 6 minutes k8s_etcd_etcd-minikube_kube-system_bb9b957ccc57c30b9de68e392888a739_0
d4b7f5d133d6 a27166429d98 "kube-controller-man…" 6 minutes ago Up 6 minutes k8s_kube-controller-manager_kube-controller-manager-minikube_kube-system_474c55dfb64741cc485e46b6bb9f2dc0_0
cf62f975b86a k8s.gcr.io/pause:3.2 "/pause" 6 minutes ago Up 6 minutes k8s_POD_kube-apiserver-minikube_kube-system_0d03c0cd1dfc268235e9f5afaaadc5b8_0
cd507279dcfb k8s.gcr.io/pause:3.2 "/pause" 6 minutes ago Up 6 minutes k8s_POD_kube-scheduler-minikube_kube-system_6b4a0ee8b3d15a1c2e47c15d32e6eb0d_0
19285bc4f976 k8s.gcr.io/pause:3.2 "/pause" 6 minutes ago Up 6 minutes k8s_POD_kube-controller-manager-minikube_kube-system_474c55dfb64741cc485e46b6bb9f2dc0_0
31e93cd15e16 k8s.gcr.io/pause:3.2 "/pause" 6 minutes ago Up 6 minutes k8s_POD_etcd-minikube_kube-system_bb9b957ccc57c30b9de68e392888a739_0
$ exit # wyjście
Logout

# zatrzymaj minikube
[user01@vlsr01 ~]$ minikube stop
* Stopping node "minikube" ...
* 1 nodes stopped.

# uruchom minikube
[user01@vlsr01 ~]$ minikube start
* minikube v1.17.1 na Centos 8
* Using the kvm2 driver based on existing profile
* Starting control plane node minikube in cluster minikube
* Restarting existing kvm2 VM for "minikube" ...
* Przygotowywanie Kubernetesa v1.20.2 na Docker 20.10.2...
* Verifying Kubernetes components...
* Enabled addons: storage-provisioner, default-storageclass
* Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default

# skasuj minikube
[user01@vlsr01 ~]$ minikube delete
* Usuwanie "minikube" - kvm2...
* Removed all traces of the "minikube" cluster.