Search code examples
kubernetesipkube-proxy

k8s Pod 1 get wrong pod 2's ip address


I install the k8s master with kubernetes binaries and the cluster works well.

But I face one strange problem.

Firstly, I run command python -m SimpleHTTPServer 9999 in pod2.

And then I make a request in pod1 curl http://<pod2 ip>:9999

The result in pod2 shows like

Serving HTTP on 0.0.0.0 port 9999 ...
10.244.0.1 - - [01/Apr/2021 14:40:34] "GET / HTTP/1.1" 200 -

However, the actual ip of pod1 is 10.244.0.47.

And according to what I found, 10.244.0.1 is the ip address of cni0.

I don't know what caused this probelm.

Could Any one give me a hand?


Solution

  • Finally I found what caused this result.

    The container I'm using is docker, which will default create iptable rules. And as a result, the traffic from docker will be changed and then snat will be done on the ip.

    Adding "iptables": false to /etc/docker/daemon.json will solve this problem.