初始化kubeadm报错

[kubelet-check] Initial timeout of 40s passed. Unfortunately, an error has occurred: timed out waiting for the condition

  1. This error is likely caused by:
  2. - The kubelet is not running
  3. - The kubelet is unhealthy due to a misconfiguration of the node in some way (required cgroups disabled)
  4. If you are on a systemd-powered system, you can try to troubleshoot the error with the following commands:
  5. - 'systemctl status kubelet'
  6. - 'journalctl -xeu kubelet'
  7. Additionally, a control plane component may have crashed or exited when started by the container runtime.
  8. To troubleshoot, list all containers using your preferred container runtimes CLI.
  9. Here is one example how you may list all Kubernetes containers running in docker:
  10. - 'docker ps -a | grep kube | grep -v pause'
  11. Once you have found the failing container, you can inspect its logs with:
  12. - 'docker logs CONTAINERID'

error execution phase wait-control-plane: couldn’t initialize a Kubernetes cluster To see the stack trace of this error execute with —v=5 or higher

解决方案:
主节点方案

查看日志 journalctl -xeu kubelet

程序一直在循环报这个错误:Unable to update cni config: No networks found in /etc/cni/net.d。这是为什么呢?这是因为前面设置了代理,导致kubelet访问API Server不通,所以需要关闭http proxy。

unset http_proxy https_proxy 或者 export no_proxy=192.168.1.118

重新初始化
前面已经执行过一次kubeadm init了,这个时候需要加个参数来忽略到这些:—ignore-preflight-errors=all

kubeadm init —apiserver-advertise-address=192.168.1.135 —image-repository registry.aliyuncs.com/google_containers —kubernetes-version v1.19.4 —service-cidr=10.96.0.0/12 —pod-network-cidr=10.244.0.0/16 —ignore-preflight-errors=all

从节点方案

初始化报错,重置reset

rm -rf /etc/kubernetes rm -rf ~/.kube/config rm -rf /etc/cni/net.d rm -rf /var/lib/etcd/* kubeadm reset -f