kubelet服务启动失败,错误代码255
用kubeadm的方法安装kubelet后,运行systemctl status kubelet 发现kubelet服务启动失败,错误代码255。
kubelet.service: main process exited, code=exited, status=255/n/a
检查了Swap已经关闭,SELinux已经被disabled,firewalld也已经被disabled,cgroup也已经和docker设置成一样。
并且发现有时候运行systemctl status kubelet 发现kubelet服务是正常的,一会再看又失败了的灵异事件。
后来查了资料,运行journalctl -xefu kubelet 命令查看systemd日志才发现,真正的错误是:
unable to load client CA file /etc/kubernetes/pki/ca.crt: open /etc/kubernetes/pki/ca.crt: no such file or directory
这个错误在运行kubeadm init 生成CA证书后会被自动解决,此处可先忽略。
再回过头来看Kubernets官方文档,其实里面已经写了很清楚了:
The kubelet is now restarting every few seconds, as it waits in a crashloop for kubeadm to tell it what to do. This crashloop is expected and normal, please proceed with the next step and the kubelet will start running normally.
简单地说就是在kubeadm init 之前kubelet会不断重启。