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:
service.beta.kubernetes.io/linode-loadbalancer-proxy-protocol: v2

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 :)

1 Reply

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)

https://docs.alertlogic.com/configure/inline-waf/preserve-IP-address.htm

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct