Interview's MateKubernetes
Interview's Mate

Kubernetes

K8s · Workloads · GitOps · Cloud

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
Kubernetes topics
Lesson 48/ 160
03. Kubernetes Networking & Traffic Management

CoreDNS & Internal Service Discovery (service.namespace.svc.cluster.local)

Resolve in-cluster DNS names through CoreDNS and the cluster.local zone.

BeginnerCoreDNS · cluster.local · Discovery3 quiz questions
Practice DevOps Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidQuiz (3)Practice

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.local and 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

Loading interactive 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.

Verify cluster.local, not only object creation

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.

Key takeaway: CoreDNS is implemented only when this invariant remains observable: 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.

Recover from cluster.local drift

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.

Key takeaway: Accept the trade-off consciously: In-cluster DNS centralizes discovery, but every missed cache or resolver timeout fans out through CoreDNS and the Service datapath.

How it works, step by step

Step 1 of 4
Traffic author

1. 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.

CoreDNS contract → owned state
Key numbers at this step
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.local in 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.local first: 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

Built-in API path
Best for: Resolve in-cluster DNS names through CoreDNS and the cluster.local zone. A concrete incident check is 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.

Datapath-specific extension
Best for: Quickly testing the cluster.local assumption with 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.

Managed ingress or mesh
Best for: Teams that need Discovery integrated with guardrails; the evidence path is 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.local without 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?
Interview tip: Interview sequence: state the invariant, run 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

Loading quiz

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.

Open DevOps Q&A →Tech Learn Q&A
Previous topic
ExternalName & Headless Services (clusterIP: None)
Next topic
EndpointSlices & High-Scale Service Routing