kubectl get nodes出现status NotReady
1. 简介
使用kubectl get nodes
查看nodes的运行状态,发现所有的master nodes和worker nodes都一直是NotReady状态。
2. 解决思路及方案
查看NotReady状态nodes的pod状态
运行kubectl get pods -n kube-system -owide | grep <nodesname>
所有的container处于运行状态,这个时候使用journalctl -f -u kubelet
查看具体什么原因导致运行不成功。命令运行结果为:
-- Logs begin at Thu 2022-07-14 01:59:52 EDT. --
Jul 17 15:52:52 kali kubelet[8924]: I0717 15:52:52.454429 8924 image_gc_manager.go:327] "Attempting to delete unused images"
Jul 17 15:52:52 kali kubelet[8924]: I0717 15:52:52.459540 8924 eviction_manager.go:349] "Eviction manager: must evict pod(s) to reclaim" resourceName="ephemeral-storage"
Jul 17 15:52:52 kali kubelet[8924]: I0717 15:52:52.459578 8924 eviction_manager.go:367] "Eviction manager: pods ranked for eviction" pods=[kube-system/etcd-kali kube-system/kube-apiserver-kali kube-system/kube-controller-manager-kali kube-system/kube-scheduler-kali kube-system/kube-proxy-x725l]
Jul 17 15:52:52 kali kubelet[8924]: E0717 15:52:52.459591 8924 eviction_manager.go:560] "Eviction manager: cannot evict a critical pod" pod="kube-system/etcd-kali"
Jul 17 15:52:52 kali kubelet[8924]: E0717 15:52:52.459596 8924 eviction_manager.go:560] "Eviction manager: cannot evict a critical pod" pod="kube-system/kube-apiserver-kali"
Jul 17 15:52:52 kali kubelet[8924]: E0717 15:52:52.459600 8924 eviction_manager.go:560] "Eviction manager: cannot evict a critical pod" pod="kube-system/kube-controller-manager-kali"
Jul 17 15:52:52 kali kubelet[8924]: E0717 15:52:52.459605 8924 eviction_manager.go:560] "Eviction manager: cannot evict a critical pod" pod="kube-system/kube-scheduler-kali"
Jul 17 15:52:52 kali kubelet[8924]: E0717 15:52:52.459609 8924 eviction_manager.go:560] "Eviction manager: cannot evict a critical pod" pod="kube-system/kube-proxy-x725l"
Jul 17 15:52:52 kali kubelet[8924]: I0717 15:52:52.459615 8924 eviction_manager.go:390] "Eviction manager: unable to evict any pods from the node"
Jul 17 15:52:55 kali kubelet[8924]: E0717 15:52:55.020983 8924 kubelet.go:2344] "Container runtime network not ready" networkReady="NetworkReady=false reason:NetworkPluginNotReady message:Network plugin returns error: cni plugin not initialized"
Jul 17 15:53:00 kali kubelet[8924]: E0717 15:53:00.022690 8924 kubelet.go:2344] "Container runtime network not ready" networkReady="NetworkReady=false reason:NetworkPluginNotReady message:Network plugin returns error: cni plugin not initialized"
由此可以看到错误原因是”Container runtime network not ready” networkReady=”NetworkReady=false reason:NetworkPluginNotReady message:Network plugin returns error: cni plugin not initialized”
这时可以确定没有安装网络插件,执行命令:kubectl apply -f https://github.com/coreos/flannel/raw/master/Documentation/kube-flannel.yml
如果安装kube-flannel.yml不能解决问题,那么就安装calico.yaml
curl https://projectcalico.docs.tigera.io/v3.23/manifests/calico-policy-only.yaml -o calico.yaml
kubectl apply -f calico.yaml
本作品采用《CC 协议》,转载必须注明作者和本文链接