《Kubernetes 排错指南-006》error execution phase couldn‘t initialize a Kubernetes cluster

2023-04-19 更新内容:

error execution phase couldn‘t initialize a Kubernetes cluster 这个报错除了虚拟机或软件包配置错误错误引起之外,还有可能是因为安装的 Docker 版本太新了。

安装 Docker v23 会导致 kubernetes init 报这个错误,原因没找到,据我猜测大概原因是因为 Docker 版本太新了,配置文件的后缀名改动影响了 Kubernetes

因为 Kubernetes1.24 之后就移除了 dockershim,所以安装最新版本的 Kubernetes 还想用 Docker 的话就需要安装 cri-dockerd,大概率是因为 cri-dockerd 读取的配置还是低版本的 daemon.json,而最新版本 Docker v23 的配置文件 daemon.conf 目前 cri-dockerd 还不支持。

系统环境:

  • VMware ESXi 7.0.2
  • Ubuntu 20.04 LTS
  • Docker 20.10.8
  • Kubernetes 1.22.1
  • Node: master

执行命令:

$ kubeadm init

报错如下:

Unfortunately, an error has occurred:
	timed out waiting for the condition

This error is likely caused by:
	- The kubelet is not running
	- The kubelet is unhealthy due to a misconfiguration of the node in some way (required cgroups disabled)

If you are on a systemd-powered system, you can try to troubleshoot the error with the following commands:
	- 'systemctl status kubelet'
	- 'journalctl -xeu kubelet'

Additionally, a control plane component may have crashed or exited when started by the container runtime.
To troubleshoot, list all containers using your preferred container runtimes CLI.

Here is one example how you may list all Kubernetes containers running in docker:
	- 'docker ps -a | grep kube | grep -v pause'
	Once you have found the failing container, you can inspect its logs with:
	- 'docker logs CONTAINERID'

error execution phase wait-control-plane: couldn't initialize a Kubernetes cluster	

报错说明:

这个问题一般是由虚拟机或软件包配置错误错误引起的,需要修改 Docker Cgroup 的驱动程序。

解决方案:

$ vi /etc/docker/daemon.json

{
  "exec-opts": [
  	"native.cgroupdriver=systemd"
  ],
  "log-driver": "json-file",
  "log-opts": {
  	"max-size": "100m"
  },
  "storage-driver": "overlay2",
  "storage-opts": [
  	"overlay2.override_kernel_check=true"
  ],
  "registry-mirrors" : [
  	"https://ot2k4d59.mirror.aliyuncs.com/"
  ],
  "graph": "/data/docker"
}

$ systemctl daemon-reload
$ systemctl restart docker

Docker Cgroup 驱动程序修改为 systemd 然后加载配置,重新启动 Docker 服务。

你可能感兴趣的:(#,Kubernetes,#,Docker,docker,kubernetes,VM,云原生,微服务)