Coredns is in CrashLoopBackOff state with "no nameservers found" error log

I have tried to build kubernetes using kubeadm on my bare-metal server, but it seemed that coredns failed to start after installing cni (weave-net).

Two coredns containerd are now in “CrashLoopBackOff” state, and the logs of them are:

plugin/forward: no nameservers found

And the description of “kubectl describe pod” is as follows:

Events:
  Type     Reason            Age                    From               Message
  ----     ------            ----                   ----               -------
  Warning  FailedScheduling  4m52s (x9 over 13m)    default-scheduler  0/1 nodes are available: 1 node(s) had taint {node.kubernetes.io/not-ready: }, that the pod didn't tolerate.
  Normal   Scheduled         4m7s                   default-scheduler  Successfully assigned kube-system/coredns-58cf647449-8pq7k to k8s
  Normal   Pulled            3m13s (x4 over 4m6s)   kubelet            Container image "localhost:5000/coredns:v1.8.4" already present on machine
  Normal   Created           3m13s (x4 over 4m6s)   kubelet            Created container coredns
  Normal   Started           3m13s (x4 over 4m6s)   kubelet            Started container coredns
  Warning  Unhealthy         3m13s                  kubelet            Readiness probe failed: Get "http://10.32.0.3:8181/ready": dial tcp 10.32.0.3:8181: connect: connection refused
  Warning  BackOff           2m54s (x12 over 4m5s)  kubelet            Back-off restarting failed container

I have already tried using calico instead of weave, but the result was the same.
There’s no settings in /etc/resolv.conf file.
How can I deal with this problem?

Cluster information:

Kubernetes version: 1.22.1
Cloud being used: bare-metail
Installation method: kubeadm
Host OS: RedHat Enterprise Linux 8.4 (minimal install)
CNI and version: weave-net 1.16
CRI and version: containerd 1.4.11

1 Like

The coredns pods worked when I switch to Docker from containerd so I may need to configure something about containerd?
And with containerd, when I write some settings like “nameserver 8.8.8.8” in /etc/resolv.conf, the coredns pod seemed to be working.

1 Like

Thanks for finding a solution for this: domain name system - kubernetes coredns is in CrashLoopBackOff status with "no nameservers found" error - Server Fault

Seems odd that by default it’ll fail and not handle a forwarder. Easy fix at least.