主机:1台 系统:Ubuntu22.04 主机需求:

image.png

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.

啥意思呢: image.png

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时被创建; image.png

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

先测试jenkins吧,而后再搭一个kubeadm集群,不过实在的讲,搭建的技术含量太低,搭的再好再快也不过是入门角色,希望还是将精力放在svc\ConfigMap\Pv\PVC\Pod\RBAC\Pod调度、亲和反亲和、污点、日志、etcd备份等等以及更高级的功能上去吧,愿诸位运维能够容身于容器时代而后发挥自己的光和热。

-- minikube步骤来自jenkins官网:

https://www.jenkins.io/doc/book/installing/kubernetes/#create-a-minikube-cluster