Issue#

The CoreDNS pods never become ready and keep restarting, so pods cannot resolve any names.

kubectl -n kube-system get pods -l k8s-app=kube-dns
NAME READY STATUS RESTARTS AGE coredns-76f75df574-8kq2x 0/1 CrashLoopBackOff 6 8m coredns-76f75df574-tz9lw 0/1 CrashLoopBackOff 6 8m

The logs show:

[FATAL] plugin/loop: Loop (127.0.0.1:55953 -> :53) detected for zone ".", see https://coredns.io/plugins/loop#troubleshooting. Query: "HINFO 4547991504243258144.3688648895315093531."

Cause#

CoreDNS forwards external queries to the upstream servers listed in the resolv.conf it receives from the kubelet (forward . /etc/resolv.conf in the Corefile).

On nodes running systemd-resolved (Ubuntu, recent Debian), /etc/resolv.conf contains only the local stub resolver:

nameserver 127.0.0.53

Inside the CoreDNS pod, 127.0.0.53 is the pod's own loopback, so CoreDNS forwards queries to itself. The loop plugin detects this and exits on purpose.

Solution#

  1. Confirm the node uses the systemd-resolved stub:
cat /etc/resolv.conf ls -l /etc/resolv.conf
  1. Check which file the kubelet passes to pods:
grep resolvConf /var/lib/kubelet/config.yaml
  1. Point the kubelet to the file that holds the real upstream servers (run on every node):
sudo sed -i 's|^resolvConf:.*|resolvConf: /run/systemd/resolve/resolv.conf|' /var/lib/kubelet/config.yaml grep -q '^resolvConf:' /var/lib/kubelet/config.yaml || \ echo 'resolvConf: /run/systemd/resolve/resolv.conf' | sudo tee -a /var/lib/kubelet/config.yaml sudo systemctl restart kubelet
  1. On kubeadm clusters, make the change persistent so kubeadm upgrade does not revert it:
kubectl -n kube-system edit configmap kubelet-config
resolvConf: /run/systemd/resolve/resolv.conf
  1. Restart CoreDNS so it picks up the new resolv.conf:
kubectl -n kube-system rollout restart deployment coredns

Alternative: If you do not want CoreDNS to depend on the node's resolvers, set explicit upstreams in the Corefile with kubectl -n kube-system edit configmap coredns, e.g. forward . 1.1.1.1 8.8.8.8, then restart the deployment.

Verify#

kubectl -n kube-system rollout status deployment coredns kubectl -n kube-system logs -l k8s-app=kube-dns --tail=20

The pods should be 1/1 Running without the loop error. Test resolution from a pod:

kubectl run dnstest --rm -it --image=busybox:1.36 --restart=Never -- nslookup kubernetes.default kubectl run dnstest2 --rm -it --image=busybox:1.36 --restart=Never -- nslookup debian.org

Both internal and external names should resolve.