Skip to main content
If you run nslookup from inside a pod and kubernetes.default fails while google.com still resolves, the pod can reach some DNS server but not the cluster DNS. This typically happens because of one file and one setting: /etc/resolv.conf inside the pod and the pod’s dnsPolicy. Example failure:
Summary: external names resolve (node DNS works), but internal cluster names fail (cluster DNS not being used).

Why this happens

Every pod has its own /etc/resolv.conf. Kubernetes (kubelet) writes that file for the pod based on the pod’s dnsPolicy and whether the pod uses the host network. A typical pod’s /etc/resolv.conf contains three important parts:
  • nameserver — usually the cluster DNS (kube-dns/CoreDNS) service IP.
  • search — includes the pod’s namespace, svc, and cluster.local so short service names expand correctly.
  • options — e.g., ndots value.
Example /etc/resolv.conf inside a normal pod:
If nameserver points to the node’s DNS (the node’s /etc/resolv.conf) rather than the cluster DNS, the pod will resolve internet names but not Kubernetes service names. That happens when the pod will inherit the node resolver instead of using cluster DNS.

The culprit: dnsPolicy

Kubernetes exposes dnsPolicy on pods to control how DNS is configured. Common values:
  • ClusterFirst (default for most pods): kubelet configures /etc/resolv.conf to use the cluster DNS so pods can resolve internal service names such as kubernetes.default.
  • Default: the pod inherits the node’s DNS configuration (the node’s /etc/resolv.conf). This allows internet name resolution via the node, but internal Kubernetes service names will not be resolved by that DNS.
  • ClusterFirstWithHostNet: special policy for host-networked pods that still directs DNS to the cluster DNS.
Example pod spec using ClusterFirst (default):
Example pod spec that will use the node DNS (and thus likely fail to resolve cluster service names):
The Default dnsPolicy is misleading: it does not mean “use the Kubernetes default behavior.” It means “use the node’s resolver.” If you need cluster DNS resolution, do not use dnsPolicy: Default.

Host networking adds a wrinkle

When hostNetwork: true is set, the pod uses the node’s network namespace. By default kubelet adjusts the dnsPolicy to ClusterFirstWithHostNet for these pods so they still use cluster DNS. Problems arise when dnsPolicy is explicitly set to Default on a host-networked pod — such pods will use the node resolver and lose ability to resolve cluster service names. Host-networked pod that will run into the DNS problem:
Fix by using ClusterFirstWithHostNet:

How to debug this issue

  1. Check /etc/resolv.conf inside the pod:
Look for:
  • nameserver — is it the cluster DNS IP (e.g., 10.96.0.10) or the node IP?
  • search — does it include <namespace>.svc.cluster.local and cluster.local?
  • options ndots — ensure it’s reasonable (commonly ndots:5).
  1. Inspect the pod spec:
Check spec.dnsPolicy and spec.hostNetwork.
  1. If the pod uses host networking, ensure dnsPolicy is ClusterFirstWithHostNet (unless you intentionally want node DNS).

Quick checklist

References

Use the checklist above to quickly identify whether a pod is pointed at the node resolver by mistake, and update dnsPolicy or the pod spec accordingly to restore cluster DNS resolution.

Watch Video