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,还是需要下载的。

相关推荐
bloglin999993 小时前
启动容器报错ls: cannot access ‘/docker-entrypoint-initdb.d/‘: Operation not permitted
docker·容器·eureka
songjxin3 小时前
离线部署kubernetes v1.34.3
云原生·容器·kubernetes
yBmZlQzJ4 小时前
免费内网穿透-端口转发配置介绍
运维·经验分享·docker·容器·1024程序员节
JH30734 小时前
docker 新手入门:10分钟搞定基础使用
运维·docker·容器
wuxia21185 小时前
minikube的安装
kubernetes·云计算
天河归来6 小时前
在本地windows电脑使用Docker搭建xinference环境
docker·语言模型·容器
算力魔方AIPC7 小时前
使用 Docker 一键部署 PaddleOCR-VL: 新手保姆级教程
运维·docker·容器
熊出没7 小时前
Kubernetes 实操命令大全
云原生·容器·kubernetes
Ghost Face...8 小时前
Docker实战:从安装到多容器编排指南
运维·docker·容器
闲人编程8 小时前
健康检查与就绪探针
kubernetes·web·状态机·健康检查·codecapsule·存活探针·启动探针