You have typed market-web and reached a Service. Something turned that name into a cluster IP.
CoreDNS
Every Service gets a record:
CoreDNS serves these records. It is the Pod you found in kube-system in Chapter 2, behind the Service kube-dns.
What a Pod sees
Each Pod's /etc/resolv.conf points at CoreDNS and carries a search list:
search straits.svc.cluster.local svc.cluster.local cluster.local
nameserver 10.96.0.10A short name is tried with each suffix in turn:
wget market-api
1. market-api.straits.svc.cluster.local ← same namespace: found
2. market-api.svc.cluster.local
3. market-api.cluster.localSo inside a namespace the bare Service name is enough.
Across namespaces
From namespace ops, market-api expands to market-api.ops.svc.cluster.local. No such record. Add the namespace:
| From another namespace | Works? |
|---|---|
market-api | No: NXDOMAIN |
market-api.straits | Yes: the search list adds svc.cluster.local |
market-api.straits.svc.cluster.local | Yes: the full name |
Checking from a Pod
learner@shallows:~$ kubectl exec client -- nslookup market-api
Name: market-api.straits.svc.cluster.local
Address: 10.96.191.79nslookup prints the name it resolved and the cluster IP. NXDOMAIN means the name does not exist as searched.