Service Selectors and Endpoints
A Service whose selector matches nothing is completely valid. It gets a ClusterIP, it resolves in DNS, and it routes to nowhere - with no error, no event and no warning. This reproduces it, shows the two commands that identify it in seconds, and then covers the DNS names a Service gets and how a headless one differs.
Services and Networking Guide 34 of 44 Beginner
- Kubernetes1.36.4
- Cluster4 nodes
- Runtimecontainerd 2.2.6
- CNICalico v3.32.1
- TimeAbout 15 min
ndots:5 in the Pod's resolv.conf means any name with fewer than five dots is tried against every search domain first. That is why api resolves, why nslookup api prints NXDOMAIN lines for the suffixes it tries on the way, and why an external name like example.com costs several failed lookups before the real one.
| 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 Service exists, resolves, and answers nothing. This matters because a selector that matches nothing is completely valid - the object is accepted, DNS works, and the only sign of trouble is an empty endpoint list.
- creating a Service whose selector carries a typo, and watching it be accepted anyway
- putting Pod labels beside the Service selector, which is the pair of commands that finds it
- seeing that the name still resolves even with no backends behind it at all
- making it headless with
clusterIP: Noneand getting a different answer out of DNS
Before you start
- A cluster with CoreDNS, which is every kubeadm cluster.
- The session creates namespace
ckad-dns, a Deploymentapi, a Service with a deliberate typo in its selector, and later a headless Service.
-
A Service with a typo in its selector
-
The two commands that find it
-
The names that resolve
-
A headless Service returns something different