Get the client IP address from a Kuberneter cluster
I am trying to get the IP address of the client in an app in the cluster. I only get the IP of the NodeBalancer, so I've been trying to set up headers correctly.
I have enabled use-forwarded-headers: "true" in the ingress controller configmap
That seemed to change the IP I get from the local cluster IP to the Linode server IP, but still not the actual client IP.
Then, it seems (from instructions I've found here: https://www.linode.com/community/questions/20620/how-can-i-use-proxy-protocol-with-linode-kubernetes-engine), that you also need to add an annotation to the ingress controller service:
I've installed the ingress controller with HELM, and I just can't seem to figure out how to set this annotation. I tried using the methods in the article above:
kubectl edit service name-of-my-index-controller-service
That just resulted in an http error (503 I think). This command opened the definition in an editor, and I edited the file, then did a kubectl apply -f file-name
I'm no expert in working with HELM or Kubernetes, so ANY help, pointers and hints are welcome. This issue is driving me nuts :)
This guide from Kong Docs has some information that I think might be helpful in your situation here.
I also found these guides that have useful information as well.
https://andrewmichaelsmith.com/2020/02/preserving-client-ip-in-kubernetes/ (This link in particular)
i got same problem as @MrTom did you find any solution? or else i have to leave linode. I tried every solution available in the internet but still i just get ip address of linode instance. not the actual client ip.
my setup is :
public_user -> linode_loadbalancer -> ingress-nginx-controller(managed by helm chart) -> ingress -> my-service ->deployments [on the same namespace I have also configure config map (managed by ingress)]
I have update ingress annotations with :
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
and I also have updated the config map with :
also i change the service >> specs to :
none of them work can any one help me how to preserve client ip address