无法使用 ClusterIP 跨节点访问 nginx pod



我创建了nginx部署和nginx服务(ClusterIP(来访问nginx pod。但无法通过集群 IP 跨节点访问 pod,而不是调度 pod 的节点。

我也尝试寻找IPtable。但不要在那边进入 DNAT。

root@kdm-master-1:~# k get all -A -o wide |grep nginx
default       pod/nginx-6db489d4b7-pfkm9                 1/1     Running   0          3h16m   10.244.1.3   kdm-worker-1   <none>           <none>
default       service/nginx        ClusterIP   10.102.239.131   <none>        80/TCP                   3h20m   run=nginx
default       deployment.apps/nginx     1/1     1            1           3h32m   nginx        nginx                      run=nginx
default       replicaset.apps/nginx-6db489d4b7     1         1         1       3h32m   nginx        nginx                      pod-template-hash=6db489d4b7,run=nginx

IP 表:

root@kdm-master-1:~# iptables -L -t nat|grep nginx
KUBE-MARK-MASQ  tcp  -- !10.244.0.0/16        10.102.239.131       /* default/nginx:80-80 cluster IP */ tcp dpt:http
KUBE-SVC-OVTWZ4GROBJZO4C5  tcp  --  anywhere             10.102.239.131       /* default/nginx:80-80 cluster IP */ tcp dpt:http
# Warning: iptables-legacy tables present, use iptables-legacy to see them

请告知我该如何解决?

set net.ipv4.ip_forward=1/etc/sysctl.conf

run sysctl --system

这将解决问题,并且能够从任何节点访问 Pod。

最新更新