1、故障现象:
kubenetes安装calico发现其中一个处于Running,但READY列却显示不正常,状态如下图所示:
![在这里插入图片描述](https://img-blog.csdnimg.cn/20210619004041411.png
2、寻找原因
进入到出现故障 pod,查看router id值发现绑定地址异常,并非宿主机的IP地址

[root@master01 ~]# kubectl exec -ti calico-node-j4f5m -n kube-system -- bash
[root@k8s-master1 /]# cat /etc/calico/confd/config/bird.cfg

在这里插入图片描述
3、解决方法
(1)、calico.yaml 文件添加以下两行,网卡使用ifconfig查看宿主机的网卡名称,我的宿主机的网卡名称是 ens33

[root@master01 ~]# ifconfig
docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:7d:18:01:ae  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.31.73  netmask 255.255.255.0  broadcast 192.168.31.255
        inet6 fe80::c8f3:b547:a509:d990  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:d8:0c:67  txqueuelen 1000  (Ethernet)
        RX packets 4740537  bytes 1428558903 (1.3 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 4178151  bytes 627478129 (598.4 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

这里直接配置通配符 :value: “interface=ens.*”

[root@master01 ~]# vi calico.yaml
# Cluster type to identify the deployment type
- name: CLUSTER_TYPE
  value: "k8s,bgp"
#新增两行配置
- name: IP_AUTODETECTION_METHOD
  value: "interface=ens.*"
# Auto-detect the BGP IP address.
- name: IP
  value: "autodetect"
# Enable IPIP
- name: CALICO_IPV4POOL_IPIP
  value: "Always"

(2)、重新应用

[root@master01 ~]# rm -rf /var/lib/cni
[root@master01 ~]# kubectl apply -f calico.yaml
[root@master01 ~]# kubectl get pods -n kube-system
NAME                                      READY   STATUS    RESTARTS   AGE
calico-kube-controllers-97769f7c7-8jzg7   1/1     Running   0          72m
calico-node-qfwsp                         1/1     Running   0          104s
calico-node-qtn9z                         1/1     Running   0          2m3s
calico-node-xdswl                         1/1     Running   0          2m22s

4、问题解决

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