Endpoint and DNS troubleshooting
Follow the failure in layers
When the bookstore cannot reach its inventory API, check three independent stages: name resolution, Service forwarding, and the backend application. A positive DNS response only supplies an address. A normal ClusterIP Service may resolve even if its selector matches no ready Pods. Headless records depend more directly on published endpoint addresses. A request can still fail after a successful lookup because of policy, routing, ports or application errors.
Recognize four distinct DNS observations
NXDOMAIN means the queried name does not exist according to the response; a misspelled name, wrong namespace or incorrect cluster suffix are possible causes. NOERROR with no answer for the requested type (often called NODATA) is different: the name may exist without that record type. SERVFAIL indicates that the server could not complete the query; an upstream problem or incomplete Kubernetes API synchronization is possible. A timeout means no usable response arrived within the client’s deadline; the cause could be reachability, a dropped packet, DNS overload or something else. Neither SERVFAIL nor timeout alone identifies the failing component.
Synthetic observationsA missing.books.svc.cluster.test. -> NXDOMAINAAAA inventory.books.svc.cluster.test. -> NOERROR, zero AAAA answersA upstream.example. -> SERVFAILA inventory.books.svc.cluster.test. -> TIMEOUT (client observation, no DNS response)Inspect the Service and every relevant EndpointSlice
A Service selects Pods using labels; EndpointSlices describe backend addresses, ports and conditions. Inspect all slices in the Service namespace carrying the kubernetes.io/service-name label. Do not assume one slice is the whole backend set. In the fixture, the Service listens on port 80 and the named endpoint port is 8080. The ready endpoint is 10.42.2.20; the second is explicitly not ready. An absent ready condition is not equivalent to explicit false; consumers generally treat unknown ready as ready. Terminating endpoints and publishNotReadyAddresses require additional interpretation. The simple model here uses explicit conditions and no terminating endpoints.
apiVersion: v1kind: Servicemetadata: name: inventory namespace: booksspec: selector: app: inventory ports: - name: http port: 80 targetPort: 8080Collect scoped read-only evidence
The following commands are illustrative, not executed. Only use them with a preapproved lab kubeconfig, explicit context and existing resources. First verify the client resolver and a known internal name, then inspect the target Service, slices and Pod labels. If the Service exists but the ready set is empty, compare the selector to labels and Pod readiness before changing anything. A direct backend request, if authorized, uses the endpoint port; the Service request uses the Service port. A successful direct request narrows the search but does not prove a specific forwarding fault. Do not disable network policies or delete Pods to diagnose the problem.
kubectl --kubeconfig ./lab.kubeconfig --context dns-study -n shop exec client -- cat /etc/resolv.confkubectl --kubeconfig ./lab.kubeconfig --context dns-study -n shop exec client -- nslookup inventory.books.svc.cluster.test.kubectl --kubeconfig ./lab.kubeconfig --context dns-study -n books get svc inventory -o yamlkubectl --kubeconfig ./lab.kubeconfig --context dns-study -n books get endpointslices -l kubernetes.io/service-name=inventory -o yamlkubectl --kubeconfig ./lab.kubeconfig --context dns-study -n books get pods -l app=inventory --show-labelsWork from the evidence, not the symptom
Suppose DNS returns 10.96.0.40 and there are zero ready endpoints. Inspect selectors and readiness next, not resolver settings. Suppose the absolute internal name times out but a previously authorized direct backend request succeeds: inspect DNS Service reachability and DNS server health, while considering policy and client configuration. Suppose a positive lookup and ready backend are both present, and the direct backend request succeeds while the Service request fails: inspect Service port mapping and the dataplane. A failing direct request could also be caused by policy or network paths; it is not a reason to restart all DNS Pods.
Practice with diagnostic cases
Use dns-observations.json, endpoint-slice.json and service.yaml. Identify the next observation for each case rather than claiming a root cause. For the ready backend, write the Service and direct backend host/port pairs and explain the difference. Compare a timeout against a valid NXDOMAIN response. Keep all tests offline unless a separate lab is approved.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Endpoint and DNS troubleshooting — knowledge check
Interpret synthetic DNS and Service evidence.
The inventory Service name resolves but all endpoints are explicitly unready. What is the next useful check?
Which observation indicates that no usable DNS response arrived by the client deadline?
An IPv4-only Service has an A record but no AAAA answer. What is a plausible observation?
What identifies EndpointSlices associated with the inventory Service?
The Service port is 80 and the ready endpoint port is 8080. Which direct destination is correct in the fixture?