Service and Pod DNS

Kubernetes assigns DNS names to Services and Pods through the cluster DNS service, which is CoreDNS in Cloudera Cloud Factory clusters.

Kubernetes assigns DNS names to Services and Pods through the cluster DNS service, which is CoreDNS in Cloudera Cloud Factory clusters. A Service name resolves to the cluster IP address of the Service. A name has the form my-svc.my-namespace.svc.cluster-domain.example. Pods in the same namespace can use the short name my-svc.

A headless Service has no cluster IP address, and its name resolves to the IP addresses of the Pods behind it. Named ports also create SRV records. Pods get a search list that includes their namespace and the cluster domain, and a resolver setting of ndots:5, so a name with fewer than five dots is tried with the search domains first.

The dnsPolicy field of a Pod controls how it resolves names.

Table 1. DNS policies
PolicyBehavior
ClusterFirstThis is the default. Names outside the cluster domain go to the upstream resolver of the node.
DefaultThe Pod inherits the name resolution configuration of its node. Despite the name, this is not the default policy.
ClusterFirstWithHostNetUse this policy for Pods that run with hostNetwork, to keep cluster DNS.
NoneIgnore the cluster configuration. Supply all settings in dnsConfig.

Key defaults and limits

  • The dnsConfig field is stable since Kubernetes 1.14.
  • The setHostnameAsFQDN field is stable since Kubernetes 1.22.
  • A Pod can have up to 32 search domains with a total of 2048 characters. This limit is stable in Kubernetes 1.28.
  • Older container runtimes, containerd 1.5.5 and earlier and CRI-O 1.21 and earlier, can leave Pods in the pending state when the search list is long.
  • Windows nodes support a single DNS suffix.

A NodeLocal DNS cache reduces lookup latency. The Compatibility matrix in Tools and reference lists the verified versions.

For more information, see DNS for Services and Pods.