k8s网络组件calico问题

今天在k8s集群上模拟cks考题时,无意间发现calico网络组件状态是RUNNING但是READY状态显示为0/1并未真正准备“初始化”操作,于是查询相关资料并进行处理,如下;

1、问题现象

calico-node-acq2f                          0/1     Running   119        31d
calico-node-pf2hs                          0/1     Running   45         31d

2、排查

查看pod的日志信息

kubectl describe pod calico-node-acq2f -n kube-system
...
  Warning  Unhealthy  19s   kubelet            Readiness probe failed: calico/node is not ready: BIRD is not ready: Error querying BIRD: unable to connect to BIRDv4 socket: dial unix /var/run/calico/bird.ctl: connect: connection refused
  Warning  Unhealthy  14s   kubelet            Readiness probe failed: 2021-12-24 08:56:37.477 [INFO][197] confd/health.go 180: Number of node(s) with BGP peering established = 0
calico/node is not ready: BIRD is not ready: BGP not established with 192.168.6.31
  Warning  Unhealthy  4s  kubelet  Readiness probe failed: 2021-12-24 08:56:47.414 [INFO][239] confd/health.go 180: Number of node(s) with BGP peering established = 0

可以看到pod和本机IP没有成功建立连接

3、处理方法

编辑calico的DaemonSet使pod能够自动与本机IP建立连接(添加环境变量:IP_AUTODETECTION_METHOD),如下:

kubectl edit ds calico-node -nkube-system
...
      - env:
        - name: IP_AUTODETECTION_METHOD
          value: interface=ens32 # 填写自己实际对应的网卡名称
...

保存后

calico-node-kdrnp                          1/1     Running   0          12s
calico-node-z7qbs                          1/1     Running   0          12s

参考链接:https://www.codenong.com/cs109711759/

你可能感兴趣的:(k8s,云原生,运维,网络,k8s,calico)