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

ClusterIP Services & Virtual IP Routing (iptables vs IPVS)

Understand ClusterIP load balancing via iptables or IPVS modes.

IntermediateClusterIP · iptables · IPVS3 quiz questions
Practice DevOps Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidQuiz (3)Practice

In plain words

ClusterIP is a forwarding desk number: iptables walks a rulebook, while IPVS looks up a compact table of real desks. The simple Kubernetes rule is: ClusterIP traffic reaches a virtual IP programmed on every node: iptables mode applies ordered packet rules, while IPVS maintains an efficient virtual-server table with real endpoints.

Think of it like…

ClusterIP is a forwarding desk number: iptables walks a rulebook, while IPVS looks up a compact table of real desks.

Where you’ve seen it

During a connectivity incident, the network owner runs kubectl get svc kubernetes; iptables-save; ipvsadm -Ln. Expected evidence: ClusterIP traffic reaches a virtual IP programmed on every node: iptables mode applies ordered packet rules, while IPVS maintains an efficient virtual-server table with real endpoints. If the run instead shows this symptom, stop and restore the last known state: A stale kube-proxy configuration, mismatched service CIDR, or host firewall rule can make the virtual IP unreachable even when direct Pod IP works.

Words you’ll hear

ClusterIP
For this lesson, ClusterIP is the controlling idea: ClusterIP traffic reaches a virtual IP programmed on every node: iptables mode applies ordered packet rules, while IPVS maintains an efficient virtual-server table with real endpoints.
iptables
iptables is the checkpoint; run kubectl get svc kubernetes; iptables-save; ipvsadm -Ln and inspect the owner chain. A stale kube-proxy configuration, mismatched service CIDR, or host firewall rule can make the virtual IP unreachable even when direct Pod IP works.
IPVS
IPVS is the outcome to preserve; the cost is explicit: Iptables is broadly available but rule chains grow, whereas IPVS scales forwarding with a kernel module and less linear-rule behavior but adds mode-specific debugging.
Verification evidence
The evidence command is kubectl get svc kubernetes; iptables-save; ipvsadm -Ln. It connects the declaration to this behavior: Understand ClusterIP load balancing via iptables or IPVS modes.

Visual diagram

Loading interactive diagram

Theory & deep dive

How ClusterIP reaches the intended state

Understand ClusterIP load balancing via iptables or IPVS modes. ClusterIP traffic reaches a virtual IP programmed on every node: iptables mode applies ordered packet rules, while IPVS maintains an efficient virtual-server table with real endpoints.

The concrete checkpoint is kubectl get svc kubernetes; iptables-save; ipvsadm -Ln; compare the ClusterIP owner, iptables state, and IPVS outcome instead of treating YAML acceptance as proof.

Verify iptables, not only object creation

Run kubectl get svc kubernetes; iptables-save; ipvsadm -Ln after the change and correlate the result with Events and the owning object. ClusterIP traffic reaches a virtual IP programmed on every node: iptables mode applies ordered packet rules, while IPVS maintains an efficient virtual-server table with real endpoints.

Key takeaway: ClusterIP is implemented only when this invariant remains observable: ClusterIP traffic reaches a virtual IP programmed on every node: iptables mode applies ordered packet rules, while IPVS maintains an efficient virtual-server table with real endpoints.

iptables: failure boundary and production cost

A stale kube-proxy configuration, mismatched service CIDR, or host firewall rule can make the virtual IP unreachable even when direct Pod IP works. The prerequisite contract is concrete: ClusterIP traffic reaches a virtual IP programmed on every node: iptables mode applies ordered packet rules, while IPVS maintains an efficient virtual-server table with real endpoints.

Iptables is broadly available but rule chains grow, whereas IPVS scales forwarding with a kernel module and less linear-rule behavior but adds mode-specific debugging. A safe design limits blast radius, records the last good configuration, and uses kubectl get svc kubernetes; iptables-save; ipvsadm -Ln as a deterministic rollback checkpoint.

Recover from iptables drift

Capture the current state with kubectl get svc kubernetes; iptables-save; ipvsadm -Ln, then correct the controlling manifest rather than patching a child object; the relevant divergence signal is specific: A stale kube-proxy configuration, mismatched service CIDR, or host firewall rule can make the virtual IP unreachable even when direct Pod IP works.

Key takeaway: Accept the trade-off consciously: Iptables is broadly available but rule chains grow, whereas IPVS scales forwarding with a kernel module and less linear-rule behavior but adds mode-specific debugging.

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: ClusterIP traffic reaches a virtual IP programmed on every node: iptables mode applies ordered packet rules, while IPVS maintains an efficient virtual-server table with real endpoints.

ClusterIP contract → owned state
Key numbers at this step
Goal
Understand ClusterIP load balancing via iptables or IPVS modes.
Owner
ClusterIP

When to use it & trade-offs

What it is

Understand ClusterIP load balancing via iptables or IPVS modes. ClusterIP traffic reaches a virtual IP programmed on every node: iptables mode applies ordered packet rules, while IPVS maintains an efficient virtual-server table with real endpoints.

Why it matters: A stale kube-proxy configuration, mismatched service CIDR, or host firewall rule can make the virtual IP unreachable even when direct Pod IP works. The invariant at risk is specific: ClusterIP traffic reaches a virtual IP programmed on every node: iptables mode applies ordered packet rules, while IPVS maintains an efficient virtual-server table with real endpoints. The quickest fact check before changing the design is kubectl get svc kubernetes; iptables-save; ipvsadm -Ln.

When to reach for it

  • Use ClusterIP to enforce this invariant: ClusterIP traffic reaches a virtual IP programmed on every node: iptables mode applies ordered packet rules, while IPVS maintains an efficient virtual-server table with real endpoints.
  • Use iptables evidence from kubectl get svc kubernetes; iptables-save; ipvsadm -Ln in reviews and incident timelines. Understand ClusterIP load balancing via iptables or IPVS modes.
  • Choose the managed ingress or mesh route only when this cost is justified by governance or scale: Iptables is broadly available but rule chains grow, whereas IPVS scales forwarding with a kernel module and less linear-rule behavior but adds mode-specific debugging.

When to avoid or be careful

  • Avoid assuming ClusterIP is complete after YAML submission; the required behavior is concrete: ClusterIP traffic reaches a virtual IP programmed on every node: iptables mode applies ordered packet rules, while IPVS maintains an efficient virtual-server table with real endpoints.
  • Avoid treating the next symptom as random; check the owner and state with kubectl get svc kubernetes; iptables-save; ipvsadm -Ln first: A stale kube-proxy configuration, mismatched service CIDR, or host firewall rule can make the virtual IP unreachable even when direct Pod IP works.
  • Avoid adopting a heavier platform wrapper before measuring its cost: Iptables is broadly available but rule chains grow, whereas IPVS scales forwarding with a kernel module and less linear-rule behavior but adds mode-specific debugging.

Native, manual, and managed paths for ClusterIP

Built-in API path
Best for: Understand ClusterIP load balancing via iptables or IPVS modes. A concrete incident check is kubectl get svc kubernetes; iptables-save; ipvsadm -Ln.

Strengths: ClusterIP traffic reaches a virtual IP programmed on every node: iptables mode applies ordered packet rules, while IPVS maintains an efficient virtual-server table with real endpoints.

Watch out: Iptables is broadly available but rule chains grow, whereas IPVS scales forwarding with a kernel module and less linear-rule behavior but adds mode-specific debugging. Recovery must also recognize this signal: A stale kube-proxy configuration, mismatched service CIDR, or host firewall rule can make the virtual IP unreachable even when direct Pod IP works.

Datapath-specific extension
Best for: Quickly testing the iptables assumption with kubectl get svc kubernetes; iptables-save; ipvsadm -Ln; the expected invariant is: ClusterIP traffic reaches a virtual IP programmed on every node: iptables mode applies ordered packet rules, while IPVS maintains an efficient virtual-server table with real endpoints.

Strengths: kubectl get svc kubernetes; iptables-save; ipvsadm -Ln gives immediate feedback without first building a platform layer.

Watch out: A manual change can hide drift, and unlike ClusterIP, it does not make this symptom self-documenting: A stale kube-proxy configuration, mismatched service CIDR, or host firewall rule can make the virtual IP unreachable even when direct Pod IP works.

