Interview Prep/Kubernetes/Services, Ingress and DNS

Clients see the real source IP as a node IP, not the client IP. How do you preserve it?

IntermediateScenarioServices, Ingress and DNS
Answer

Situation read → An allowlist in the app breaks because every request appears to come from inside the cluster.

What I'd do →

  1. For a LoadBalancer or NodePort Service set externalTrafficPolicy: Local
  2. Or use NLB with proxy protocol and configure the app or ingress to read it
  3. For ALB read X-Forwarded-For and trust only the LB ranges
  4. Make sure the pods are spread so every LB target node has a pod
  5. Verify with an echo service that prints headers

Why → Cluster policy SNATs traffic to balance across nodes, which hides the original address.

Interview tip → Mention the trade-off: Local can create uneven load.

All Kubernetes questions Roadmap: Kubernetes networking, storage & scaling

More on Services, Ingress and DNS