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 44/ 160
03. Kubernetes Networking & Traffic Management

Services Overview: Decoupling Pods from Dynamic IPs

Expose stable virtual IPs and DNS names in front of changing pod endpoints.

BeginnerService · VIP · Selectors3 quiz questions
Practice DevOps Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidQuiz (3)Practice

In plain words

A Service is a durable reception number that keeps forwarding callers to the currently open desks behind it. The simple Kubernetes rule is: A Service selects ready backing Pods through labels, advertises a stable DNS name and virtual address, and updates EndpointSlices as Pods change IPs.

Think of it like…

A Service is a durable reception number that keeps forwarding callers to the currently open desks behind it.

Where you’ve seen it

During a connectivity incident, the network owner runs kubectl get svc,endpointslice -l app=api; kubectl get endpoints api. Expected evidence: A Service selects ready backing Pods through labels, advertises a stable DNS name and virtual address, and updates EndpointSlices as Pods change IPs. If the run instead shows this symptom, stop and restore the last known state: A selector mismatch, unready endpoints, or a Pod listening on a different targetPort produces a Service object that exists but carries no usable path.

Words you’ll hear

Service
For this lesson, Service is the controlling idea: A Service selects ready backing Pods through labels, advertises a stable DNS name and virtual address, and updates EndpointSlices as Pods change IPs.
VIP
VIP is the checkpoint; run kubectl get svc,endpointslice -l app=api; kubectl get endpoints api and inspect the owner chain. A selector mismatch, unready endpoints, or a Pod listening on a different targetPort produces a Service object that exists but carries no usable path.
Selectors
Selectors is the outcome to preserve; the cost is explicit: Stable Service discovery hides churn, but selectors and readiness couple routing to labels and remove direct ownership of the concrete Pod instance.
Verification evidence
The evidence command is kubectl get svc,endpointslice -l app=api; kubectl get endpoints api. It connects the declaration to this behavior: Expose stable virtual IPs and DNS names in front of changing pod endpoints.

Visual diagram

Loading interactive diagram

Theory & deep dive

How Service reaches the intended state

Expose stable virtual IPs and DNS names in front of changing pod endpoints. A Service selects ready backing Pods through labels, advertises a stable DNS name and virtual address, and updates EndpointSlices as Pods change IPs.

The concrete checkpoint is kubectl get svc,endpointslice -l app=api; kubectl get endpoints api; compare the Service owner, VIP state, and Selectors outcome instead of treating YAML acceptance as proof.

Verify VIP, not only object creation

Run kubectl get svc,endpointslice -l app=api; kubectl get endpoints api after the change and correlate the result with Events and the owning object. A Service selects ready backing Pods through labels, advertises a stable DNS name and virtual address, and updates EndpointSlices as Pods change IPs.

Key takeaway: Service is implemented only when this invariant remains observable: A Service selects ready backing Pods through labels, advertises a stable DNS name and virtual address, and updates EndpointSlices as Pods change IPs.

VIP: failure boundary and production cost

A selector mismatch, unready endpoints, or a Pod listening on a different targetPort produces a Service object that exists but carries no usable path. The prerequisite contract is concrete: A Service selects ready backing Pods through labels, advertises a stable DNS name and virtual address, and updates EndpointSlices as Pods change IPs.

Stable Service discovery hides churn, but selectors and readiness couple routing to labels and remove direct ownership of the concrete Pod instance. A safe design limits blast radius, records the last good configuration, and uses kubectl get svc,endpointslice -l app=api; kubectl get endpoints api as a deterministic rollback checkpoint.

Recover from VIP drift

Capture the current state with kubectl get svc,endpointslice -l app=api; kubectl get endpoints api, then correct the controlling manifest rather than patching a child object; the relevant divergence signal is specific: A selector mismatch, unready endpoints, or a Pod listening on a different targetPort produces a Service object that exists but carries no usable path.

Key takeaway: Accept the trade-off consciously: Stable Service discovery hides churn, but selectors and readiness couple routing to labels and remove direct ownership of the concrete Pod instance.

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: A Service selects ready backing Pods through labels, advertises a stable DNS name and virtual address, and updates EndpointSlices as Pods change IPs.

Service contract → owned state
Key numbers at this step
Goal
Expose stable virtual IPs and DNS names in front of changing pod endpoints.
Owner
Service

When to use it & trade-offs

What it is

Expose stable virtual IPs and DNS names in front of changing pod endpoints. A Service selects ready backing Pods through labels, advertises a stable DNS name and virtual address, and updates EndpointSlices as Pods change IPs.

Why it matters: A selector mismatch, unready endpoints, or a Pod listening on a different targetPort produces a Service object that exists but carries no usable path. The invariant at risk is specific: A Service selects ready backing Pods through labels, advertises a stable DNS name and virtual address, and updates EndpointSlices as Pods change IPs. The quickest fact check before changing the design is kubectl get svc,endpointslice -l app=api; kubectl get endpoints api.

When to reach for it

  • Use Service to enforce this invariant: A Service selects ready backing Pods through labels, advertises a stable DNS name and virtual address, and updates EndpointSlices as Pods change IPs.
  • Use VIP evidence from kubectl get svc,endpointslice -l app=api; kubectl get endpoints api in reviews and incident timelines. Expose stable virtual IPs and DNS names in front of changing pod endpoints.
  • Choose the managed ingress or mesh route only when this cost is justified by governance or scale: Stable Service discovery hides churn, but selectors and readiness couple routing to labels and remove direct ownership of the concrete Pod instance.

