CoreDNS is the default DNS server for Kubernetes clusters. It enables Pods and Services to discover each other by name rather than by volatile IP address.
Why Cluster DNS Matters
In Kubernetes:
Pod IPs are ephemeral — they change on restart, rescheduling, or scaling.
Service IPs are stable within the cluster, but remembering them is impractical.
Applications need to reach other services by a predictable name (e.g., database.default.svc.cluster.local).
CoreDNS solves this by maintaining an internal DNS namespace for the cluster.
Relationship to External DNS
This video on external DNS is explicitly framed as a prerequisite for understanding CoreDNS:
“From the next video we’ll be looking into networking stuff related to Kubernetes itself like CoreDNS. I thought it would be a good idea to add a prerequisite because to understand CoreDNS, you need to know how DNS works actually.” — Day 30 CKA Video
The same principles apply:
A records → map service names to ClusterIPs
CNAME-like behavior → ExternalName Services proxy to external domains
Caching → CoreDNS caches responses to reduce API server load
Hierarchical resolution → .svc.cluster.local is the cluster domain; queries outside it are forwarded upstream
How CoreDNS Works (High-Level)
A Pod makes a DNS query for my-service.default.svc.cluster.local.
The query is sent to the cluster’s DNS Service IP (usually 10.96.0.10 or the 10th IP in the Service CIDR).
CoreDNS receives the query.
CoreDNS checks the Kubernetes plugin — finds the Service’s ClusterIP.
Returns the IP to the Pod.
For external domains (e.g., google.com), CoreDNS forwards the query to an upstream resolver configured in its Corefile.
Returns individual Pod IPs (A records for each endpoint)
ExternalName
Returns a CNAME to an external domain
Troubleshooting Cluster DNS
Command
Purpose
kubectl run -it --rm debug --image=busybox:1.28 --restart=Never -- nslookup kubernetes.default
Test if Pod DNS works
kubectl logs -n kube-system -l k8s-app=kube-dns
Check CoreDNS logs
kubectl get configmap coredns -n kube-system -o yaml
Inspect Corefile
Practical Practice
Exam-style hands-on tasks for CoreDNS and cluster DNS. Complete each task before reviewing the solution. Time yourself — CKA tasks average 5–7 minutes.
Task 1: Verify Cluster DNS is Working
You are asked to confirm that Pods in the cluster can resolve the Kubernetes API service name.
Requirements: Use a temporary Pod with busybox:1.28. Run nslookup kubernetes.default.
Verification: The command returns the ClusterIP of the kubernetes Service.
Solution:
kubectl run -it --rm debug --image=busybox:1.28 --restart=Never -- nslookup kubernetes.default
Task 2: Resolve a Cross-Namespace Service
A Pod in namespace frontend cannot reach a Service api in namespace backend. You suspect the Pod is using a short name instead of the full FQDN.
Requirements: From a test Pod in frontend, resolve the Service using the correct cross-namespace FQDN.
Verification:kubectl run -n frontend -it --rm debug --image=busybox:1.28 --restart=Never -- nslookup api.backend.svc.cluster.localSolution:
Task 3: Inspect the CoreDNS ConfigMap
You are asked to view the active CoreDNS Corefile to understand how cluster DNS is configured.
Requirements: Read the ConfigMap coredns in kube-system namespace.
Verification:kubectl get configmap coredns -n kube-system -o yaml | head -20Solution:
kubectl get configmap coredns -n kube-system -o yaml# Look for the Corefile section under data:
Task 4: Fix DNS Resolution After NetworkPolicy
A default-deny NetworkPolicy in namespace app is blocking all egress. Pods can no longer resolve Service names.
Requirements: Add an egress rule allowing UDP 53 to the kube-system namespace.
Verification:kubectl run -n app -it --rm debug --image=busybox:1.28 --restart=Never -- nslookup kubernetes.defaultSolution: