Skip to main content
RunBook Academy

KubernetesXXXVIII · ServicesServices

ExternalName — the CNAME alias to an external service

Advanced⏱ ~14 minkubectl

What you'll learn

  • Explain how ExternalName creates a CNAME alias
  • Distinguish ExternalName from ClusterIP, NodePort, and LoadBalancer
  • Identify the use cases for ExternalName
  • Identify the failure modes of ExternalName

Prerequisites

Verified against Kubernetes 1.34.x · kubeadm 1.34.x · kubectl 1.34.x · etcd 3.6.x · CoreDNS 1.11.x · containerd 1.7.x / 2.x · 2026-08-16

Not yet marked complete on this device.

An ExternalName Service creates a CNAME alias to an external DNS name. The Service has no ClusterIP; the DNS resolver returns the CNAME. This lesson walks the mechanism, the use cases, and the operational discipline.

The ExternalName manifest

apiVersion: v1
kind: Service
metadata:
  name: external-db
  namespace: prod-app
spec:
  type: ExternalName
  externalName: db.example.com

The externalName field is the external DNS name. The DNS resolver inside the cluster returns the CNAME when clients query the Service’s name.

The DNS resolution

The DNS resolver inside the cluster is configured by the CNI plugin and the DNS service (CoreDNS). When a client queries external-db.prod-app.svc.cluster.local, the DNS resolver returns the CNAME db.example.com.

sequenceDiagram
    autonumber
    participant C as Pod
    participant DNS as CoreDNS
    participant E as External DNS
    C->>DNS: external-db.prod-app.svc.cluster.local
    DNS->>DNS: match Service ExternalName
    DNS-->>C: CNAME db.example.com
    C->>E: db.example.com
    E-->>C: 192.0.2.10
    C->>C: connect to 192.0.2.10:5432

The client makes two DNS queries: one for the Service’s name (returns the CNAME) and one for the external domain (returns the IP). The DNS resolver inside the cluster does not resolve the external IP; the client must do that.

The use cases

The ExternalName’s use cases:

  • External services: a service that lives outside the cluster (e.g., a managed database) is referenced by an ExternalName Service.
  • DNS-based service abstraction: the application uses the Service’s name; the Service’s implementation is external.
  • Migration from in-cluster to external: the Service is changed from ClusterIP to ExternalName to migrate the backend to an external service.
  • Multi-cluster service: the Service points to a service in another cluster.

The ExternalName is the right choice for services that live outside the cluster.

The Traffic

The traffic flow is different from the ClusterIP:

flowchart LR
    A[Pod] -->|DNS query: external-db| B[CoreDNS]
    B -->|CNAME db.example.com| A
    A -->|DNS query: db.example.com| C[External DNS]
    C -->|IP 192.0.2.10| A
    A -->|TCP 192.0.2.10:5432| D[External DB]

The Pod resolves the Service’s name to a CNAME, follows the CNAME to the external IP, and connects directly to the external service. The kube-proxy is not involved.

The failure modes

The ExternalName’s failure modes:

  • DNS misconfiguration: the CNAME points to a wrong external name. The fix is to verify the external name.
  • External service unreachable: the external service is down. The fix is to check the external service.
  • DNS resolver chain too long: the CNAME chain exceeds the resolver’s limit. The fix is to use a shorter CNAME chain.
  • NetworkPolicy blocks the external traffic: the NetworkPolicy allows traffic to the cluster’s Pods but not to the external IP. The fix is to update the NetworkPolicy.

The operational discipline

The ExternalName’s operational discipline:

  • Document the ExternalName’s external target. The cluster operator must understand the external service.
  • Audit the ExternalName usage. The cluster operator must enumerate every ExternalName Service.
  • Test the ExternalName in staging. The external service must be reachable from staging.
  • Monitor the external service’s health. The external service’s health is the responsibility of the external team.
  • Document the ExternalName’s design. The ExternalName is the cluster’s DNS abstraction; the documentation is the reference.

Quiz

Knowledge check · 4 questions

  1. Q1. What does an ExternalName Service create in the cluster's DNS?

  2. Q2. ExternalName Services route traffic through the kube-proxy on every node.

  3. Q3. An ExternalName Service external-db is configured to point to db.example.com. The Pod cannot connect to the external database. What is the diagnostic flow and the recovery?

    The cluster has a Service external-db in namespace prod-app. The Service is type ExternalName with externalName: db.example.com. The Pod cannot connect to the external database. The Pod resolves the Service's name to the CNAME, then cannot resolve db.example.com.

  4. Q4. Name two use cases for an ExternalName Service.

Passing score: 75%. Answers are checked in this browser.

Production discipline

  • ExternalName is a CNAME alias. The Service has no ClusterIP.
  • ExternalName bypasses the kube-proxy. The client connects directly to the external service.
  • Document the ExternalName’s external target. The cluster operator must understand the external service.
  • Audit the ExternalName usage. The cluster operator must enumerate every ExternalName Service.
  • Test the ExternalName in staging. The external service must be reachable from staging.
  • Monitor the external service’s health. The external service’s health is the responsibility of the external team.
  • Verify the NetworkPolicy. The NetworkPolicy must allow egress to the external IP.
  • Document the ExternalName’s design. The ExternalName is the cluster’s DNS abstraction; the documentation is the reference.