本文最后更新于134 天前,其中的信息可能已经过时,如有错误请发送邮件到big_fw@foxmail.com
calico 地址池冲突问题
发生原因:
丰都环境某一个节点提示:failed to create pod sandbox
, 报错提示:Calico CNl panicked during ADD: runtime error: invalid memory address or nil pointer dereference。
问题搜索:
Calico CNI panicked during add IP · Issue #5779 · projectcalico/calico · GitHub
根据GitHub提示,需要:
- remove the cidr configuration for k8s node
- restart calico and create the pod
但是生产环境没有经验风险巨大,方案舍弃。
于是决定升级calico,升级以后报错
(combined from similar events): Failed to create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "333d675935c6ff730ce241c0a33dc83e5e897341a82a5cf557f9d350bed69a86" network for pod "ui-oas-58d46fdd94-77wzb": networkPlugin cni failed to set up pod "ui-oas-58d46fdd94-77wzb_ptest" network: error adding host side routes for interface: caliefdccd95d3d, error: route (Ifindex: 9709, Dst: 10.43.166.169/32, Scope: link) already exists for an interface other than 'caliefdccd95d3d': route (Ifindex: 1214, Dst: 10.43.166.169/32, Scope: link, Iface: calib3187871ec0)
calico的地址池已经把IP分配出去,但是地址池中并没有记录,新创建pod的时候依旧会从已分配出去的IP中随机分配,就会导致一直夯住。
#查看节点的CIDR
kubectl get node nodexxxx -o yaml
spec:
podCIDR: 10.92.3.0/24
podCIDRs:
- 10.92.3.0/24
#查看已分配的IP地址列表:
calicoctl ipam show --show-blocks
#查看未分配的IP地址列表:
calicoctl pool show
#需要安装calicoctl
curl -O -L "https://github.com/projectcalico/calicoctl/releases/download/v3.20.1/calicoctl" && chmod +x calicoctl && sudo mv calicoctl /usr/local/bin/
解决方法:
一个是切换cidr,kubeproxy,需要设置为不可调度并且驱逐节点pod;
Migrate from one IP pool to another | Calico Documentation (tigera.io)
一个是重启节点。
最后决定停机重启节点.
通过calicoctl命令可发现:
calicoctl.v3.21.6 ipam check --allow-version-mismatch --show-problem-ips
最后重启了一下CoreDNS的pod,problems变为0,集群恢复正常