Introduction
When deploying applications on Kubernetes, one of the most essential components that often works silently in the background is DNS (Domain Name System). clusters use this dns plugin as the default DNS service for service discovery and internal communication.
What is CoreDNS?
It is a flexible and extensible DNS server written in Go. In it acts as a DNS service that allows pods to discover each other using DNS names rather than IP addresses.
It was introduced as the default DNS server in v1.13, replacing kube-dns due to its performance and flexibility.
Key Features:
-
Lightweight and fast
-
Modular (plugin-based architecture)
-
Natively integrates with system
-
Supports service discovery
Why DNS is Important in Kubernetes?
In services are dynamic — pods come and go, IPs change. But service names remain consistent.
-
Translating service names to IPs
-
Enabling pod-to-pod and pod-to-service communication
-
Load balancing DNS queries
How CoreDNS Works
It runs as a Deployment in the kube-system namespace. It listens to DNS requests made by pods and resolves them based on the current service and pod metadata.
Here’s the general flow:
-
A pod makes a DNS query to resolve
my-service.default.svc.cluster.local. -
It receives this query on port 53 (UDP/TCP).
-
It checks API to resolve the service name.
-
Responds with the ClusterIP of the service.

Configuration File (Corefile)
The CoreDNS configuration is stored in a file named Corefile, usually located in the ConfigMap:
kubectl -n kube-system get configmap coredns -o yamlExample :
.:53 {
errors
health
kubernetes cluster.local in-addr.arpa ip6.arpa {
pods insecure
fallthrough in-addr.arpa ip6.arpa
}
prometheus :9153
forward . /etc/resolv.conf
cache 30
loop
reload
loadbalance
}Explanation:
-
.53: CoreDNS listens on port 53 -
kubernetes cluster.local: Enable Kubernetes service discovery -
forward: Forward unresolved queries to upstream DNS (like Google) -
cache: Improves performance by caching -
prometheus: Metrics endpoint
Installing/Checking CoreDNS
CoreDNS is installed by default in most setups via kubeadm or managed services like EKS, GKE, AKS.
To check the deployment:
kubectl get pods -n kube-system -l k8s-app=kube-dns
To restart CoreDNS:
kubectl rollout restart deployment coredns -n kube-systemUse Cases
| Use Case | Description |
|---|---|
| Service Discovery | Pods find other services using DNS |
| External Name Services | Mapping to external DNS names |
| Monitoring | Expose metrics via Prometheus |
| Load Balancing | Round-robin DNS load balancing |
| Custom DNS Plugins | Add custom behaviors like rewrites, filtering |
Example:
apiVersion: v1
kind: Pod
metadata:
name: dnsutils
namespace: default
spec:
containers:
- name: dnsutils
image: busybox
command:
- sleep
- "3600"
restartPolicy: AlwaysUse it to test DNS queries:
kubectl exec -it dnsutils -- nslookup .defaultDebugging Issues
1. Check Logs:
kubectl logs -n kube-system -l k8s-app=kube-dns2. Check Corefile syntax:
Ensure there are no errors in the configmap
3. Test DNS resolution in a pod:
nslookup kubernetes.default
dig kube-dns.kube-system.svc.cluster.localUsing in Production
-
Enable caching – Reduces DNS lookup time
-
Use health checks – Use the
healthplugin for monitoring -
Monitor with Prometheus – Expose metrics for observability
-
Limit DNS recursion – Prevent external abuse
-
Split DNS for internal/external – Secure private resolution
-
Audit logs – Track abnormal query patterns
Real-World Use Case
Imagine a microservices architecture where multiple services (e.g., frontend, backend, auth, database) need to talk to each other inside a cluster.
Conclusion
It is important because it handles DNS for your Kubernetes cluster.It is a vital yet often overlooked part of networking. From resolving internal service names to enabling reliable pod communication, it keeps the cluster connected and operational.
Mastering for dns not only improves your troubleshooting skills but also makes your cluster more observable and secure.
Final Thoughts
“It’s installed by default and runs as a deployment in the cluster.”DNS is a critical part of every distributed system, and ensures that service discovery happens seamlessly. Whether you’re deploying microservices or running multi-cluster environments, understanding and optimizing it will give you a major edge in managing networking efficiently.
For official documentation, [Kubernetes CoreDNS docs] click here