一、故障現象:
kubenetes安裝calico發現其中一個處於Running,但READY列卻顯示不正常,狀態以下圖所示:
二、尋找緣由
進入到出現故障 pod,查看router id值發現綁定地址異常,並不是宿主機的IP地址node
[root@master01 ~]# kubectl exec -ti calico-node-j4f5m -n kube-system -- bash [root@k8s-master1 /]# cat /etc/calico/confd/config/bird.cfg
三、解決方法
(1)、calico.yaml 文件添加如下兩行,網卡使用ifconfig查看宿主機的網卡名稱,個人宿主機的網卡名稱是 ens33docker
[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.*"bash
[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)、從新應用markdown
[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
四、問題解決app