Managed ingress or mesh
Best for: Teams that need IPVS integrated with guardrails; the evidence path is kubectl get svc kubernetes; iptables-save; ipvsadm -Ln.

Strengths: Platform controls can wrap this exact behavior in policy or dashboards: ClusterIP traffic reaches a virtual IP programmed on every node: iptables mode applies ordered packet rules, while IPVS maintains an efficient virtual-server table with real endpoints.

Watch out: The added platform ownership buys value at this cost: Iptables is broadly available but rule chains grow, whereas IPVS scales forwarding with a kernel module and less linear-rule behavior but adds mode-specific debugging.

Interview signals & numbers to know

When this topic comes up

  • Interview anchor: ClusterIP traffic reaches a virtual IP programmed on every node: iptables mode applies ordered packet rules, while IPVS maintains an efficient virtual-server table with real endpoints.
  • Trace ClusterIP to IPVS through iptables; the invariant is: ClusterIP traffic reaches a virtual IP programmed on every node: iptables mode applies ordered packet rules, while IPVS maintains an efficient virtual-server table with real endpoints.
  • Recognize the symptom: A stale kube-proxy configuration, mismatched service CIDR, or host firewall rule can make the virtual IP unreachable even when direct Pod IP works.
  • Justify the cost: iptables is broadly available but rule chains grow, whereas IPVS scales forwarding with a kernel module and less linear-rule behavior but adds mode-specific debugging.
  • Verify with kubectl get svc kubernetes; iptables-save; ipvsadm -Ln instead of only inspecting YAML.

Benchmarks & rules of thumb

1 -
ClusterIP virtual service is load-balanced across ready endpoints
2 -
main kube-proxy modes to contrast: iptables and IPVS
0 -
direct Pod application bind to the ClusterIP interface

Common mistakes & follow-ups

Common interview mistakes

  • Debugging only the child object misses the ClusterIP owner contract: ClusterIP traffic reaches a virtual IP programmed on every node: iptables mode applies ordered packet rules, while IPVS maintains an efficient virtual-server table with real endpoints.
  • Ignoring this telltale condition leads to unrelated changes: A stale kube-proxy configuration, mismatched service CIDR, or host firewall rule can make the virtual IP unreachable even when direct Pod IP works.
  • Repeating kubectl get svc kubernetes; iptables-save; ipvsadm -Ln without an owner for remediation wastes retry cost. Iptables is broadly available but rule chains grow, whereas IPVS scales forwarding with a kernel module and less linear-rule behavior but adds mode-specific debugging.

Likely interviewer follow-ups

  • How would API output and runtime evidence prove this behavior: ClusterIP traffic reaches a virtual IP programmed on every node: iptables mode applies ordered packet rules, while IPVS maintains an efficient virtual-server table with real endpoints?
  • Which owner object, logs, and Events would you inspect for this symptom-A stale kube-proxy configuration, mismatched service CIDR, or host firewall rule can make the virtual IP unreachable even when direct Pod IP works-?
  • At what threshold would this cost become unacceptable: iptables is broadly available but rule chains grow, whereas IPVS scales forwarding with a kernel module and less linear-rule behavior but adds mode-specific debugging?
Interview tip: Interview sequence: state the invariant, run kubectl get svc kubernetes; iptables-save; ipvsadm -Ln, name the failure, then justify the cost. Invariant: ClusterIP traffic reaches a virtual IP programmed on every node: iptables mode applies ordered packet rules, while IPVS maintains an efficient virtual-server table with real endpoints. Failure: A stale kube-proxy configuration, mismatched service CIDR, or host firewall rule can make the virtual IP unreachable even when direct Pod IP works. Cost: Iptables is broadly available but rule chains grow, whereas IPVS scales forwarding with a kernel module and less linear-rule behavior but adds mode-specific debugging.

Knowledge check

Loading quiz

Put it into practice

Practice related interview Q&A

Apply ClusterIP Services & Virtual IP Routing (iptables vs IPVS) with generative AI interview Q&A and hands-on practice.

Open DevOps Q&A →Tech Learn Q&A
Previous topic
Services Overview: Decoupling Pods from Dynamic IPs
Next topic
NodePort & LoadBalancer Services (Cloud Load Balancer Integration)