What is NodeLocalDNS?

NodeLocalDNS is an optional feature in Kubernetes that improves DNS performance and reliability by running a small DNS caching server on each node.

Instead of making every DNS request go across the network to the kube-dns or CoreDNS service, the request is handled locally on the node. This reduces DNS lookup latency and avoids overloading the shared cluster DNS service.


Why Use NodeLocalDNS?

  • 🧠 Faster DNS resolution — queries are resolved from local cache.
  • 📉 Reduced load on kube-dns/CoreDNS — fewer round trips to the central service.
  • 🌐 Better reliability — even if CoreDNS has a hiccup, cached results can still resolve.

How NodeLocalDNS Works

Here’s a simplified flow:

  1. A pod makes a DNS query (e.g. to resolve my-service.default.svc.cluster.local).
  2. Instead of forwarding it to CoreDNS over the network, the request is sent to a local IP on the node (typically 169.254.20.10).
  3. The NodeLocalDNS agent on the node handles the request — either from its cache or by querying upstream CoreDNS.

This way, DNS traffic stays mostly local to the node.


YAML Example: Enabling NodeLocalDNS

You can enable NodeLocalDNS in your cluster with the following configuration (example for kubeadm):

kubectl apply -f https://k8s.io/examples/admin/nodelocaldns/nodelocaldns.yaml

Check that the nodelocaldns pods are running on each node:

kubectl get pods -n kube-system -l k8s-app=nodelocaldns

Where It Helps Most

  • Clusters with high pod churn (pods frequently created/destroyed).
  • Workloads doing many DNS lookups.
  • Environments with CoreDNS performance issues.

Summary

NodeLocalDNS is a small, local DNS caching layer that reduces pressure on your cluster DNS and speeds up lookups. It’s easy to set up and a great tool for production-grade clusters.

→ Learn more: