Interview Prep/Kubernetes/Services, Ingress and DNS

How do you route traffic to an external database through a Kubernetes name?

IntermediateScenarioServices, Ingress and DNS
Answer

Situation read → Apps use db.prod.svc and you want to switch between an RDS endpoint and an in-cluster DB without code changes.

What I'd do →

  1. Create a Service of type: ExternalName with externalName: mydb.abc.ap-south-1.rds.amazonaws.com
  2. Apps keep using db.prod.svc.cluster.local
  3. For IPs, use a Service without selector plus a manual EndpointSlice
  4. Remember ExternalName does not work well with TLS SNI hostname checks
  5. Change only the Service to cut over

Why → The cluster DNS returns a CNAME, which decouples app configuration from the backend location.

Interview tip → Mention that ExternalName does no proxying and no health checks.

All Kubernetes questions Roadmap: Kubernetes networking, storage & scaling

More on Services, Ingress and DNS