2

I have to get the real ip from the request in my business.actually I got the 10.2.100.1 every time at my test environment. any way to do this ?

sope
  • 1,619
  • 5
  • 19
  • 37

3 Answers3

1

This is the same question as GCE + K8S - Accessing referral IP address and How to read client IP addresses from HTTP requests behind Kubernetes services?.

The answer, copied from them, is that this isn't yet possible in the released versions of Kubernetes.

Services go through kube_proxy, which answers the client connection and proxies through to the backend (your web server). The address that you'd see would be the IP of whichever kube-proxy the connection went through.

Work is being actively done on a solution that uses iptables as the proxy, which will cause your server to see the real client IP.

Community
  • 1
  • 1
Alex Robinson
  • 12,633
  • 2
  • 38
  • 55
0

Try to get that service IP which service is associated with that pods.

Animesh Kumar Paul
  • 2,241
  • 4
  • 26
  • 37
  • 1
    I mean if I deploy a web service in kubernetes cluster ,I need know about the source IP from client request in service pod . But I got the kube-proxy IP. It doesn't make any sense – sope Sep 24 '15 at 14:12
-1

One very roundabout way right now is to set up an HTTP liveness probe and watch the IP it originates from. Just be sure to also respond to it appropriately or it'll assume your pod is down.