问题
由于k8s安装master一直处于NotReady状态查看日志出现 failed to find plugin “flannel” in path [/opt/cni/bin]
日志信息
Nov 04 00:35:47 k8s-node1 kubelet[2814]: : [failed to find plugin "flannel" in path [/opt/cni/bin]]
Nov 04 00:35:47 k8s-node1 kubelet[2814]: W1104 00:35:47.520553 2814 cni.go:239] Unable to update cni config: no valid networks found in /etc/cni/net.d
Nov 04 00:35:48 k8s-node1 kubelet[2814]: E1104 00:35:48.764306 2814 kubelet.go:2103] Container runtime network not ready: NetworkReady=false reason:NetworkPluginNotReady message:docker: network plugin is not ready: cni config uninitialized
Nov 04 00:35:52 k8s-node1 kubelet[2814]: W1104 00:35:52.524329 2814 cni.go:204] Error validating CNI config list {
Nov 04 00:35:52 k8s-node1 kubelet[2814]: "name": "cbr0",
Nov 04 00:35:52 k8s-node1 kubelet[2814]: "cniVersion": "0.3.1",
Nov 04 00:35:52 k8s-node1 kubelet[2814]: "plugins": [
Nov 04 00:35:52 k8s-node1 kubelet[2814]: {
Nov 04 00:35:52 k8s-node1 kubelet[2814]: "type": "flannel",
Nov 04 00:35:52 k8s-node1 kubelet[2814]: "delegate": {
Nov 04 00:35:52 k8s-node1 kubelet[2814]: "hairpinMode": true,
Nov 04 00:35:52 k8s-node1 kubelet[2814]: "isDefaultGateway": true
Nov 04 00:35:52 k8s-node1 kubelet[2814]: }
Nov 04 00:35:52 k8s-node1 kubelet[2814]: },
查看 /opt/cni/bin 缺少 flannel
查看节点状态
kubectl get nodes
查看日志命令
journalctl -u kubelet -f
解决方案
需要下载CNI插件:CNI plugins v0.8.6
github下载地址:https://github.com/containernetworking/plugins/releases/tag/v0.8.6
(在1.0.0版本后CNI Plugins中没有flannel)
下载后通过xftp 上传到Linux /home目录解压
tar zxvf cni-plugins-linux-amd64-v0.8.6.tgz
复制 flannel 到 /opt/cni/bin/
[root@k8s-node1 home]# cp flannel /opt/cni/bin/
查看节点状态
查看到状态立马变为Ready,至此解决问题。