CoreDNS & Internal Service Discovery (service.namespace.svc.cluster.local)
Resolve in-cluster DNS names through CoreDNS and the cluster.local zone.
In plain words
CoreDNS is the cluster directory desk that expands short names using the caller's neighborhood and building rules. The simple Kubernetes rule is: CoreDNS serves the cluster DNS zone, answering Service and Pod queries and applying search suffixes so service.namespace.svc.cluster.local names can be abbreviated inside namespaces.
Think of it like…
CoreDNS is the cluster directory desk that expands short names using the caller's neighborhood and building rules.
Where you’ve seen it
During a connectivity incident, the network owner runs kubectl get svc -n kube-system kube-dns; kubectl exec dns-test -- nslookup api.prod.svc.cluster.local. Expected evidence: CoreDNS serves the cluster DNS zone, answering Service and Pod queries and applying search suffixes so service.namespace.svc.cluster.local names can be abbreviated inside namespaces. If the run instead shows this symptom, stop and restore the last known state: An ndots count, broad search list, overloaded CoreDNS Pods, or missing UDP/TCP permissions can multiply external lookups or cause intermittent NXDOMAIN and timeout responses.
Words you’ll hear
- CoreDNS
- For this lesson, CoreDNS is the controlling idea: CoreDNS serves the cluster DNS zone, answering Service and Pod queries and applying search suffixes so service.namespace.svc.cluster.local names can be abbreviated inside namespaces.
- cluster.local
- cluster.local is the checkpoint; run
kubectl get svc -n kube-system kube-dns; kubectl exec dns-test -- nslookup api.prod.svc.cluster.localand inspect the owner chain. An ndots count, broad search list, overloaded CoreDNS Pods, or missing UDP/TCP permissions can multiply external lookups or cause intermittent NXDOMAIN and timeout responses. - Discovery
- Discovery is the outcome to preserve; the cost is explicit: In-cluster DNS centralizes discovery, but every missed cache or resolver timeout fans out through CoreDNS and the Service datapath.
- Verification evidence
- The evidence command is
kubectl get svc -n kube-system kube-dns; kubectl exec dns-test -- nslookup api.prod.svc.cluster.local. It connects the declaration to this behavior: Resolve in-cluster DNS names through CoreDNS and the cluster.local zone.
Visual diagram
Theory & deep dive
How CoreDNS reaches the intended state
Resolve in-cluster DNS names through CoreDNS and the cluster.local zone. CoreDNS serves the cluster DNS zone, answering Service and Pod queries and applying search suffixes so service.namespace.svc.cluster.local names can be abbreviated inside namespaces.
The concrete checkpoint is kubectl get svc -n kube-system kube-dns; kubectl exec dns-test -- nslookup api.prod.svc.cluster.local; compare the CoreDNS owner, cluster.local state, and Discovery outcome instead of treating YAML acceptance as proof.
Run kubectl get svc -n kube-system kube-dns; kubectl exec dns-test -- nslookup api.prod.svc.cluster.local after the change and correlate the result with Events and the owning object. CoreDNS serves the cluster DNS zone, answering Service and Pod queries and applying search suffixes so service.namespace.svc.cluster.local names can be abbreviated inside namespaces.
cluster.local: failure boundary and production cost
An ndots count, broad search list, overloaded CoreDNS Pods, or missing UDP/TCP permissions can multiply external lookups or cause intermittent NXDOMAIN and timeout responses. The prerequisite contract is concrete: CoreDNS serves the cluster DNS zone, answering Service and Pod queries and applying search suffixes so service.namespace.svc.cluster.local names can be abbreviated inside namespaces.
In-cluster DNS centralizes discovery, but every missed cache or resolver timeout fans out through CoreDNS and the Service datapath. A safe design limits blast radius, records the last good configuration, and uses kubectl get svc -n kube-system kube-dns; kubectl exec dns-test -- nslookup api.prod.svc.cluster.local as a deterministic rollback checkpoint.
Capture the current state with kubectl get svc -n kube-system kube-dns; kubectl exec dns-test -- nslookup api.prod.svc.cluster.local, then correct the controlling manifest rather than patching a child object; the relevant divergence signal is specific: An ndots count, broad search list, overloaded CoreDNS Pods, or missing UDP/TCP permissions can multiply external lookups or cause intermittent NXDOMAIN and timeout responses.
How it works, step by step
Step 1 of 41. Define the reachability contract
Declare selectors, listeners, routes, or policy and keep endpoint readiness explicit: CoreDNS serves the cluster DNS zone, answering Service and Pod queries and applying search suffixes so service.namespace.svc.cluster.local names can be abbreviated inside namespaces.
- Goal
- Resolve in-cluster DNS names through CoreDNS and the cluster.local zone.
- Owner
- CoreDNS
When to use it & trade-offs
What it is
Resolve in-cluster DNS names through CoreDNS and the cluster.local zone. CoreDNS serves the cluster DNS zone, answering Service and Pod queries and applying search suffixes so service.namespace.svc.cluster.local names can be abbreviated inside namespaces.
Why it matters: An ndots count, broad search list, overloaded CoreDNS Pods, or missing UDP/TCP permissions can multiply external lookups or cause intermittent NXDOMAIN and timeout responses. The invariant at risk is specific: CoreDNS serves the cluster DNS zone, answering Service and Pod queries and applying search suffixes so service.namespace.svc.cluster.local names can be abbreviated inside namespaces. The quickest fact check before changing the design is kubectl get svc -n kube-system kube-dns; kubectl exec dns-test -- nslookup api.prod.svc.cluster.local.
When to reach for it
- Use CoreDNS to enforce this invariant: CoreDNS serves the cluster DNS zone, answering Service and Pod queries and applying search suffixes so service.namespace.svc.cluster.local names can be abbreviated inside namespaces.
- Use cluster.local evidence from
kubectl get svc -n kube-system kube-dns; kubectl exec dns-test -- nslookup api.prod.svc.cluster.localin reviews and incident timelines. Resolve in-cluster DNS names through CoreDNS and the cluster.local zone. - Choose the managed ingress or mesh route only when this cost is justified by governance or scale: In-cluster DNS centralizes discovery, but every missed cache or resolver timeout fans out through CoreDNS and the Service datapath.
When to avoid or be careful
- Avoid assuming CoreDNS is complete after YAML submission; the required behavior is concrete: CoreDNS serves the cluster DNS zone, answering Service and Pod queries and applying search suffixes so service.namespace.svc.cluster.local names can be abbreviated inside namespaces.
- Avoid treating the next symptom as random; check the owner and state with
kubectl get svc -n kube-system kube-dns; kubectl exec dns-test -- nslookup api.prod.svc.cluster.localfirst: An ndots count, broad search list, overloaded CoreDNS Pods, or missing UDP/TCP permissions can multiply external lookups or cause intermittent NXDOMAIN and timeout responses. - Avoid adopting a heavier platform wrapper before measuring its cost: In-cluster DNS centralizes discovery, but every missed cache or resolver timeout fans out through CoreDNS and the Service datapath.
Native, manual, and managed paths for CoreDNS
kubectl get svc -n kube-system kube-dns; kubectl exec dns-test -- nslookup api.prod.svc.cluster.local.Strengths: CoreDNS serves the cluster DNS zone, answering Service and Pod queries and applying search suffixes so service.namespace.svc.cluster.local names can be abbreviated inside namespaces.
Watch out: In-cluster DNS centralizes discovery, but every missed cache or resolver timeout fans out through CoreDNS and the Service datapath. Recovery must also recognize this signal: An ndots count, broad search list, overloaded CoreDNS Pods, or missing UDP/TCP permissions can multiply external lookups or cause intermittent NXDOMAIN and timeout responses.
kubectl get svc -n kube-system kube-dns; kubectl exec dns-test -- nslookup api.prod.svc.cluster.local; the expected invariant is: CoreDNS serves the cluster DNS zone, answering Service and Pod queries and applying search suffixes so service.namespace.svc.cluster.local names can be abbreviated inside namespaces.Strengths: kubectl get svc -n kube-system kube-dns; kubectl exec dns-test -- nslookup api.prod.svc.cluster.local gives immediate feedback without first building a platform layer.
Watch out: A manual change can hide drift, and unlike CoreDNS, it does not make this symptom self-documenting: An ndots count, broad search list, overloaded CoreDNS Pods, or missing UDP/TCP permissions can multiply external lookups or cause intermittent NXDOMAIN and timeout responses.
kubectl get svc -n kube-system kube-dns; kubectl exec dns-test -- nslookup api.prod.svc.cluster.local.Strengths: Platform controls can wrap this exact behavior in policy or dashboards: CoreDNS serves the cluster DNS zone, answering Service and Pod queries and applying search suffixes so service.namespace.svc.cluster.local names can be abbreviated inside namespaces.
Watch out: The added platform ownership buys value at this cost: In-cluster DNS centralizes discovery, but every missed cache or resolver timeout fans out through CoreDNS and the Service datapath.
Interview signals & numbers to know
When this topic comes up
- Interview anchor: CoreDNS serves the cluster DNS zone, answering Service and Pod queries and applying search suffixes so service.namespace.svc.cluster.local names can be abbreviated inside namespaces.
- Trace CoreDNS to Discovery through cluster.local; the invariant is: CoreDNS serves the cluster DNS zone, answering Service and Pod queries and applying search suffixes so service.namespace.svc.cluster.local names can be abbreviated inside namespaces.
- Recognize the symptom: An ndots count, broad search list, overloaded CoreDNS Pods, or missing UDP/TCP permissions can multiply external lookups or cause intermittent NXDOMAIN and timeout responses.
- Justify the cost: In-cluster DNS centralizes discovery, but every missed cache or resolver timeout fans out through CoreDNS and the Service datapath.
- Verify with kubectl get svc -n kube-system kube-dns; kubectl exec dns-test -- nslookup api.prod.svc.cluster.local instead of only inspecting YAML.
Benchmarks & rules of thumb
- 5
- default DNS search ndots threshold in many Pod resolver files
- 2
- query transports to preserve: UDP and TCP
- 53
- standard DNS port served by CoreDNS Pods
Common mistakes & follow-ups
Common interview mistakes
- Debugging only the child object misses the CoreDNS owner contract: CoreDNS serves the cluster DNS zone, answering Service and Pod queries and applying search suffixes so service.namespace.svc.cluster.local names can be abbreviated inside namespaces.
- Ignoring this telltale condition leads to unrelated changes: An ndots count, broad search list, overloaded CoreDNS Pods, or missing UDP/TCP permissions can multiply external lookups or cause intermittent NXDOMAIN and timeout responses.
- Repeating
kubectl get svc -n kube-system kube-dns; kubectl exec dns-test -- nslookup api.prod.svc.cluster.localwithout an owner for remediation wastes retry cost. In-cluster DNS centralizes discovery, but every missed cache or resolver timeout fans out through CoreDNS and the Service datapath.
Likely interviewer follow-ups
- How would API output and runtime evidence prove this behavior: CoreDNS serves the cluster DNS zone, answering Service and Pod queries and applying search suffixes so service.namespace.svc.cluster.local names can be abbreviated inside namespaces?
- Which owner object, logs, and Events would you inspect for this symptom-An ndots count, broad search list, overloaded CoreDNS Pods, or missing UDP/TCP permissions can multiply external lookups or cause intermittent NXDOMAIN and timeout responses-?
- At what threshold would this cost become unacceptable: In-cluster DNS centralizes discovery, but every missed cache or resolver timeout fans out through CoreDNS and the Service datapath?
kubectl get svc -n kube-system kube-dns; kubectl exec dns-test -- nslookup api.prod.svc.cluster.local, name the failure, then justify the cost. Invariant: CoreDNS serves the cluster DNS zone, answering Service and Pod queries and applying search suffixes so service.namespace.svc.cluster.local names can be abbreviated inside namespaces. Failure: An ndots count, broad search list, overloaded CoreDNS Pods, or missing UDP/TCP permissions can multiply external lookups or cause intermittent NXDOMAIN and timeout responses. Cost: In-cluster DNS centralizes discovery, but every missed cache or resolver timeout fans out through CoreDNS and the Service datapath.Knowledge check
Put it into practice
Practice related interview Q&A
Apply CoreDNS & Internal Service Discovery (service.namespace.svc.cluster.local) with generative AI interview Q&A and hands-on practice.