"curl http://api works from one namespace and fails from another — why?" A pod in shop runs curl http://api/. A healthy Service api exists in payments; there is none in shop. Default dnsPolicy. What happens?
- It works: Service names are cluster-wide, and the
svc.cluster.localsearch suffix finds it.svc.cluster.localis a zone, not a namespace;api.svc.cluster.localis not a record for any Service. - curl fails with
Could not resolve host: the resolver expandsapithrough the search list, starting withapi.shop.svc.cluster.local, and no suffix yields a name that exists; the caller must useapi.paymentsor the full name. Service names are namespaced; the search list only ever inserts the pod's own namespace, so a short name cannot reach another namespace. - It times out: names that are not in the pod's namespace are forwarded to the upstream resolver, which cannot answer. Every candidate name ends in cluster.local, which CoreDNS answers authoritatively with NXDOMAIN in well under a millisecond; nothing is forwarded.
- The request resolves but is rejected, because RBAC forbids calling Services in other namespaces. RBAC controls API access, not DNS or pod-to-Service traffic; cross-namespace calls are open unless a NetworkPolicy says otherwise.
- It works: CoreDNS looks the Service up in every namespace and returns the first match. The kubernetes plugin answers exactly the name asked; namespace disambiguation happens in the client's search list, not in CoreDNS.
curl fails with 'Could not resolve host' because a short name only expands with the pod's own namespace; use
The pod's resolv.conf lists <own-ns>.svc.cluster.local, svc.cluster.local and cluster.local as search suffixes, so a bare Service name is only ever completed with the pod's own namespace. Each expansion ends in cluster.local, which CoreDNS answers authoritatively, so the client collects NXDOMAINs and gives up. The interview signal is knowing where namespace scoping is applied (the client's search list) and answering with the form that works: <svc>.<ns>, which the second suffix completes.
Saying 'it works because Service names are cluster-wide' or 'CoreDNS searches every namespace'. The search list is the client's, CoreDNS answers exactly the name asked, and RBAC has nothing to do with traffic.