此问题解决花费了两天时间,上网找了不少资料,仍没有解决问题,最后是看flannel的官方资料时找到了问题答案。遇到问题查官方资料是多么重要
环境
vagrant + VM BOX 虚拟环境
1主 + 2 节点
CentOS 7.8.2003
k8s 1.26
flannel 0.22.0
问题现象:
节点能 ping 通本节点的 pod ,同一节点的 pod 能相互 ping 通
不同节点之间的 pod 无法 ping 通,包括 节点 ping pod
问题解决过程:
查看 路由 信息
[vagrant@k8s-master ~]$ route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface default gateway 0.0.0.0 UG 100 0 0 eth0 10.0.2.0 0.0.0.0 255.255.255.0 U 100 0 0 eth0 10.244.0.0 0.0.0.0 255.255.255.0 U 0 0 0 cni0 10.244.1.0 10.244.1.0 255.255.255.0 UG 0 0 0 flannel.1 10.244.2.0 10.244.2.0 255.255.255.0 UG 0 0 0 flannel.1 192.168.111.0 0.0.0.0 255.255.255.0 U 101 0 0 eth1
[vagrant@k8s-work01 ~]$ route Destination Gateway Genmask Flags Metric Ref Use Iface default gateway 0.0.0.0 UG 100 0 0 eth0 10.0.2.0 0.0.0.0 255.255.255.0 U 100 0 0 eth0 10.244.0.0 10.244.0.0 255.255.255.0 UG 0 0 0 flannel.1 10.244.1.0 0.0.0.0 255.255.255.0 U 0 0 0 cni0 10.244.2.0 10.244.2.0 255.255.255.0 UG 0 0 0 flannel.1 192.168.111.0 0.0.0.0 255.255.255.0 U 101 0 0 eth1
[vagrant@k8s-work02 ~]$ route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface default gateway 0.0.0.0 UG 100 0 0 eth0 10.0.2.0 0.0.0.0 255.255.255.0 U 100 0 0 eth0 10.244.0.0 10.244.0.0 255.255.255.0 UG 0