Symptoms
- Apps across many namespaces fail at the same time:
no such host,Temporary failure in name resolution,i/o timeoutto10.0.0.10:53, orSERVFAILfor internal or private endpoint names. - CoreDNS pods are in
CrashLoopBackOff, or running but answering only some zones. - Someone recently changed
coredns-custominkube-systemto add a forwarder, stub domain,hostsentry or rewrite rule.
AKS doesn't let you edit the main Corefile. It imports keys from coredns-custom: keys ending in .server become extra server blocks, and keys ending in .override are inserted into the default .:53 block. One bad key can break resolution for the whole cluster.
1. Confirm it's CoreDNS (3 minutes)
kubectl get pods -n kube-system -l k8s-app=kube-dns -o wide
kubectl logs -n kube-system -l k8s-app=kube-dns --tail=50 --prefix
kubectl get endpoints kube-dns -n kube-system
Test from a throwaway pod:
kubectl run dnstest -n default --rm -it --restart=Never --image=busybox:1.36 -- \
sh -c "nslookup kubernetes.default.svc.cluster.local; nslookup microsoft.com"
| What you see | Likely cause |
|---|---|
CoreDNS CrashLoopBackOff, log shows a Corefile parse error | Syntax error, unknown plugin or duplicate server block in coredns-custom |
CoreDNS running, cluster.local works, external names fail | .override forwards . to a DNS server that's unreachable or wrong |
Only names listed in a hosts block resolve | hosts plugin without fallthrough |
| One zone fails, everything else works | That .server block forwards to the wrong IP, or NSG/firewall blocks UDP/TCP 53 to it |
kube-dns endpoints list is empty | No CoreDNS pod is Ready |
Error text varies by CoreDNS version, so read the first error line in the logs rather than matching exact wording.
2. Look at the change
kubectl get configmap coredns-custom -n kube-system -o yaml > coredns-custom-broken.yaml
cat coredns-custom-broken.yaml
Find who changed it. With AKS control plane logs sent to Log Analytics (resource-specific tables):
AKSAuditAdmin
| where TimeGenerated > ago(6h)
| where tostring(ObjectRef.resource) == "configmaps" and tostring(ObjectRef.name) == "coredns-custom"
| where Verb in ("update", "patch", "create")
| project TimeGenerated, Verb, user = tostring(User.username), ip = tostring(SourceIps[0]), UserAgent
| order by TimeGenerated desc
If you use GitOps (Flux or Argo CD), the commit history shows the previous version. Revert it there, or the controller puts the bad version back.
3. Roll back the ConfigMap
Fastest safe option: put back the last known-good version from Git.
kubectl apply -f coredns-custom-known-good.yaml
If you don't have one, empty it. This returns CoreDNS to AKS defaults: cluster names and Azure DNS (168.63.129.16) via the node's resolver.
# coredns-custom-empty.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: coredns-custom
namespace: kube-system
data: {}
kubectl apply -f coredns-custom-empty.yaml
Warning
Emptying the ConfigMap removes every custom forwarder. If workloads depend on a stub domain for on-premises names (for example
corp.contoso.comto your DNS servers), add that one known-good.serverkey back before you restart, or those lookups keep failing.
Don't delete the ConfigMap or edit the coredns ConfigMap. AKS manages that one and reconciles your changes away.
4. Restart CoreDNS
AKS picks up coredns-custom changes on a rolling restart:
kubectl -n kube-system rollout restart deployment coredns
kubectl -n kube-system rollout status deployment coredns --timeout=180s
kubectl logs -n kube-system -l k8s-app=kube-dns --tail=20 --prefix
The rollout replaces pods one at a time. If every pod is already crashing, the new pods start with the fixed config right away.
5. Restart workloads that cached failures
Most clients retry DNS, but some don't recover on their own: Java apps with a negative DNS cache, connection pools that gave up, and pods that failed readiness and were pulled from Services.
kubectl get pods -A --field-selector=status.phase!=Running,status.phase!=Succeeded
kubectl rollout restart deployment/orders-api -n orders
Restart one tier at a time, starting with what other services depend on.
Fixing the original change properly
When the incident is closed, reapply the change the engineer actually wanted, written correctly. A safe stub-domain example:
apiVersion: v1
kind: ConfigMap
metadata:
name: coredns-custom
namespace: kube-system
data:
corp.server: |
corp.contoso.com:53 {
errors
cache 30
forward . 10.10.0.4 10.10.0.5
}
hosts.override: |
hosts {
10.20.1.15 legacy-api.contoso.internal
fallthrough
}
Checks before applying:
- Key names end in
.serveror.override. .serverblocks name a specific zone. Don't define another.:53block; change the default with an.overridekey instead.- Every
hostsblock hasfallthrough. - The forwarder IPs answer UDP and TCP 53 from a node:
kubectl debug node/<node> -it --image=busybox:1.36 -- nslookup corp.contoso.com 10.10.0.4. - Apply to a non-production cluster first and run the
dnstestpod.
Verify recovery
- All CoreDNS pods are
Runningand Ready;kube-dnshas endpoints. dnstestresolveskubernetes.default.svc.cluster.local, a public name, aprivatelinkname and any stub-domain name.- App 5xx and timeout rates return to baseline.
Communicate
"DNS resolution inside AKS cluster
Prevent it next time
- Manage
coredns-customonly through GitOps or a pipeline with a review, never withkubectl editin production. - Add a CI check that validates the Corefile snippets (for example, run a CoreDNS container with the snippet and query it) before merge.
- Alert on CoreDNS health. With Managed Prometheus, alert when
kube_deployment_status_replicas_available{deployment="coredns"}drops below the desired count orcoredns_dns_responses_total{rcode="SERVFAIL"}spikes. Metric names vary by exporter version; check what your cluster exposes. - Run a synthetic DNS check from a pod every minute against an internal, an external and a private endpoint name.
- Roll CoreDNS config changes to one non-production cluster first and wait at least an hour.
Get the weekly HubDatAI email
One email a week with everything new: posts, learning sessions and videos. Free, no spam, unsubscribe in one click. What you get