Support Library
Kubernetes DNS and ExternalDNS
Kubernetes has two very different kinds of DNS: CoreDNS, which answers names inside the cluster, and ExternalDNS, which writes public records at your DNS provider. Most confusing failures come from mixing them up. This guide separates the two and shows how to troubleshoot each.
The short answer
CoreDNS resolves names for pods, such as api.shop.svc.cluster.local, and forwards everything else to an upstream resolver. Its common problems are search suffixes, the ndots:5 default and upstream forwarding. ExternalDNS watches Services, Ingresses and Gateway routes and creates matching records at a public provider, such as shop.example.com. Its common problems are filters, credentials, and the TXT ownership records it uses to decide which records it may change or delete. cert-manager is a third, separate writer: it creates temporary _acme-challenge TXT records for DNS-01 certificate validation.
Inside the cluster: CoreDNS
Every pod gets a /etc/resolv.conf like this (the namespace and service address vary):
nameserver 192.0.2.10
search shop.svc.cluster.local svc.cluster.local cluster.local
options ndots:5- api from a pod in the shop namespace becomes api.shop.svc.cluster.local through the search list.
- ndots:5 means any name with fewer than five dots is tried with every search suffix first. A lookup for api.example.com becomes three or more extra queries that each return NXDOMAIN before the real one, which adds latency and load.
- Names that are not cluster names are forwarded to the upstream in the Corefile, usually the node's own resolver.
Fixes: write external names with a trailing dot (api.example.com.) in configuration, or lower ndots for a pod with dnsConfig. See FQDNs, relative names and trailing dots for how search suffixes work.
| Command | What it shows |
|---|---|
| kubectl apply -f https://k8s.io/examples/admin/dns/dnsutils.yaml | Starts the test pod from the Kubernetes documentation |
| kubectl exec -i -t dnsutils -- nslookup kubernetes.default | Cluster DNS works at all |
| kubectl exec -i -t dnsutils -- cat /etc/resolv.conf | The search list and ndots the pod really has |
| kubectl exec -i -t dnsutils -- dig api.example.com. | Upstream forwarding works for an external name |
| kubectl -n kube-system logs -l k8s-app=kube-dns | CoreDNS errors, such as upstream timeouts |
| kubectl -n kube-system get configmap coredns -o yaml | The Corefile, including forward and any stub domains |
Public records: ExternalDNS
ExternalDNS reads hostnames from your Kubernetes objects and keeps matching records at the provider. A Service asks for a name with an annotation:
apiVersion: v1
kind: Service
metadata:
name: shop
annotations:
external-dns.alpha.kubernetes.io/hostname: shop.example.com
spec:
type: LoadBalancer
ports:
- port: 443
selector:
app: shopThe important flags on the ExternalDNS deployment:
| Flag | Why it matters |
|---|---|
| --source=service --source=ingress | Which objects it reads hostnames from |
| --domain-filter=example.com | Only touches zones under this domain. Always set it. |
| --policy=upsert-only | Creates and updates but never deletes. sync also deletes records whose objects are gone. |
| --registry=txt --txt-owner-id=prod-eu-1 | Writes TXT ownership records and only changes records marked with this cluster's ID |
| --dry-run | Logs the changes it would make without making them |
Ownership records are TXT records next to each managed record, holding text such as heritage=external-dns,external-dns/owner=prod-eu-1. ExternalDNS will not modify or delete a record without a matching ownership record, which protects hand-made records and other clusters' records. Give every cluster its own owner ID, never reuse one, and do not change it on a running cluster, or ExternalDNS stops managing (and stops cleaning up) its own records.
Credentials and safe deletion
- Scope provider credentials to the zones ExternalDNS manages, ideally through workload identity (IAM roles for service accounts on EKS, Workload Identity on GKE and AKS) rather than static keys in a Secret.
- Start with upsert-only and move to sync once you trust the filters and owner IDs.
- Give Kubernetes its own subdomain where you can, such as k8s.example.com delegated to a separate zone (see DNS zones and delegation), so a misconfiguration cannot touch your apex, MX or verification records.
- Exclude its names from Terraform or DNSControl (for example with DNSControl's IGNORE), or the two will keep undoing each other. See DNS drift.
- When a cluster is retired, delete its Services and Ingresses while ExternalDNS is still running in sync mode, or remove its records by hand. Leftover records pointing at released load balancer addresses are dangling records.
Troubleshooting ExternalDNS
| Symptom | Check |
|---|---|
| No record is created | kubectl logs deploy/external-dns for "skipping" or filter messages; the annotation spelling; the source type; whether the Service has an external address yet |
| Record exists but is never updated | The ownership TXT record: dig +short TXT on the record's ownership name, and whether its owner ID matches --txt-owner-id |
| Access denied errors in the log | The provider credentials and the zones they are scoped to |
| Changes are slow | The --interval setting and provider API rate limits |
| A record keeps flipping between two values | Two clusters, or ExternalDNS and another tool, writing the same name |
Check the public result from outside the cluster against the zone's authoritative servers.
| Command | What it confirms |
|---|---|
| dig +norecurse @ns1.example.com shop.example.com | The record ExternalDNS published, as one authoritative server answers it; repeat for each nameserver |
Certificates: cert-manager and DNS-01
cert-manager can prove control of a name to a certificate authority such as Let's Encrypt by creating a TXT record at _acme-challenge.shop.example.com, waiting for it to be visible, and removing it afterwards. This is separate from ExternalDNS: it uses its own issuer configuration and credentials, and it needs write access to that TXT name only. A common pattern is to point _acme-challenge names with a CNAME at a small zone used only for validation, so cert-manager's credentials cannot change anything else. cert-manager does not follow such CNAMEs by default: set cnameStrategy: Follow on the issuer's DNS-01 solver, or validation writes to the wrong zone and fails. Check the zone's CAA records allow the certificate authority you use.
How DNS Panopticon helps
DNS Panopticon cannot see inside a cluster. It sees what ExternalDNS publishes: Domain Visualizer and the DNS Propagation Checker show the public records for a name, and the Attack Surface card in Security Posture (on the Advanced plan) flags CNAMEs that point at services that no longer exist, which is how leftover records from retired clusters often show up.
FAQ
Why do my pods make so many DNS queries for external names?
Because of ndots:5. Any name with fewer than five dots is tried with each search suffix first. Use fully qualified names with a trailing dot, or lower ndots in the pod's dnsConfig.
Will ExternalDNS delete my hand-made records?
Not if they have no ownership TXT record for its owner ID. With the sync policy it deletes records it owns once their Kubernetes objects are gone.
Can two clusters share one zone?
Yes, if each has its own txt-owner-id and they do not claim the same hostnames.
Does ExternalDNS handle certificates?
No. Certificates are usually issued by cert-manager, which writes its own temporary _acme-challenge TXT records for DNS-01 validation.