calico网络故障排查(calico/node is not ready: BIRD is not ready)
一、问题发现1.执行kubectl get pod -o wide -n calico-system,发现有一个节点的calico-node没有出入READY状态,如下:2.执行kubectl describe pod calico-node-5xskb -n calico-system,发现有如下报错:3.执行kubectl exec -ti calico-node-5xskb -n calic
一、问题发现
1.执行kubectl get pod -o wide -n calico-system,发现有一个节点的calico-node没有出入READY状态,如下:
2.执行kubectl describe pod calico-node-5xskb -n calico-system,发现有如下报错:
3.执行kubectl exec -ti calico-node-5xskb -n calico-system -- bash,进入calico-node,打开bird配置文件,发现router id为172.19.0.1,此IP是bride网桥地址,正常应该是ens33网卡地址:192.168.31.103,如下:
上面的ip是网桥IP,calico的BGP采用物理设备(网卡)作为虚拟路由器实现路由功能
4.在master执行calicoctl node status
到此,基本可以确定是k8s-3节点的calico的BGP网卡设备识别错误导致
二、解决过程
1.查看calico官网上关于此问题的解释,如下:
官网链接:https://docs.projectcalico.org/archive/v3.18/networking/ip-autodetection
By default, Calico uses the first-found method; the first valid IP address on the first interface (excluding local interfaces such as the docker bridge). However, you can change the default method to any of the following:
- Address used by the node to reach a particular IP or domain (can-reach)
- Regex to include matching interfaces (interface)
- Regex to exclude matching interfaces (skip-interface
大致意思是说:calico默认采用first-found方法,选择第一个接口的第一个有效IP地址(排除本地网桥接口),但是上面的情况,就是calico采用172.19.0.1网桥地址,这个比较疑惑
官网建议采用can-reach、interface、skip-inteface方式之一,通过修改 IP_AUTODETECTION_METHOD,让IP自动探测固定到某一个接口或者IP上,下面的方式采用正则表达式将接口限定在ens开头的网卡上:
kubectl set env daemonset.apps/calico-node -n calico-system IP_AUTODETECTION_METHOD=interface=ens.*
本文采用上述方式修改后并未起作用:
注:本在的k8s环境按照calico环境时采用的是calico Installation方式
后来按照官网https://docs.projectcalico.org/reference/installation/api#operator.tigera.io/v1.CalicoNetworkSpec链接说明,增加如下:
nodeAddressAutodetectionV4:
interface: ens.*
官网说明如下:
修改后的文件如下:
apiVersion: operator.tigera.io/v1
kind: Installation
metadata:
name: default
spec:
# Configures Calico networking.
registry: swr.cn-east-2.myhuaweicloud.com
imagePath: kuboard-dependency
calicoNetwork:
# Note: The ipPools section cannot be modified post-install.
ipPools:
- blockSize: 26
cidr: 10.100.0.1/16
encapsulation: VXLANCrossSubnet
natOutgoing: Enabled
nodeSelector: all()
nodeAddressAutodetectionV4:
interface: ens.*
2.重新执行:kubectl create -f calico-operator.yaml kubectl create -f calico-custom-resources.yaml 问题解决
重新执行calicoctl node status
calico-operator.yaml文件太大,未附上内容。
更多推荐
所有评论(0)