測試部署了一個service,包括2個pod,分別在node1和node2上。node
[root@k8s ~]# kubectl get svc NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE nginx-svc 10.254.216.26 <none> 80/TCP 43m
[root@k8s ~]# kubectl get pod NAME READY STATUS RESTARTS AGE busybox 1/1 Running 3 65d nginx-deployment-4087004473-d3tkv 1/1 Running 0 9m nginx-deployment-4087004473-gdm3q 1/1 Running 0 54m
在node1(或者node2)上curl 10.254.216.26(cluster ip),只有當負載到本地pod時正常,curl <本地pod ip和另外一個主機pod ip>是正常的。nginx
參考 https://stackoverflow.com/que... 添加路由後,docker
ip route add 10.254.0.0/16 dev flannel.1
主機間能夠通訊,可是本地pod不正常了。curl
刪除上述路由信息,添加路由以下路由解決。測試
ip route add 10.254.0.0/16 dev docker0