在部署 Kubernates 集群时,CoreDNS 的Pod始终处于**"ContainerCreating"**状态,正如下所示:

# k get pod -n kube-system
NAME                                READY   STATUS              RESTARTS   AGE
coredns-546565776c-8rtm4            0/1     ContainerCreating   0          9m37s
coredns-546565776c-thnmx            0/1     ContainerCreating   0          9m37s

使用Describe来检查pod情况,发现有个报 failed to find plugin "bridge" in path [/opt/cni/bin]]错误:

Successfully assigned kube-system/coredns-546565776c-8rtm4 to worker-02
  Warning  FailedCreatePodSandBox  89s                    kubelet, worker-02  Failed to create pod sandbox: rpc error: code = Unknown desc = [failed to set up sandbox container "7caca4bf0d240fe8a2d5d3785a0996c93ff73209e7c68c806a66d9f3150d9bab" network for pod "coredns-546565776c-8rtm4": networkPlugin cni failed to set up pod "coredns-546565776c-8rtm4_kube-system" network: failed to delegate add: failed to find plugin "bridge" in path [/opt/cni/bin], failed to clean up sandbox container "7caca4bf0d240fe8a2d5d3785a0996c93ff73209e7c68c806a66d9f3150d9bab" network for pod "coredns-546565776c-8rtm4": networkPlugin cni failed to teardown pod "coredns-546565776c-8rtm4_kube-system" network: failed to find plugin "bridge" in path [/opt/cni/bin]]

集群部署的CNI插件是 Flannel参考

解决方案

既然是缺少 bridge 这个插件,那就把这个插件下载下来,于是进行以下操作:

CNI Plugins有许多插件,我部署的是arm64平台,所以我下载 arm64的插件:

# wget https://github.com/containernetworking/plugins/releases/download/v1.0.1/cni-plugins-linux-arm64-v1.0.1.tgz
# tar axvf ./cni-plugins-linux-arm64-v1.0.1.tgz  -C /opt/cni/bin/

确认一下是否已经存在bridge插件

# ls -l /opt/cni/bin/bridge
-rwxr-xr-x 1 root root 4221528  9月  8 03:49 /opt/cni/bin/bridge

片刻之后,CoreDNS的Pod状态已经是Running

# k get pod -n kube-system
NAME                                READY   STATUS              RESTARTS   AGE
coredns-546565776c-8rtm4            1/1     Running   0          28m
coredns-546565776c-thnmx            1/1     Running   0          28m

一条龙处理方法:

yum install kubernetes-cni.aarch64