How to get the real ip in the request in the pod in kubernetes

9/24/2015

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
kubernetes

2 Answers

9/24/2015

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

-- Animesh Kumar Paul
Source: StackOverflow

9/24/2015

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.

-- Alex Robinson
Source: StackOverflow