An ExternalName service creates a DNS alias inside Kubernetes for an existing DNS name. Set the Service type to ExternalName and provide the destination in externalName. This is useful when pods should use a stable Kubernetes service name while the actual service remains internal or external to the cluster. section 11.4.3
Create an alias for an external API
The following Service makes time-api resolve to worldtimeapi.org: apiVersion: v1 kind: Service metadata: name: time-api spec: type: ExternalName externalName: worldtimeapi.org A pod in the same namespace can call http://time-api/api/timezone/CET. A pod elsewhere can use time-api.<namespace>.svc.cluster.local. section 11.4.3
ExternalName services differ from ordinary service types in several important ways:
- They create a DNS CNAME record rather than routing traffic through a cluster IP. section 11.4.3
- They do not require Endpoints or EndpointSlice objects. section 11.4.3
- They have no cluster IP; DNS resolution points the Kubernetes service name to the configured external name. section 11.4.3
Listing 11.8 An ExternalName-type service
apiVersion: v1 kind: Service metadata: name: time-api spec: type: ExternalName #1 externalName: worldtimeapi.org #2
Browse the complete minimal manifest for an ExternalName service. section 11.4.3
