Prerequisite: set an alias for kubectl
Run this on the control plane node to make subsequent commands shorter:1) Identify the DNS solution implemented in this cluster
List the pods in thekube-system namespace to see DNS-related components:
coredns-*).
2) How many DNS server pods are deployed?
From the pod list above we see two CoreDNS pods:coredns-74ff55c5b-9lxcvcoredns-74ff55c5b-kgtwz
3) What is the name of the service created for accessing CoreDNS?
List services in thekube-system namespace to find the DNS service:
kube-dns.
4) What is the IP of the CoreDNS server that pods should use to resolve services?
From thekube-dns Service output above, the ClusterIP is 10.96.0.10. This ClusterIP is the DNS server address that pods use (typically configured in /etc/resolv.conf) to resolve Kubernetes service names and other DNS queries.
Answer: 10.96.0.10
5) Where is the CoreDNS configuration file located inside the CoreDNS pod?
Inspect the CoreDNS pod description to view mounts and arguments that reveal where the Corefile comes from:- The CoreDNS configuration file path inside the pod is
/etc/coredns/Corefile. - That Corefile is provided via a
ConfigMapnamedcoredns, mounted into the pod as theconfig-volume.
You can inspect the CoreDNS ConfigMap to view the active Corefile:Look for the
Corefile key in the ConfigMap data to see configuration and DNS forwarding rules.Quick Reference
Further reading
- CoreDNS official docs: https://coredns.io
- Kubernetes DNS concepts: https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/