Kubernetes DNS Concepts

From NovaOrdis Knowledge Base
Revision as of 23:31, 11 July 2023 by Ovidiu (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search



Each Kubernetes cluster runs its own DNS service. The DNS service is exposed as a kube-dns Kubernetes ClusterIP service, running in the "kube-system" namespace. The service is backed by two coredns highly-available pods, also deployed in the "kube-system" namespace.

The DNS Service

Each Kubernetes cluster runs an internal DNS service. The DNS service is exposed as a regular Kubernetes ClusterIP service, deployed in the "kube-system" namespace, which in turn exposes the Kubernetes internal DNS server:

NAME       TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)                  AGE
kube-dns   ClusterIP   <none>        53/UDP,53/TCP,9153/TCP   49d

The static ClusterIP address allocated to the DNS service ( is hardcoded into every pod in the cluster, allowing the pods to resolve service names.

Every time a new Kubernetes service is deployed, the Kubernetes cluster automatically updates the internal database with service name to ClusterIP address mappings, making the ClusterIP address of the new service dynamically available to all other pods in the cluster. The mechanism is explained in detail in:

Services and DNS

StatefulSets and the individual pods managed by a StatefulSet are also registered with the DNS service.

Name Resolution inside a Pod

A pod can be configured to use the internal DNS server or not for DNS queries executed on the pod. This behavior is configured with the pod manifest dnsPolicy element.

Each pod gets an /etc/resolv.conf with a name server hardcoded to the IP address of the DNS service kube-dns:

search default.svc.cluster.local svc.cluster.local cluster.local
options ndots:5

The local DNS library is thus configured to use by default the name server behind the Kubernetes DNS service.

Each name being resolved on a pod is successively looked up, in order, in the following DNS subdomains: "default.svc.cluster.local", "svc.cluster.local" and "cluster.local". For more details see /etc/resolv.conf search.


"cluster.local" is a configurable cluster domain suffix used in all cluster local names.


All services in the cluster belong to "svc.cluster.local" subdomain.


DNS Operations

DNS Implementation Details

The DNS Server

The Kubernetes cluster's DNS server implementation is based on CoreDNS, kube-dns or SkyDNS, depending on version. The pods implementing the DNS support are exposed to the cluster via a DNS ClusterIP Service.


NAME                         READY   STATUS    RESTARTS   AGE
coredns-5644d7b6d9-kcxt6     1/1     Running   0          8h
coredns-5644d7b6d9-mztf9     1/1     Running   0          8h


Note that kube-dns seems to be both the name of the Kubernetes DNS service and the name of a backing provider.


External DNS