liveBook · Manning

Domain name system

As explained in Acing the Certified Kubernetes Administrator Exam, Second Edition

The Domain Name System, a hierarchical naming system that resolves domain or resource names to network addresses.

DNS lets pods reach cluster resources by name instead of tracking IP addresses. CoreDNS resolves those names to IP addresses; Kubernetes Services provide stable names and IP addresses for groups of pods. CoreDNS runs as a Deployment in the kube-system namespace. section 1.4.3 section 6.2.3

A Service name is scoped to its namespace. A pod can use a short Service name for a Service in its own namespace. To reach one elsewhere, use <service-name>.<namespace-name>, or the full name <service-name>.<namespace-name>.svc.cluster.local. Check the pod’s /etc/resolv.conf for its search domains and DNS server IP. section 6.2.4 section 6.8

Diagnose a name that works only in another namespace

From a pod in namespace c01383, curl apache-svc returns “Could not resolve host” for a Service in default. curl apache-svc.default succeeds. Inspecting /etc/resolv.conf shows search domains beginning with c01383.svc.cluster.local: the unqualified name is searched from the pod’s namespace. section 6.2.4

When configuring or troubleshooting cluster DNS:

  • Check CoreDNS pods and their Deployment with kubectl -n kube-system get po and kubectl -n kube-system get deploy. If CoreDNS is the identified query bottleneck, scale its Deployment and verify the new replicas. section 6.2.3
  • If names fail, distinguish DNS from Service connectivity. In a demonstration with CoreDNS scaled to zero, wget apache-svc reports a bad address; after DNS is restored, the request reaches the Service. section 6.2.3
  • For a DNS Service IP change, keep the Service CIDR, kube-dns Service IP and kubelet clusterDNS setting aligned. Test a new pod’s resolver file and run nslookup to verify resolution. section 6.1
root@kind-control-plane:/# kubectl exec -it netshoot -- bash
bash-5.1# cat /etc/resolv.conf
search default.svc.cluster.local svc.cluster.local cluster.local
nameserver 100.96.0.10
options ndots:5

This pod resolver output verifies that the changed DNS Service IP, 100.96.0.10, reached a new pod and shows the search domains used for cluster names. section 6.1

How Acing the Certified Kubernetes Administrator Exam, Second Edition covers it

How deep it goes
Works through namespace lookup, CoreDNS availability, replica scaling and a DNS Service IP change; does not explain DNS protocol internals.
Examples
Tests cross-namespace Service names with curl, inspects /etc/resolv.conf and verifies resolution with nslookup.
What it assumes
Builds on pods and Services while introducing the cluster IP ranges needed for the configuration exercise.
What you can do after
Operate/configure it with kubectl and kubelet settings, then verify a new pod’s DNS server and name resolution.
How it connects
Connects DNS to CoreDNS, Services, namespaces, kubelet configuration and Service CIDR.

Also explained in

Compare how 7 books explain domain name system →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Acing the Certified Kubernetes Administrator Exam, Second Edition. The section links point to the parts of the book it draws on.