ExternalName — CNAME alias to external DNS name.
1apiVersion: v12kind: Service3metadata:4 name: external-db5 namespace: production6spec:7 type: ExternalName8 externalName: mydb.rds.amazonaws.com9---10apiVersion: v111kind: Service12metadata:13 name: external-api14 namespace: production15spec:16 type: ExternalName17 externalName: api.external-service.com18---19# Application uses: postgresql://external-db:5432/mydb20# Resolves to CNAME: mydb.rds.amazonaws.com
1# Commands2kubectl get svc external-db3kubectl describe svc external-db45# DNS resolution6kubectl exec -it my-pod -- nslookup external-db.production.svc.cluster.local7kubectl exec -it my-pod -- nslookup external-db.production.svc.cluster.local | grep CNAME89# Test connectivity10kubectl exec -it my-pod -- curl http://external-api.production.svc.cluster.local/health1112# Switch external target without app changes13kubectl patch svc external-db -p '{"spec":{"externalName":"newdb.rds.amazonaws.com"}}'
Use cases:
Limitations: