liveBook · Manning

Externalname service type

As explained in Kubernetes in Action, Second Edition

An ExternalName service is a Kubernetes Service whose DNS name is an alias for an external DNS name specified by its externalName field.

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

How Kubernetes in Action, Second Edition covers it

How deep it goes
Explains the manifest, DNS behavior, pod access, and absence of endpoints or cluster IPs.
Examples
Uses a time-api Service aliasing worldtimeapi.org, with curl access and nslookup output.
What it assumes
Assumes basic Service and DNS familiarity while contrasting ExternalName with ClusterIP behavior.
What you can do after
Operate/configure an ExternalName Service and connect to its target through Kubernetes DNS.
How it connects
Connects Service objects with DNS CNAME records, cluster DNS, Endpoints, EndpointSlice objects, and headless services.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Kubernetes in Action, Second Edition. The section links point to the parts of the book it draws on.