Interview Prep/Kubernetes/Services, Ingress and DNS

Why does a pod's IP change and how do apps cope?

BeginnerScenarioServices, Ingress and DNS
Answer

Situation read → A developer hard-coded a pod IP in config.

What I'd do →

  1. Explain pods are ephemeral and get a new IP on recreation
  2. Use a Service DNS name instead
  3. For StatefulSets use the stable pod DNS name from the headless Service
  4. Check with kubectl get pods -o wide before and after deleting a pod

Why → Services provide a stable virtual IP and name over a changing set of pod IPs.

Interview tip → Short answer: "never address pods directly".

All Kubernetes questions Roadmap: Kubernetes networking, storage & scaling

More on Services, Ingress and DNS