只是初始化一个集群,没想到如此艰辛。
初始化集群使用如下命令:
sudo kubeadm init --kubernetes-version=v1.26.1 --ignore-preflight-errors=all
结果出现如题所示问题:
waiting for the kubelet to boot up the control plane as Static Pods from directory “/etc/kubernetes/manifests”
this might take a minute or longer if the control plane images have to be pulled
Unfortunately, an error has occurred:
timed out waiting for the condition
…
结合日志中的内容journalctl -xeu kubelet,搜索各种可能出现的问题,如下:
在自己的努力坚持下,终于看到这条内容:this might take a minute or longer if the control plane images have to be pulled #1023(https://github.com/kubernetes/kubeadm/issues/1023), 尝试一下,没想到竟然成功了!方法就是修改/lib/systemd/system/kubelet.service,添加kubelet启动参数如下:
[Service]
ExecStart=/usr/bin/kubelet --kubeconfig=/etc/kubernetes/kubelet.conf --config=/var/lib/kubelet/config.yaml
…
然后,重启计算机,执行sudo kubeadm reset 后重新执行sudo kubeadm init,成功进行了初始化:
[apiclient] All control plane components are healthy after 13.501844 seconds
[upload-config] Storing the configuration used in ConfigMap “kubeadm-config” in the “kube-system” Namespace
[kubelet] Creating a ConfigMap “kubelet-config” in namespace kube-system with the configuration for the kubelets in the cluster
…
现在回想起来,真是一把辛酸泪,还真是最开始提示的问题:“The kubelet is unhealthy due to a misconfiguration ”,但是谁要能想到是什么问题呢?