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 →
- Create a Service of
type: ExternalNamewithexternalName: mydb.abc.ap-south-1.rds.amazonaws.com - Apps keep using
db.prod.svc.cluster.local - For IPs, use a Service without selector plus a manual EndpointSlice
- Remember ExternalName does not work well with TLS SNI hostname checks
- 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.
More on Services, Ingress and DNS
A Service has no endpoints. How do you find out why?BeginnerWhen do you use ClusterIP, NodePort, LoadBalancer and ExternalName?BeginnerTraffic to a Service works from some pods but times out from others. How do you debug it?AdvancedYou want to expose three HTTP services under one hostname with different paths. How?Intermediateingress-nginx returns 404 for a new host. What do you check?Intermediateingress-nginx returns 502 or 503 intermittently. What are the likely reasons?Intermediate