k8s etcd 运行错误 failed to find plugin “flannel“ in path [/usr/lib/cni]

表现形式为 coredns 一直处于 ContainerCreating 状态

shell 复制代码
root@master-node:~# kubectl -n kube-system get pod
NAME                                  READY   STATUS              RESTARTS   AGE
coredns-66bc5c9577-bg6r2              0/1     ContainerCreating   0          4m19s
coredns-66bc5c9577-zgrxl              0/1     ContainerCreating   0          4m19s
etcd-master-node                      1/1     Running             0          4m28s
kube-apiserver-master-node            1/1     Running             0          4m28s
kube-controller-manager-master-node   1/1     Running             0          4m28s
kube-proxy-k28lq                      1/1     Running             0          4m20s
kube-scheduler-master-node            1/1     Running             0          4m28s

describe 可以看到一些错误的事件

shell 复制代码
Events:
  Type     Reason                  Age                 From               Message
  ----     ------                  ----                ----               -------
  Warning  FailedScheduling        4m33s               default-scheduler  0/1 nodes are available: 1 node(s) had untolerated taint {node.kubernetes.io/not-ready: }. no new claims to deallocate, preemption: 0/1 nodes are available: 1 Preemption is not helpful for scheduling.
  Normal   Scheduled               97s                 default-scheduler  Successfully assigned kube-system/coredns-66bc5c9577-bg6r2 to master-node
  Warning  FailedCreatePodSandBox  96s                 kubelet            Failed to create pod sandbox: rpc error: code = Unknown desc = failed to setup network for sandbox "9d01df1e999793e5efa68228832ca7288668866636f933b46db5db7cae5a264d": plugin type="flannel" failed (add): failed to find plugin "flannel" in path [/usr/lib/cni]

检查发现 /usr/lib/cni 目录下确实没有 flannel 插件,查询之后看到 flannel/opt/cni/bin 位置,这个可能就是问题的根源,我并没有明确安装部署 flannel 可能是其他服务无意间下载到了这个目录

shell 复制代码
root@master-node:/usr/lib/cni# ls
bandwidth  bridge  dhcp  firewall  host-device  host-local  ipvlan  loopback  macvlan  portmap  ptp  sbr  static  tuning  vlan  vrf
r
shell 复制代码
root@master-node:/opt/cni/bin# ls
bandwidth  bridge  dhcp  dummy  firewall  flannel  host-device  host-local  ipvlan  LICENSE  loopback  macvlan  portmap  ptp  README.md  sbr  static  tap  tuning  vlan  vrf
r

解决方案创建符号链接

shell 复制代码
sudo ln -sf /opt/cni/bin/* /usr/lib/cni/

如果你没有 cni,还是需要下载的。

相关推荐
BullSmall5 小时前
第三方软件安全-Dependency‑Track Docker 部署
安全·docker·容器
IT大白鼠9 小时前
Docker 私有仓库管理:Harbor 企业级仓库搭建与镜像全生命周期管理
运维·docker·容器
bgy666612 小时前
从零上手 Docker,容器技术完整入门指南
运维·docker·容器
pride.li16 小时前
Docker教程-Docker安装与镜像配置
运维·docker·容器
bgy666616 小时前
Docker Swarm 容器编排实战指南
运维·docker·容器
再卷还是菜17 小时前
Cephfs总结及kubernetes+Cephfs的整合项目
云原生·容器·kubernetes
底层玩家老张18 小时前
数据库上K8s,运维为什么反而更累了?从StatefulSet到Operator的复盘
数据库·kubernetes·operator·数据库运维·架构选型
力江18 小时前
GitLab 私有化部署实战 —— 从 Omnibus 到 Docker 的踩坑之旅
docker·容器·gitlab
深念Y19 小时前
Docker 镜像体积从 110MB 降到 13MB 后端服务的瘦身
运维·docker·容器