STATUS becomes NotReady after restart of kubernetes cluster node


Look at the log of the node on the master kubectl describe nodes k8s-node1 to
see the log:

kubelet stopped posting node status

The kubelet of the node is not started, log on to node1 and check the kubelet service status

systemctl status kubelet

Status is stopped, try to start kubelet

systemctl start kubelet

Startup failed, or stopped.
journalctl -e -u kubeletCheck the log and see the following:

Jan 21 19:41:56 k8s-node1 kubelet[18066]: I0121 19:41:56.046728   18066 server.go:416] Version: v1.20.1
Jan 21 19:41:56 k8s-node1 kubelet[18066]: I0121 19:41:56.047342   18066 server.go:837] Client rotation is on, will bootstrap in background
Jan 21 19:41:56 k8s-node1 kubelet[18066]: I0121 19:41:56.065802   18066 certificate_store.go:130] Loading cert/key pair from "/var/lib/kubelet/pki/kubelet-client-current.pem".
Jan 21 19:41:56 k8s-node1 kubelet[18066]: I0121 19:41:56.066770   18066 dynamic_cafile_content.go:167] Starting client-ca-bundle::/etc/kubernetes/pki/ca.crt
Jan 21 19:41:56 k8s-node1 kubelet[18066]: I0121 19:41:56.175135   18066 server.go:645] --cgroups-per-qos enabled, but --cgroup-root was not specified.  defaulting to /
Jan 21 19:41:56 k8s-node1 kubelet[18066]: F0121 19:41:56.175899   18066 server.go:269] failed to run Kubelet: running with swap on is not supported, please disable swap! or set --fail-swap
Jan 21 19:41:56 k8s-node1 kubelet[18066]: goroutine 1 [running]:

It turned out that the swap restarted after the server was restarted last time, and the kubelet could not be started.

solution

Close swap:

swapoff -a
然后重启kubelet
systemctl restart kubelet
重新查看服务状态
systemctl status kubelet
发现已经启动成功,node的状态也从NotReady变成Ready

However, if you restart the server again, there will be problems, so it is best to close swap directly
as follows:

vim /etc/fstab
把下面这一行注释掉
#/swap.img       none    swap    sw      0       0

Save and exit, kubelet will not have any problems after the next restart.

Guess you like

Origin blog.51cto.com/xiaozhenkai/2601477