天天看點

記一次minikube的使用

主機:1台

系統:Ubuntu22.04

主機需求:

記一次minikube的使用

1,下載下傳minikube運作程式

curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64

2,安裝生成執行程式,這沒放在/usr/bin或者/usr/sbin下是以又麻煩了一步,做了軟連接配接;

install minikube-linux-amd64 /usr/local/bin/minikube

ln -s /usr/local/bin/ /usr/bin/

3,此時安裝minikube所需的CRI,俺安裝的是docker;

apt-get install docker.io

4,而後,執行minukube啟動叢集運作時會報錯,解決方案在提示中;

minikube start

以下幾步都是報錯-----------------------

5,第四步報錯提示:

  • minikube v1.27.0 on Ubuntu 22.04

    ! Kubernetes 1.25.0 has a known issue with resolv.conf. minikube is using a workaround that should work for most use cases.

    ! For more information, see: https://github.com/kubernetes/kubernetes/issues/112135

    Automatically selected the docker driver. Other choices: ssh, none

    The "docker" driver should not be used with root privileges. If you wish to continue as root, use --force.

    If you are running minikube within a VM, consider using --driver=none:

    https://minikube.sigs.k8s.io/docs/reference/drivers/none/

    X Exiting due to DRV_AS_ROOT: The "docker" driver should not be used with root privileges.

啥意思呢:

記一次minikube的使用

6,主要是因為使用了root啟動,要麼換個賬号,要麼使用--force參數繼續運作,那麼換個賬号好了,于是它很頑強的接着報錯;

minikube v1.27.0 on Ubuntu 22.04

! Kubernetes 1.25.0 has a known issue with resolv.conf. minikube is using a workaround that should work for most use cases.

! For more information, see: https://github.com/kubernetes/kubernetes/issues/112135

Unable to pick a default driver. Here is what was considered, in preference order:

docker: Not healthy: "docker version --format {{.Server.Os}}-{{.Server.Version}}" exit status 1: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/version": dial unix /var/run/docker.sock: connect: permission denied

docker: Suggestion: Add your user to the 'docker' group: 'sudo usermod -aG docker $USER && newgrp docker' https://docs.docker.com/engine/install/linux-postinstall/

Alternatively you could install one of these drivers:

kvm2: Not installed: exec: "virsh": executable file not found in $PATH

podman: Not installed: exec: "podman": executable file not found in $PATH

vmware: Not installed: exec: "docker-machine-driver-vmware": executable file not found in $PATH

virtualbox: Not installed: unable to find VBoxManage in $PATH

qemu2: Not installed: exec: "qemu-system-x86_64": executable file not found in $PATH

X Exiting due to DRV_NOT_HEALTHY: Found driver(s) but none were healthy. See above for suggestions how to fix installed drivers.:

這段啥意思呢?主要是docker節點不健康,需要按照提示将目前使用者添加docker組,此組安裝docker時被建立;

記一次minikube的使用

7,于是乎,按照提示來吧:

sudo usermod -aG docker m && newgrp docker

8,而後,啟動minikube

m@mk8s-node-02:/tmp$ minikube start --driver=docker

minikube v1.27.0 on Ubuntu 22.04

Kubernetes 1.25.0 has a known issue with resolv.conf. minikube is using a workaround that should work for most use cases.

For more information, see: https://github.com/kubernetes/kubernetes/issues/112135

Using the docker driver based on existing profile

Starting control plane node minikube in cluster minikube

Pulling base image ...

docker "minikube" container is missing, will recreate.

Creating docker container (CPUs=2, Memory=2200MB) ...

Preparing Kubernetes v1.25.0 on Docker 20.10.17 ...

Generating certificates and keys ...

Booting up control plane ...

Configuring RBAC rules ...\ E0929 20:59:07.598949 17953 kubeadm.go:273] unable to create cluster role binding, some addons might not work: timeout apply sa: sudo /var/lib/minikube/binaries/v1.25.0/kubectl create clusterrolebinding minikube-rbac --clusterrole=cluster-admin --serviceaccount=kube-system:default --kubeconfig=/var/lib/minikube/kubeconfig: Process exited with status 1

stdout:

stderr:

error: failed to create clusterrolebinding: clusterrolebindings.rbac.authorization.k8s.io "minikube-rbac" already exists

Verifying Kubernetes components...

Executing "docker container inspect minikube --format={{.State.Status}}" took an unusually long time: 5.498703889s

Restarting the docker service may improve performance.

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

9,雖然又是一批報錯,是因為我此前啟動過,而後停止了該容器,并進行删除導緻的,現在可以使用了,不過是單台的不好玩,主要還是用來測試的,别在意;

m@mk8s-node-02:/tmp$ kubectl get nodes

NAME STATUS ROLES AGE VERSION

minikube Ready control-plane 86m v1.25.0