Kuberbnetes - coredns is not working

Hi, I installed a k8s environment using kubeadm, but coredns seems not work well, but coredns status is running.

NAME                                 READY   STATUS    RESTARTS   AGE
coredns-78fcd69978-257fm             1/1     Running   0          11h
coredns-78fcd69978-hln69             1/1     Running   0          11h
etcd-guoyao-dev                      1/1     Running   2          11h
kube-apiserver-guoyao-dev            1/1     Running   2          11h
kube-controller-manager-guoyao-dev   1/1     Running   2          11h
kube-proxy-dkq4t                     1/1     Running   0          11h
kube-scheduler-guoyao-dev            1/1     Running   2          11h```
but cannot resolve the service domain name. why? could someone help me fix it? :sweat_smile:
```root@guoyao-dev:/home/velero-v1.6.3-linux-amd64# kubectl run curl --image=radial/busyboxplus:curl -i --tty
If you don't see a command prompt, try pressing enter.
[ root@curl:/ ]$ nslookup my-nginx
Server:    10.96.0.10
Address 1: 10.96.0.10

nslookup: can't resolve 'my-nginx'
[ root@curl:/ ]$ ```
And there are alot of error logs in coredns. here is some:
```ERROR] plugin/errors: 2 [auth.docker.io](http://auth.docker.io). AAAA: read udp 10.244.0.2:45051->172.17.0.1:53: i/o timeout
[ERROR] plugin/errors: 2 [registry-1.docker.io](http://registry-1.docker.io). A: read udp 10.244.0.2:49016->8.8.8.8:53: i/o timeout
[ERROR] plugin/errors: 2 [storm.emqx.io](http://storm.emqx.io). A: read udp 10.244.0.2:36417->172.17.0.1:53: i/o timeout
[ERROR] plugin/errors: 2 [storm.emqx.io](http://storm.emqx.io). A: read udp 10.244.0.2:44858->8.8.8.8:53: i/o timeout
[ERROR] plugin/errors: 2 [storm.emqx.io](http://storm.emqx.io). A: read udp 10.244.0.2:35737->8.8.8.8:53: i/o timeout
[ERROR] plugin/errors: 2 [storm.emqx.io](http://storm.emqx.io). A: read udp 10.244.0.2:60939->8.8.8.8:53: i/o timeout
[ERROR] plugin/errors: 2 [storm.emqx.io](http://storm.emqx.io). A: read udp 10.244.0.2:48756->172.17.0.1:53: read: connection refused```
what's the problem, could someone help me? Thanks all in advance.

Do you have a Service called my-nginx?

Yes, there’s one

NAME         TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)   AGE
kubernetes   ClusterIP   10.96.0.1      <none>        443/TCP   11h
my-nginx     ClusterIP   10.97.69.107   <none>        80/TCP    23m```

Use the image busybox:1.28 and try again.

Still not work, same error

kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
/ # nslookup my-nginx
Server:    10.96.0.10
Address 1: 10.96.0.10

nslookup: can't resolve 'my-nginx'
/ # ```

Check your CNI plug-in Pods

Sorry, but how to check it:sweat_smile:, which command should I run? i’ve never checked it.

What CNI plug-in are you running?

{
    "cniVersion": "0.3.0",
    "name": "mynet",
    "type": "bridge",
    "bridge": "cni0",
    "isGateway": true,
    "ipMasq": true,
    "ipam": {
        "type": "host-local",
        "subnet": "10.244.0.0/16",
        "routes": [
            {"dst": "0.0.0.0/0"}
        ]
    }
}
root@guoyao-dev:/home# cat /etc/cni/net.d/99-loopback.conf 
{
    "cniVersion": "0.3.0",
    "type": "loopback"
}```
not sure that whether my command is right.

"subnet": "10.244.0.0/16"
is this related? I found my-nginx service clusterIP is not this

NAME         TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)   AGE
kubernetes   ClusterIP   10.96.0.1      <none>        443/TCP   12h
my-nginx     ClusterIP   10.97.69.107   <none>        80/TCP    49m```

Show output of kubectl get po -A

I reinstall k8s using kubeadm init and using cilium as CNI, now it seems work well.

kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
/ # nslookup my-nginx
Server:    10.96.0.10
Address 1: 10.96.0.10 kube-dns.kube-system.svc.cluster.local

Name:      my-nginx
Address 1: 10.100.17.87 my-nginx.default.svc.cluster.local```

It seems that it’s due to cni, I’ve reinstalled k8s alot of times before, but I didn’t re-install cni sometimes. That’s maybe the reason that cause coredns cannot resolve service domain name. Thanks a lot :smile::+1:

That was the reason why, yes.