I need to get client IP in Kubernetes, but I can only get the Flannel internal IP 10.244.X.1
(in nginx via $remote_addr
, $http_x_forwarded_for
is always -
).
The Network topo is:
client browser -> k8s cluster node ip -> k8s service (A) -> the pod (which desire the client ip) -> other services
I have tried externalTrafficPolicy
in A
, doesn't work. Is it only work on cloud provider, or behind a LB? [1]
I also tried ingress-nginx [2], get the same result.
My Environment:
Kernel Version: 3.10.0-1062.4.1.el7.x86_64
OS Image: CentOS Linux 7 (Core)
Operating System: linux
Architecture: amd64
Container Runtime Version: docker://18.6.2
Kubelet Version: v1.16.2
Kube-Proxy Version: v1.16.2
Network Add-on: Flannel
I have read some similar questions [3] [4] [5] , looks answers are imply to cloud provider or LB.