Skip to main content
In this lesson we’ll examine how DNS is implemented in a Kubernetes cluster by inspecting CoreDNS pods, services, and configuration. Follow the steps below to identify the DNS solution, count pods, locate the service IP, and find where CoreDNS reads its configuration.

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 the kube-system namespace to see DNS-related components:
Answer: The cluster uses CoreDNS as its DNS solution (pods named coredns-*).

2) How many DNS server pods are deployed?

From the pod list above we see two CoreDNS pods:
  • coredns-74ff55c5b-9lxcv
  • coredns-74ff55c5b-kgtwz
Answer: 2 CoreDNS pods are deployed.

3) What is the name of the service created for accessing CoreDNS?

List services in the kube-system namespace to find the DNS service:
Answer: The service name is kube-dns.

4) What is the IP of the CoreDNS server that pods should use to resolve services?

From the kube-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:
Answers:
  • The CoreDNS configuration file path inside the pod is /etc/coredns/Corefile.
  • That Corefile is provided via a ConfigMap named coredns, mounted into the pod as the config-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

That concludes this lab—now you know how to identify CoreDNS components, find the DNS service IP, and locate the Corefile configuration used by the DNS pods.

Watch Video