Why do my pods see the load balancer IP instead of the client IP?
Your pods see the load balancer IP because the Hetzner Load Balancer opens its own connection to the node and puts its own address on it. To preserve the client IP behind a Hetzner Load Balancer, turn on PROXY protocol on both sides:
- On the Service, set the annotation
load-balancer.hetzner.cloud/uses-proxyprotocol: "true". - In the backend that receives the connection (your ingress controller or your application), turn on reading the PROXY protocol header.
Change both in the same step. If only one side has it, connections break.
externalTrafficPolicy: Local does not bring the client IP back. With the default Cluster, the node that receives a request can forward it to a pod on another node, and it then replaces the source address a second time. Local removes only that second replacement.
Follow Preserve the client source IP for the backend settings, how to verify the result and how to turn PROXY protocol off again. If your ingress controller is Traefik, you find the setting in Install Traefik for HTTP routing.
Related questions
