Interview Prep/Kubernetes/Services, DNS, Ingress and NetworkPolicy

Traffic to a new Service of `type: ExternalName` pointing to an RDS hostname fails with "connection refused" on the expected port.

IntermediateTroubleshootingServices, DNS, Ingress and NetworkPolicy
Answer

Likely causes → ExternalName only creates a DNS CNAME. It does no port mapping and no proxying, so the ports in the Service are ignored; the client must use the real port. HTTP clients also send the Service name as Host, which some backends reject.

Diagnose →

kubectl get svc db -o jsonpath='{.spec.externalName}{"\n"}'
kubectl run dns --rm -it --image=busybox:1.36 --restart=Never -- nslookup db.data.svc.cluster.local

Fix → Connect to db.data.svc.cluster.local:5432 (the real RDS port). If you need port remapping, use a selector-less Service with a manual EndpointSlice pointing at IPs (not ideal for RDS whose IPs change).

Prevent → Use ExternalName only as a DNS alias, and document the real port.

All Kubernetes questions Roadmap: Kubernetes networking, storage & scaling

More on Services, DNS, Ingress and NetworkPolicy