http://www.voidcn.com/article/p-wpuagtbj-byy.html
? 考虑到node节点的kubelet报错Unable to update cni config: No networks found in /etc/cni/net.d,并且master节点的/etc/cni/net.d目录里拥有10-flannel.conflist文件,
? 我们可以把该文件从master节点复制到node节点的对应目录中,然后重启kubelet服务即可。
? (该方法亡羊补牢,对我的问题也没用)
我这边使用这个方法解决的 感觉挺有效果 留下来.
一开始的状态:
[root@k8s106 ~]# kubectl get node
NAME STATUS ROLES AGE VERSION
k8s106 Ready master 59d v1.14.1
k8snode01 NotReady <none> 2d22h v1.14.1
当时报错信息为:
[root@k8snode01 flannel]# systemctl status kubelet
● kubelet.service - kubelet: The Kubernetes Node Agent
Loaded: loaded (/usr/lib/systemd/system/kubelet.service; enabled; vendor preset: disabled)
Drop-In: /usr/lib/systemd/system/kubelet.service.d
└─10-kubeadm.conf
Active: active (running) since Fri 2020-01-17 09:25:06 CST; 7min ago
Docs: https://kubernetes.io/docs/
Main PID: 5694 (kubelet)
CGroup: /system.slice/kubelet.service
└─5694 /usr/bin/kubelet --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf --config=/var/lib/kubelet/config.yaml --cgroup-driver=systemd --network-plugin=cni --pod-infra-container-image=k8s.gcr.io/pause:3.1
Jan 17 09:32:11 k8snode01 kubelet[5694]: W0117 09:32:11.141609 5694 cni.go:213] Unable to update cni config: No networks found in /etc/cni/net.d
Jan 17 09:32:11 k8snode01 kubelet[5694]: E0117 09:32:11.666478 5694 kubelet.go:2170] Container runtime network not ready: NetworkReady=false reason:NetworkPluginNotReady message:docker: network plugin is not ready: cni config uninitialized
Jan 17 09:32:16 k8snode01 kubelet[5694]: W0117 09:32:16.142092 5694 cni.go:213] Unable to update cni config: No networks found in /etc/cni/net.d
Jan 17 09:32:16 k8snode01 kubelet[5694]: E0117 09:32:16.668065 5694 kubelet.go:2170] Container runtime network not ready: NetworkReady=false reason:NetworkPluginNotReady message:docker: network plugin is not ready: cni config uninitialized
Jan 17 09:32:21 k8snode01 kubelet[5694]: W0117 09:32:21.142460 5694 cni.go:213] Unable to update cni config: No networks found in /etc/cni/net.d
Jan 17 09:32:21 k8snode01 kubelet[5694]: E0117 09:32:21.669779 5694 kubelet.go:2170] Container runtime network not ready: NetworkReady=false reason:NetworkPluginNotReady message:docker: network plugin is not ready: cni config uninitialized
Jan 17 09:32:26 k8snode01 kubelet[5694]: W0117 09:32:26.142913 5694 cni.go:213] Unable to update cni config: No networks found in /etc/cni/net.d
Jan 17 09:32:26 k8snode01 kubelet[5694]: E0117 09:32:26.671288 5694 kubelet.go:2170] Container runtime network not ready: NetworkReady=false reason:NetworkPluginNotReady message:docker: network plugin is not ready: cni config uninitialized
Jan 17 09:32:31 k8snode01 kubelet[5694]: W0117 09:32:31.143443 5694 cni.go:213] Unable to update cni config: No networks found in /etc/cni/net.d
Jan 17 09:32:31 k8snode01 kubelet[5694]: E0117 09:32:31.673118 5694 kubelet.go:2170] Container runtime network not ready: NetworkReady=false reason:NetworkPluginNotReady message:docker: network plugin is not ready: cni config uninitialized
集群搭建的过程中,master节点初始化成功,但 node节点加入集群时却一直显示NotReady状态,如下:
使用kubeclt describe node xxxx
命令,发现报错:
KubeletNotReady runtime network not ready: NetworkReady=false reason:NetworkPluginNotReady message:docker: network plugin is not ready: cni config uninitialized
进入node节点,执行 systemctl status kubelet
和 journalctl -xeu kubelet
命令,发现报错:
Unable to update cni config: No networks found in /etc/cni/net.d
原因:
该错误意思是 CNI插件还未安装,所以状态会是NotReady。
解决:
方法一:
? 编辑 /etc/systemd/system/kubelet.service.d/10-kubeadm.conf文件(有的是/usr/lib/systemd/system/kubelet.service.d/10-kubeadm.conf文件),
? 删除最后一行里的$KUBELET_NETWORK_ARGS 即可。
? (该方法治标不治本,没能解决我的问题)
方法二:
? 考虑到node节点的kubelet报错Unable to update cni config: No networks found in /etc/cni/net.d,并且master节点的/etc/cni/net.d目录里拥有10-flannel.conflist文件,
? 我们可以把该文件从master节点复制到node节点的对应目录中,然后重启kubelet服务即可。
? (该方法亡羊补牢,对我的问题也没用)
方法三:
? 注意到master节点的/etc/cni/net.d/10-flannel.conflist文件是经过 安装flannel插件 才生成的,而node节点则是在master节点安装完flannel插件后才加入集群的, ? 所以,我们不妨 先加入node节点,再执行 flannel插件的安装。 ? (该方法有取巧的嫌疑,但解决了我的问题)