1. 程式人生 > 實用技巧 >k8s叢集故障二:節點為NotReady狀態

k8s叢集故障二:節點為NotReady狀態

按照教程部署完k8s的各個節點後,獲取節點資訊時,可是發現只有作為master和同時作為node的節點狀態才是正確的:

[root@k8s-master ~]# kubectl get node
NAME         STATUS     ROLES    AGE     VERSION
k8s-master   Ready      <none>   7d22h   v1.18.6
k8s1         NotReady   <none>   7d21h   v1.18.6
k8s2         NotReady   <none>   7d21h   v1.18.6

在node中檢視日誌:

7月 31 17:22:43 k8s1 kubelet[29033]: E0731 17:22:43.663415   29033 kubelet.go:2188] Container runtime network not ready: NetworkReady=false reason:NetworkPluginNotReady message:docker: network plugin is not ready: cni config uninitialized
7月 31 17:22:48 k8s1 kubelet[29033]: E0731 17:22:48.674388   29033 kubelet.go:2188] Container runtime network not ready: NetworkReady=false reason:NetworkPluginNotReady message:docker: network plugin is not ready: cni config uninitialized
7月 31 17:22:53 k8s1 kubelet[29033]: E0731 17:22:53.689125   29033 kubelet.go:2188] Container runtime network not ready: NetworkReady=false reason:NetworkPluginNotReady message:docker: network plugin is not ready: cni config uninitialized

網路問題導致,經過多次排查發現:因為是有k8s-master 主機直接遷移node需要的元件到另外的機器,所以在配置檔案中有兩處一定要做出修改:

[root@k8s1 ~]# vim /opt/kubernetes/cfg/kube-proxy-config.yml

hostnameOverride: k8s1 ##主機名

[root@k8s1 ~]#vim /opt/kubernetes/cfg/kubelet.conf

--hostname-override=k8s-node1

##在重新刪除相關證書檔案:

[root@k8s1 ~]# rm /opt/kubernetes/cfg/kubelet.kubeconfig

[root@k8s1 ~]# rm -f /opt/kubernetes/ssl/kubelet*

然後重啟伺服器