2023-04-19 更新内容:
error execution phase couldn‘t initialize a Kubernetes cluster
这个报错除了虚拟机或软件包配置错误错误引起之外,还有可能是因为安装的Docker
版本太新了。
安装
Docker v23
会导致kubernetes init
报这个错误,原因没找到,据我猜测大概原因是因为Docker
版本太新了,配置文件的后缀名改动影响了Kubernetes
。
因为
Kubernetes
从1.24
之后就移除了dockershim
,所以安装最新版本的Kubernetes
还想用Docker
的话就需要安装cri-dockerd
,大概率是因为cri-dockerd
读取的配置还是低版本的,而最新版本
Docker v23
的配置文件目前
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/
{
"exec-opts": [
"=systemd"
],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
},
"storage-driver": "overlay2",
"storage-opts": [
"overlay2.override_kernel_check=true"
],
"registry-mirrors" : [
"/"
],
"graph": "/data/docker"
}
$ systemctl daemon-reload
$ systemctl restart docker
将 Docker Cgroup
驱动程序修改为 systemd
然后加载配置,重新启动 Docker
服务。