πŸ“šBook Signing at KubeCon EU 2026Meet us at Booking.com HQ (Mon 18:30-21:00) & vCluster booth #521 (Tue 24 Mar, 12:30-1:30pm) β€” free book giveaway!RSVP Booking.com Event
Networking intermediate ⏱ 20 minutes K8s 1.28+

ExternalDNS Automation Kubernetes

Automate DNS record management with ExternalDNS on Kubernetes. Route53, CloudDNS, and Azure DNS integration for Ingress, Service, and Gateway resources.

By Luca Berton β€’ β€’ πŸ“– 5 min read

πŸ’‘ Quick Answer: Deploy ExternalDNS as a Deployment with permissions to manage DNS records. Annotate Ingress/Service/Gateway resources with external-dns.alpha.kubernetes.io/hostname β€” ExternalDNS automatically creates and updates A/CNAME records in your DNS provider.

The Problem

Every time you create an Ingress or LoadBalancer Service, you manually create DNS records. When the load balancer IP changes, you update DNS manually. ExternalDNS automates this β€” it watches Kubernetes resources and synchronizes DNS records automatically.

The Solution

Deploy ExternalDNS (Route53)

apiVersion: apps/v1
kind: Deployment
metadata:
  name: external-dns
  namespace: external-dns
spec:
  replicas: 1
  template:
    spec:
      serviceAccountName: external-dns
      containers:
        - name: external-dns
          image: registry.k8s.io/external-dns/external-dns:v0.15.0
          args:
            - --source=ingress
            - --source=service
            - --source=gateway-httproute
            - --provider=aws
            - --aws-zone-type=public
            - --registry=txt
            - --txt-owner-id=my-cluster
            - --domain-filter=example.com
            - --policy=upsert-only

Annotated Ingress

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: web-app
  annotations:
    external-dns.alpha.kubernetes.io/hostname: app.example.com
    external-dns.alpha.kubernetes.io/ttl: "300"
spec:
  rules:
    - host: app.example.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: web-app
                port:
                  number: 80

ExternalDNS creates: app.example.com β†’ A β†’ <load-balancer-ip>

Gateway API Integration

apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: web-route
  annotations:
    external-dns.alpha.kubernetes.io/hostname: web.example.com
spec:
  parentRefs:
    - name: main-gateway
  hostnames:
    - web.example.com
  rules:
    - matches:
        - path:
            type: PathPrefix
            value: /
      backendRefs:
        - name: web-service
          port: 80
graph LR
    ING[Ingress / Service / Gateway] -->|Watch| EDNS[ExternalDNS]
    EDNS -->|Create/Update records| DNS[Route53 / CloudDNS / Azure DNS]
    DNS --> USER[Users resolve<br/>app.example.com]

Common Issues

DNS records not created: Check ExternalDNS logs: kubectl logs -n external-dns deploy/external-dns. Common: IAM permissions missing, domain filter doesn’t match.

Old DNS records not cleaned up: Use --policy=sync instead of upsert-only for automatic cleanup. Caution: sync deletes records not managed by ExternalDNS.

Best Practices

  • upsert-only policy for safety β€” creates and updates but never deletes
  • domain-filter β€” restrict to your domains only
  • TXT record registry β€” prevents conflicts between multiple clusters
  • RBAC per namespace β€” restrict which namespaces can create DNS records
  • TTL 300s β€” good balance between propagation speed and DNS caching

Key Takeaways

  • ExternalDNS automates DNS record management from Kubernetes resources
  • Supports Ingress, Service, and Gateway API as sources
  • Works with Route53, CloudDNS, Azure DNS, Cloudflare, and 30+ providers
  • TXT record registry prevents conflicts between multiple clusters
  • upsert-only policy is safest β€” never accidentally deletes DNS records
#external-dns #dns #automation #route53
Luca Berton
Written by Luca Berton

Principal Solutions Architect specializing in Kubernetes, AI/GPU infrastructure, and cloud-native platforms. Author of Kubernetes Recipes and creator of CopyPasteLearn courses.

Kubernetes Recipes book cover

Want More Kubernetes Recipes?

This recipe is from Kubernetes Recipes, our 750-page practical guide with hundreds of production-ready patterns.

Luca Berton Ansible Pilot Ansible by Example Open Empower K8s Recipes Terraform Pilot CopyPasteLearn ProteinLens