Troubleshoot Kube DNS

How to troubleshoot Kube DNS

Troubleshooting pod with networking utils installed

You can spin up a pod with networking tools installed to quickly and efficiently troubleshoot DNS. The tools installed in the image include:

  • Ping
  • Tracert
  • Curl
  • Dig
  • Nslookup

The following command will pull a popular image from Google container registry called dnsutils tagged at version 1.3 and open a terminal session on the pod.

kubectl run -it dnsutils --image gcr.io/kubernetes-e2e-test-images/dnsutils:1.3

Once connected to the pod, if you run nslookup kubernetes you can check the kubernetes service fronting the API server which should resolve the name kubernetes.default.svc.cluster.local.

/ # nslookup kubernetes
Server:         10.43.0.10
Address:        10.43.0.10#53

Name:   kubernetes.default.svc.cluster.local
Address: 10.43.0.1

/ #

The first two lines return the IP address of your cluster DNS and the last two lines should show the FQDN of the kubernetes service and its cluster IP. You can check the IP of the kubernetes service by running kubectl get svc kubernetes.

$ kubectl get svc kubernetes
NAME         TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE
kubernetes   ClusterIP   10.43.0.1    <none>        443/TCP   44h

Recreate the kube-dns pod

If you face challenges with DNS it could be an option to simply recreate the kube-dns pod and see if a new pod solves any errors.

To do this you can run a delete command against the kube-dns pod and kubernetes will automatically re-create it as shown in the sequence below.

$ kubectl get pod -n kube-system -l k8s-app=kube-dns
NAME                      READY   STATUS    RESTARTS   AGE
coredns-6799fbcd5-96p7b   1/1     Running   0          44h

$ kubectl delete pod -n kube-system -l k8s-app=kube-dns
pod "coredns-6799fbcd5-96p7b" deleted

$ kubectl get pod -n kube-system -l k8s-app=kube-dns
NAME                      READY   STATUS    RESTARTS   AGE
coredns-6799fbcd5-zsbsz   1/1     Running   0          8s
Last modified July 21, 2024: update (e2ae86c)