k8s-coredns-troubleshooting
Skill38 starsChanged 16 days agoApache-2.0View on GitHub
Use when cluster DNS itself misbehaves on Kubernetes: CoreDNS pods in CrashLoopBackOff ("Error during parsing: Unknown directive", "plugin/loop: Loop ... detected"), "reload failed" after a Corefile edit, external names failing while Service names resolve (";; connection timed out; no servers could be reached", SERVFAIL, "plugin/errors: 2 ... i/o timeout"), one domain or stub domain failing, rewrite or hosts entries that do not work, "Plugins not ready: \"kubernetes\"", REFUSED or "concurrent queries exceeded maximum", slow lookups (ndots, 5 s delays), NodeLocal DNSCache (169.254.20.10), or the AKS coredns-custom, EKS add-on and GKE kube-dns ConfigMaps. Investigates with kubectl get and logs, and proposes fixes. Reads first and asks before changing anything.
In this repository32 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- k8s-aks-troubleshootingSkill
- k8s-api-troubleshootingSkill
- k8s-argocd-troubleshootingSkill
- k8s-autoscaling-troubleshootingSkill
- k8s-cert-manager-troubleshootingSkill
- k8s-cilium-troubleshootingSkill
- k8s-cloudnative-pg-troubleshootingSkill
- k8s-cluster-reviewSkill
- k8s-envoy-gateway-troubleshootingSkill
- k8s-envoy-troubleshootingSkill
- k8s-external-secrets-troubleshootingSkill
- k8s-fluent-bit-troubleshootingSkill
- k8s-flux-troubleshootingSkill
- k8s-gatekeeper-troubleshootingSkill
- k8s-gateway-api-troubleshootingSkill
- k8s-grafana-troubleshootingSkill
- k8s-helm-troubleshootingSkill
- k8s-istio-troubleshootingSkill
- k8s-kyverno-troubleshootingSkill
- k8s-loki-troubleshootingSkill
- k8s-network-troubleshootingSkill
- k8s-node-troubleshootingSkill
- k8s-opentelemetry-collector-troubleshootingSkill
- k8s-prometheus-troubleshootingSkill
- k8s-rbac-troubleshootingSkill
- k8s-storage-troubleshootingSkill
- k8s-triageSkill
- k8s-upgrade-readinessSkill
- k8s-velero-troubleshootingSkill
- k8s-workload-troubleshootingSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 52
Only one client fails for a Service name (wrong namespace in the name, dnsPolicy, a Service with no endpoints) or an egress NetworkPolicy …
≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CoreDNS troubleshooting
Find out why CoreDNS does not answer a name the way it should, and propose a fix. Read first, ask before changing. Run the investigation commands freely. Run a command under an "Ask first" line only after the user approves that exact command; if your credentials do not allow it, give it to the user to run. Never run a "Proposed fix"; hand it to the user.
CoreDNS runs in kube-system as the Deployment coredns (label k8s-app=kube-dns),
behind the Service kube-dns, and reads its configuration, the Corefile, from the
ConfigMap coredns. Each server block (.:53 { ... }, or example.com:53 { ... } for
one domain) lists plugins: kubernetes answers names under cluster.local, forward
sends everything else upstream (by default to the node's /etc/resolv.conf), cache,
rewrite and hosts change answers, errors logs failures, loop stops CoreDNS when
it would query itself, and reload reads an edited Corefile about 30 seconds after the
ConfigMap reaches the pod. The default Corefile has no log plugin, so successful
queries and NXDOMAIN answers are not logged.
The commands use placeholders: my-namespace, my-app (a Service), my-client (a pod
whose lookups fail) and my-coredns-pod. Replace them with the real names. The CoreDNS
image has no shell, so test lookups from a client pod. Never read Secrets.
When to use
- CoreDNS pods crash, restart or are not Ready.
- Names outside the cluster fail, or one domain fails, while Service names resolve.
- DNS broke right after someone edited the
corednsConfigMap. - Lookups are slow, time out now and then, or get
REFUSED.
Hand-offs, by skill name. When the evidence points elsewhere, continue with that skill; if it is not installed, keep going with the steps here and tell the user which skill would help:
- Only one client fails for a Service name (wrong namespace in the name,
dnsPolicy, a Service with no endpoints) or an egress NetworkPolicy blocks DNS:k8s-network-troubleshooting. On Cilium, a DNS-aware policy:k8s-cilium-troubleshooting. - The CoreDNS pods are Pending, evicted or OOMKilled because of their node:
k8s-node-troubleshooting. Failed to watch ... is forbiddenfor thecorednsServiceAccount:k8s-rbac-troubleshooting.
Investigate
Work through the steps in order. Stop when you have the cause and its evidence.
1. See CoreDNS's pods, Deployment and Service. A rollout that is stuck, a pod that
restarts, or no endpoints for kube-dns each change where to look next.
kubectl get deployment coredns -n kube-system
kubectl get pods -n kube-system -l k8s-app=kube-dns -o wide
kubectl get service kube-dns -n kube-system
kubectl get endpointslices -n kube-system -l kubernetes.io/service-name=kube-dns
kubectl get daemonset -n kube-systemA node-local-dns DaemonSet means NodeLocal DNSCache sits in front of CoreDNS (see the
second reference). On GKE there is a kube-dns Deployment and no coredns ConfigMap.
2. Read CoreDNS's logs, current and, after a crash, previous. [ERROR] lines come
from errors; [INFO] Reloading and plugin/reload lines show Corefile edits.
kubectl logs -n kube-system -l k8s-app=kube-dns --tail=50 --prefix
kubectl logs -n kube-system my-coredns-pod --previous --tail=20
kubectl get events -n kube-system --field-selector involvedObject.kind=Pod --sort-by=.lastTimestamp3. Read the Corefile and any custom ConfigMap the cluster adds to it. Note the line numbers: parse errors name them.
kubectl get configmap coredns -n kube-system -o jsonpath='{.data.Corefile}'
kubectl get configmap coredns -n kube-system -o yaml
kubectl get configmap -n kube-system | grep -E 'coredns|dns'4. Read the client's side: its logs, its DNS policy, and which names fail.
kubectl logs -n my-namespace my-client --tail=30
kubectl get pod my-client -n my-namespace -o jsonpath='{.spec.dnsPolicy}{" "}{.spec.dnsConfig}{" node="}{.spec.nodeName}{"\n"}'
kubectl get service my-app -n my-namespace5. Look a name up from the client, if its image has nslookup or dig: a Service
name, an external name, and the failing one. Try a fully qualified name with a trailing
dot to skip the search list.
Ask first: the agent runs this only after the user approves it.
kubectl exec my-client -n my-namespace -- nslookup kubernetes.default.svc.cluster.local
kubectl exec my-client -n my-namespace -- nslookup my-app.my-namespace.svc.cluster.local
kubectl exec my-client -n my-namespace -- nslookup example.com.
kubectl exec my-client -n my-namespace -- cat /etc/resolv.conf
# Undo: none needed; these commands only read6. Open the matching reference and follow its steps:
| What you see | Reference |
A crash, Error during parsing, reload failed, a loop, Plugins not ready, upstream timeouts, SERVFAIL, REFUSED, stub domains, rewrite, hosts, metrics | references/corefile-and-plugins.md |
Slow or intermittent lookups, ndots, NodeLocal DNSCache, scaling, AKS, EKS and GKE | references/clients-nodelocal-managed.md |
Read the results
What the common findings mean (CoreDNS 1.14):
- A new pod crashes with
/etc/coredns/Corefile:<line> - Error during parsing: Unknown directive '<word>'(no[FATAL]prefix; read it with--previous): the Corefile has a typo or a plugin this build does not have, on that line. Pods that were already running log[ERROR] plugin/reload: Corefile changed but reload failed: ...and keep serving their old configuration, so DNS still works until those pods are replaced: the ConfigMap and what is served are no longer the same. [FATAL] plugin/loop: Loop (127.0.0.1:<port> -> :53) detected for zone ".": CoreDNS forwards to itself, usually because the node's/etc/resolv.confpoints at a local resolver such as127.0.0.53(systemd-resolved), orforwardnames a loopback address or thekube-dnsService.[ERROR] plugin/errors: 2 <name> A: read udp <pod>-><upstream>:53: i/o timeout:2is SERVFAIL; the upstream inforwarddoes not answer (wrong address, firewall, upstream down). The client sees;; connection timed out; no servers could be reachedorSERVFAILfor external names, while Service names, which CoreDNS answers itself, still resolve.- One name or domain gets NXDOMAIN and nothing is logged: CoreDNS answered it on
purpose: a
rewriteto a name that does not exist, ahostsblock withoutfallthrough, a server block for that zone forwarding to the wrong place, or a name undercluster.localthat is not a Service (thekubernetesplugin never forwards those). [INFO] plugin/ready: Plugins not ready: "kubernetes"and the pod not Ready: CoreDNS cannot list Services and EndpointSlices from the API server (RBAC, network to the API server, an overloaded API server).5 <name> A: concurrent queries exceeded maximum 1000andREFUSEDat the client: more queries are waiting on the upstream thanmax_concurrentallows; the upstream is slow or the load is too high.
State the cause in one sentence, then the evidence you saw (the log line, the Corefile line, the client's result), then the proposed fix.
Proposed fix
Show each fix to the user before running it: what it changes and how to undo it. The
Corefile serves every pod in the cluster: never change it yourself; hand it to the user as
a proposed fix, with the whole corrected Corefile and the current one saved for the undo.
On AKS change the coredns-custom ConfigMap instead, on EKS the add-on's
configurationValues, on GKE the kube-dns ConfigMap: the provider overwrites direct
edits of the coredns ConfigMap.
Save the Corefile before any change:
kubectl get configmap coredns -n kube-system -o jsonpath='{.data.Corefile}'Apply the corrected Corefile (save it as Corefile). Running pods reload it within about
two minutes (up to a minute for the kubelet to update the mounted ConfigMap, then the
reload plugin's check every 30 seconds or so), and log [INFO] Reloading complete:
Proposed fix: review before running. The agent does not run this.
kubectl create configmap coredns -n kube-system --from-file=Corefile --dry-run=client -o yaml | kubectl apply -f -
# Undo: the same command with the Corefile you saved before the changeOnce the Corefile is valid again, pods in CrashLoopBackOff start at their next restart, and a stuck rollout goes on by itself. To replace pods that still run an old configuration:
Ask first: the agent runs this only after the user approves it.
kubectl rollout restart deployment/coredns -n kube-system
# Undo: none needed; the restart only recreates the pods with the same templateRestart CoreDNS only after its Corefile is valid: with a broken Corefile, the new pods crash and only the old ones that the rollout has not replaced yet keep DNS working.
Sources
Checked against CoreDNS 1.14.6 (the version kubeadm 1.37 deploys) and Kubernetes 1.37:
- CoreDNS plugins: kubernetes, forward, reload, loop, errors, log, cache, rewrite, hosts, ready, health and metrics.
- Kubernetes: Debugging DNS resolution, Customizing DNS, DNS for Services and Pods, NodeLocal DNSCache and autoscaling DNS.
- Managed clusters: AKS CoreDNS customization, EKS CoreDNS add-on and GKE kube-dns.
- Messages from the source: kubeadm's Corefile, reload, loop and forward. The parse, reload and upstream messages quoted here were seen on a Kubernetes 1.37 kind cluster with CoreDNS 1.14.6.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

