Hands-on Lab·Certified Kubernetes Administrator
CoreDNS and Service Discovery
Resolve one Service four ways, get a headless Service to hand back every Pod IP, and measure the real cost of a short name by counting the queries CoreDNS receives: five for fleet, one for the fully qualified name.
Services and Networking Guide 54 of 103 Intermediate
- Kubernetes1.36.4
- Cluster4 nodes
- Runtimecontainerd 2.2.6
- CNICalico v3.32.1
- TimeAbout 35 min
The last search domain comes from this lab's DHCP. Yours will differ, and that matters for the ndots count.
- CoreDNSv1.14.2
| Server Name | IP Address | OS | Roles | CPU | RAM | HDD |
|---|---|---|---|---|---|---|
| CKA1001 | 192.168.0.175 | Ubuntu 26.04 LTS | Control Plane Node | 2 Core | 4 GB | 50 GB |
| CKA1001-NODE01 | 192.168.0.176 | Ubuntu 26.04 LTS | Worker Node | 2 Core | 4 GB | 50 GB |
| CKA1001-NODE02 | 192.168.0.177 | Ubuntu 26.04 LTS | Worker Node | 2 Core | 4 GB | 50 GB |
| CKA1001-NODE03 | 192.168.0.178 | Ubuntu 26.04 LTS | Worker Node | 2 Core | 4 GB | 50 GB |
This guide includes
Use this when a name will not resolve inside the cluster, or when DNS is generating far more queries than anyone expected. This matters because ndots:5 means most short names are tried against every search domain first, and that cost is measurable rather than theoretical.
- reading what the kubelet hands a Pod for DNS, and finding the kube-dns Service in front of CoreDNS
- resolving one Service four different ways and finding which form fails
- setting
clusterIP: Noneand getting every Pod address back instead of one virtual IP - measuring what
ndots:5actually costs rather than taking the description on trust - reading the Corefile plugin by plugin
Before you start
- The Services guide, since every name below resolves to a Service.
- A shell Pod with DNS tools.
nicolaka/netshootis used throughout;nslookupanddigare not in normal application images. - The EndpointSlices guide, for why a headless Service returns the addresses it does.
-
What a Pod is handed for DNS
-
One Service, four names, and one that fails
-
A headless Service hands back the Pods themselves
-
ndots:5, measured rather than described
-
The Corefile, plugin by plugin