calico状态一直处于CrashLoopBackOff并且报错no valid IPv4 addresses found on the host interfaces
calico pod一致处于CrashLoopBackOff
报错内容如下:
[root@k8s-20-49 ~]# kubectl logs -f calico-node-bwqz4 -n kube-system
2021-05-28 06:05:29.621 [INFO][8] startup.go 256: Early log level set to info
2021-05-28 06:05:29.621 [INFO][8] startup.go 272: Using NODENAME environment for node name
2021-05-28 06:05:29.621 [INFO][8] startup.go 284: Determined node name: k8s-20-53
2021-05-28 06:05:29.624 [INFO][8] k8s.go 228: Using Calico IPAM
2021-05-28 06:05:29.624 [INFO][8] startup.go 316: Checking datastore connection
2021-05-28 06:05:29.642 [INFO][8] startup.go 340: Datastore connection verified
2021-05-28 06:05:29.642 [INFO][8] startup.go 95: Datastore is ready
2021-05-28 06:05:29.656 [INFO][8] startup.go 382: Initialize BGP data
2021-05-28 06:05:29.657 [WARNING][8] startup.go 594: Unable to auto-detect an IPv4 address using interface regexes [eth.*|en.*|em.*]: no valid IPv4 addresses found on the host interfaces
2021-05-28 06:05:29.657 [WARNING][8] startup.go 404: Couldn't autodetect an IPv4 address. If auto-detecting, choose a different autodetection method. Otherwise provide an explicit address.
2021-05-28 06:05:29.657 [INFO][8] startup.go 210: Clearing out-of-date IPv4 address from this node IP=""
2021-05-28 06:05:29.668 [WARNING][8] startup.go 1057: Terminating
Calico node failed to start
很重要的一行提示2021-05-28 06:05:29.657 [WARNING][8] startup.go 594: Unable to auto-detect an IPv4 address using interface regexes [eth.*|en.*|em.*]: no valid IPv4 addresses found on the host interfaces
,他说在eth.|en.|em.*网卡中没有找到有效的ipv4地址,我们的k8s每个节点都使用bound做得网卡绑定,因此在他提供的网卡名称里面没有找到有效的地址,所有报错
解决方法:
只需要在calico配置文件中增加bond网卡名称即可,在yaml的53行
[root@k8s-20-49 ~]# kubectl edit daemonsets calico-node -n kube-system
- name: IP_AUTODETECTION_METHOD
value: interface=eth.*|en.*|em.*|bo.*
改完保存后,无需做任何操作,稍后就可以生效