安装kube-flannel网络插件后,发现新建pod一直在创建中,一开始还以为是镜像拉不下来, 查看日志才发现是缺少bridge插件
root@k8s-master01:~# kubectl get pod -owide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
nginx-f6dc544c7-rwbrr 0/1 ContainerCreating 0 22s <none> k8s-master01 <none> <none>
root@k8s-master01:~# kubectl describe pod nginx-f6dc544c7-rwbrr
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 41s default-scheduler Successfully assigned default/nginx-f6dc544c7-rwbrr to k8s-master01
Warning FailedCreatePodSandBox 41s kubelet Failed to create pod sandbox: rpc error: code = Unknown desc = failed to setup network for sandbox "2df3a0ebe51e858f83bddb4d6c2d480fe0f149dab89e823e9fc365dae227d9c0": plugin type="flannel" failed (add): failed to delegate add: failed to find plugin "bridge" in path [/opt/cni/bin]
Warning FailedCreatePodSandBox 41s kubelet Failed to create pod sandbox: rpc error: code = Unknown desc = failed to setup network for sandbox "845a3aac0aac9b02e7b8f92778219ca4cdb01cf3c665c4ca48718dd5325e73a3": plugin type="flannel" failed (add): failed to delegate add: failed to find plugin "bridge" in path [/opt/cni/bin]
Warning FailedCreatePodSandBox 40s kubelet Failed to create pod sandbox: rpc error: code = Unknown desc = failed to setup network for sandbox "c725754b4acc47816bfc9d6f8486f668a50afd05015302828ee5f5476ff51202": plugin type="flannel" failed (add): failed to delegate add: failed to find plugin "bridge" in path [/opt/cni/bin]
Normal SandboxChanged 2s (x6 over 41s) kubelet Pod sandbox changed, it will be killed and re-created.
Warning FailedCreatePodSandBox 2s (x4 over 39s) kubelet Failed to create pod sandbox: rpc error: code = Unknown desc = failed to reserve sandbox name "nginx-f6dc544c7-rwbrr_default_dcce1250-19ba-4115-b29f-481ce97d6e28_1": name "nginx-f6dc544c7-rwbrr_default_dcce1250-19ba-4115-b29f-481ce97d6e28_1" is reserved for "845a3aac0aac9b02e7b8f92778219ca4cdb01cf3c665c4ca48718dd5325e73a3"
安装缺少的bridge插件 https://github.com/containernetworking/plugins/releases
wget https://github.com/containernetworking/plugins/releases/download/v1.3.0/cni-plugins-linux-amd64-v1.3.0.tgz
tar xf cni-plugins-linux-amd64-v1.3.0.tgz -C /opt/cni/bin/
确定下bridge是否解压到指定路径
root@k8s-master01:~# ls -l /opt/cni/bin/bridge
-rwxr-xr-x 1 root root 4531309 May 10 2023 /opt/cni/bin/bridge
等会pod就running (无需重启任何服务)
root@k8s-master01:~# kubectl get pod
NAME READY STATUS RESTARTS AGE
nginx-f6dc544c7-rwbrr 1/1 Running 0 10m