Loading

coredns 状态一直处于 containerCreating, 错误日志为 kubernetes failed to set bridge addr: “cni0“ already has an IP address different from

kubectl get pod -A
image

coredns状态为 containerCreating, 看下日志:

kubectl logs coredns-6d8c4cb4d-6b5k2 -n kube-system

Warning FailedCreatePodSandBox 22m kubelet Failed to create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container “54846981daca512b465b9f45cabfcf4925bc58be8f3e08a403c9f2b16380bf11” network for pod “coredns-6d8c4cb4d-6b5k2”: networkPlugin cni failed to set up pod “coredns-6d8c4cb4d-6b5k2_kube-system” network: failed to delegate add: failed to set bridge addr: “cni0” already has an IP address different from 10.96.0.1/24
Warning FailedCreatePodSandBox 22m kubelet Failed to create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container “af99fa1e894c368ee7b252d792829065ef31b2bb3bc71f90e2d7fa00259c7218” network for pod “coredns-6d8c4cb4d-6b5k2”: networkPlugin cni failed to set up pod “coredns-6d8c4cb4d-6b5k2_kube-system” network: failed to delegate add: failed to set bridge addr: “cni0” already has an IP address different from 10.96.0.1/24
Normal SandboxChanged 8m3s (x411 over 23m) kubelet Pod sandbox changed, it will be killed and re-created.
Warning FailedCreatePodSandBox 3m2s (x540 over 22m) kubelet (combined from similar events): Failed to create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container “922a94bed6b5fc4d4bc2015a97af9242f2c0c062380a7d42e6824518ee05bfbe” network for pod “coredns-6d8c4cb4d-6b5k2”: networkPlugin cni failed to set up pod “coredns-6d8c4cb4d-6b5k2_kube-system” network: failed to delegate add: failed to set bridge addr: “cni0” already has an IP address different from 10.244.0.1/24

自己初始化master的命令为:

kubeadm init --pod-network-cidr=10.244.0.0/16 --image-repository registry.aliyuncs.com/google_containers 

也就是pod 的网络范围为: 10.244.0.0/16
注意:
/etc/kubernetes/manifests/kube-controller-manager.yaml 中,也有以下参数设置pod的网络范围:

    - --cluster-cidr=10.244.0.0/16

在看下本地虚拟网卡cni0的的网络ip:
ifconfig
image

解决方法:
方法1: 修改 cni0 的 ip段:
使用 ip address 命令,具体使用可参考相关语法

方法2: 将这个错误的网卡删除掉,系统会自动重建。
下面我们删除错误的cni0,然后让它自己重建,操作过程如下:

ifconfig cni0 down
ip link delete cni0

结果:
image

转载自:kubernetes failed to set bridge addr: “cni0“ already has an IP address different from_面向未来的历史的博客-CSDN博客

posted @ 2022-07-16 21:06  拾月凄辰  阅读(2673)  评论(0编辑  收藏  举报