When to avoid or be careful

  • Avoid assuming Service is complete after YAML submission; the required behavior is concrete: A Service selects ready backing Pods through labels, advertises a stable DNS name and virtual address, and updates EndpointSlices as Pods change IPs.
  • Avoid treating the next symptom as random; check the owner and state with kubectl get svc,endpointslice -l app=api; kubectl get endpoints api first: A selector mismatch, unready endpoints, or a Pod listening on a different targetPort produces a Service object that exists but carries no usable path.
  • Avoid adopting a heavier platform wrapper before measuring its cost: Stable Service discovery hides churn, but selectors and readiness couple routing to labels and remove direct ownership of the concrete Pod instance.

Native, manual, and managed paths for Service

Built-in API path
Best for: Expose stable virtual IPs and DNS names in front of changing pod endpoints. A concrete incident check is kubectl get svc,endpointslice -l app=api; kubectl get endpoints api.

Strengths: A Service selects ready backing Pods through labels, advertises a stable DNS name and virtual address, and updates EndpointSlices as Pods change IPs.

Watch out: Stable Service discovery hides churn, but selectors and readiness couple routing to labels and remove direct ownership of the concrete Pod instance. Recovery must also recognize this signal: A selector mismatch, unready endpoints, or a Pod listening on a different targetPort produces a Service object that exists but carries no usable path.

Datapath-specific extension
Best for: Quickly testing the VIP assumption with kubectl get svc,endpointslice -l app=api; kubectl get endpoints api; the expected invariant is: A Service selects ready backing Pods through labels, advertises a stable DNS name and virtual address, and updates EndpointSlices as Pods change IPs.

Strengths: kubectl get svc,endpointslice -l app=api; kubectl get endpoints api gives immediate feedback without first building a platform layer.

Watch out: A manual change can hide drift, and unlike Service, it does not make this symptom self-documenting: A selector mismatch, unready endpoints, or a Pod listening on a different targetPort produces a Service object that exists but carries no usable path.

Managed ingress or mesh
Best for: Teams that need Selectors integrated with guardrails; the evidence path is kubectl get svc,endpointslice -l app=api; kubectl get endpoints api.

Strengths: Platform controls can wrap this exact behavior in policy or dashboards: A Service selects ready backing Pods through labels, advertises a stable DNS name and virtual address, and updates EndpointSlices as Pods change IPs.

Watch out: The added platform ownership buys value at this cost: Stable Service discovery hides churn, but selectors and readiness couple routing to labels and remove direct ownership of the concrete Pod instance.

Interview signals & numbers to know

When this topic comes up

  • Interview anchor: A Service selects ready backing Pods through labels, advertises a stable DNS name and virtual address, and updates EndpointSlices as Pods change IPs.
  • Trace Service to Selectors through VIP; the invariant is: A Service selects ready backing Pods through labels, advertises a stable DNS name and virtual address, and updates EndpointSlices as Pods change IPs.
  • Recognize the symptom: A selector mismatch, unready endpoints, or a Pod listening on a different targetPort produces a Service object that exists but carries no usable path.
  • Justify the cost: Stable Service discovery hides churn, but selectors and readiness couple routing to labels and remove direct ownership of the concrete Pod instance.
  • Verify with kubectl get svc,endpointslice -l app=api; kubectl get endpoints api instead of only inspecting YAML.

Benchmarks & rules of thumb

1 -
stable ClusterIP normally fronts multiple Pod IPs
0 -
endpoints mean the Service has no traffic destination
2 -
ports to map carefully: port and targetPort

Common mistakes & follow-ups

Common interview mistakes

  • Debugging only the child object misses the Service owner contract: A Service selects ready backing Pods through labels, advertises a stable DNS name and virtual address, and updates EndpointSlices as Pods change IPs.
  • Ignoring this telltale condition leads to unrelated changes: A selector mismatch, unready endpoints, or a Pod listening on a different targetPort produces a Service object that exists but carries no usable path.
  • Repeating kubectl get svc,endpointslice -l app=api; kubectl get endpoints api without an owner for remediation wastes retry cost. Stable Service discovery hides churn, but selectors and readiness couple routing to labels and remove direct ownership of the concrete Pod instance.

Likely interviewer follow-ups

  • How would API output and runtime evidence prove this behavior: A Service selects ready backing Pods through labels, advertises a stable DNS name and virtual address, and updates EndpointSlices as Pods change IPs?
  • Which owner object, logs, and Events would you inspect for this symptom-A selector mismatch, unready endpoints, or a Pod listening on a different targetPort produces a Service object that exists but carries no usable path-?
  • At what threshold would this cost become unacceptable: Stable Service discovery hides churn, but selectors and readiness couple routing to labels and remove direct ownership of the concrete Pod instance?
Interview tip: Interview sequence: state the invariant, run kubectl get svc,endpointslice -l app=api; kubectl get endpoints api, name the failure, then justify the cost. Invariant: A Service selects ready backing Pods through labels, advertises a stable DNS name and virtual address, and updates EndpointSlices as Pods change IPs. Failure: A selector mismatch, unready endpoints, or a Pod listening on a different targetPort produces a Service object that exists but carries no usable path. Cost: Stable Service discovery hides churn, but selectors and readiness couple routing to labels and remove direct ownership of the concrete Pod instance.

Knowledge check

Loading quiz

Put it into practice

Practice related interview Q&A

Apply Services Overview: Decoupling Pods from Dynamic IPs with generative AI interview Q&A and hands-on practice.

Open DevOps Q&A →Tech Learn Q&A
Previous topic
eBPF Networking & Kube-Proxy Replacement with Cilium
Next topic
ClusterIP Services & Virtual IP Routing (iptables vs IPVS)