網(wǎng)絡(luò)故障:master無(wú)法ping通node上的 pod ip娱节,node也無(wú)法ping通master上的pod ip.
環(huán)境:
基于kubeadm部署的k8s 1.19, 1個(gè)master 2個(gè)node
master 網(wǎng)段: 172.17.0.0
node01 網(wǎng)絡(luò): 172.17.1.0
node02 網(wǎng)段: 172.17.2.0
網(wǎng)絡(luò)插件:flannel
[root@bj-pt-uat-k8s-master01 ~]# kubectl get pod -n kube-system
NAME READY STATUS RESTARTS AGE
coredns-6d56c8448f-rmjnx 1/1 Running 0 51d
coredns-6d56c8448f-xdx62 1/1 Running 0 51d
etcd-bj-pt-uat-k8s-master01 1/1 Running 0 51d
kube-apiserver-bj-pt-uat-k8s-master01 1/1 Running 0 54d
kube-controller-manager-bj-pt-uat-k8s-master01 1/1 Running 2 52d
kube-flannel-ds-7z4h9 1/1 Running 0 17h
kube-flannel-ds-n6pxb 1/1 Running 0 54d
kube-flannel-ds-xd2tp 1/1 Running 0 54d
kube-proxy-rckxq 1/1 Running 0 51d
kube-proxy-rp7tp 1/1 Running 0 51d
kube-proxy-x8ngn 1/1 Running 0 51d
kube-scheduler-bj-pt-uat-k8s-master01 1/1 Running 2 52d
發(fā)現(xiàn)的問(wèn)題:
- master01上有去這三個(gè)網(wǎng)絡(luò)的路由:
[root@bj-pt-uat-k8s-master01 ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.21.64.1 0.0.0.0 UG 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0
172.17.0.0 0.0.0.0 255.255.255.0 U 0 0 0 cni0
172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 docker0
172.17.1.0 172.17.1.0 255.255.255.0 UG 0 0 0 flannel.1
172.17.2.0 172.17.2.0 255.255.255.0 UG 0 0 0 flannel.1
172.21.64.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
- node上卻沒(méi)有去 master(172.17.0.0)的路由
[root@bj-pt-uat-k8s-node02 ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.21.64.1 0.0.0.0 UG 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0
172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 docker0
172.17.1.0 172.17.1.0 255.255.255.0 UG 0 0 0 flannel.1
172.17.2.0 0.0.0.0 255.255.255.0 U 0 0 0 cni0
172.21.64.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
正常的網(wǎng)絡(luò)通訊肯定都要一來(lái)一回辫红,回去路由沒(méi)有肯定就代表不同。
所以我首先想到的就是給node上加一條回去的路由
- 嘗試解決:
參考master上的路由走向田盈,我得知,node01上如下加
目標(biāo)為172.17.0.0 掩碼為255.255.255.0 網(wǎng)關(guān)為 172.17.0.0 的一條路由規(guī)則缴阎,如下面的命令
route add -net 172.17.0.0 netmask 255.255.255.0 gw 172.17.0.0
然而我增加是卻報(bào)錯(cuò):
[root@bj-pt-uat-k8s-node01 ~]# route add -net 172.17.0.0 netmask 255.255.255.0 gw 172.17.0.0
SIOCADDRT: Network is unreachable
待完善