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

NodePort & LoadBalancer Services (Cloud Load Balancer Integration)

Publish services externally with NodePort or cloud LoadBalancer integrations.

BeginnerNodePort · LoadBalancer · Cloud LB3 quiz questions
Practice DevOps Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidQuiz (3)Practice

In plain words

NodePort is every branch office opening the same side door, while LoadBalancer places a public receptionist in front of all branches. The simple Kubernetes rule is: NodePort exposes a Service on every node's assigned port, while a cloud LoadBalancer Service usually creates an external balancer and routes its listeners toward those node or Pod targets.

Think of it like…

NodePort is every branch office opening the same side door, while LoadBalancer places a public receptionist in front of all branches.

Where you’ve seen it

During a connectivity incident, the network owner runs kubectl get svc api -o wide; kubectl describe svc api. Expected evidence: NodePort exposes a Service on every node's assigned port, while a cloud LoadBalancer Service usually creates an external balancer and routes its listeners toward those node or Pod targets. If the run instead shows this symptom, stop and restore the last known state: Firewall rules, health checks, provider quotas, and externalTrafficPolicy can create a provisioned address that still reaches no ready backend.

Words you’ll hear

NodePort
For this lesson, NodePort is the controlling idea: NodePort exposes a Service on every node's assigned port, while a cloud LoadBalancer Service usually creates an external balancer and routes its listeners toward those node or Pod targets.
LoadBalancer
LoadBalancer is the checkpoint; run kubectl get svc api -o wide; kubectl describe svc api and inspect the owner chain. Firewall rules, health checks, provider quotas, and externalTrafficPolicy can create a provisioned address that still reaches no ready backend.
Cloud LB
Cloud LB is the outcome to preserve; the cost is explicit: LoadBalancer services are simple to request but often consume one cloud load balancer per object and leak provider-specific behavior into portable manifests.
Verification evidence
The evidence command is kubectl get svc api -o wide; kubectl describe svc api. It connects the declaration to this behavior: Publish services externally with NodePort or cloud LoadBalancer integrations.

Visual diagram

Loading interactive diagram

Theory & deep dive

How NodePort reaches the intended state

Publish services externally with NodePort or cloud LoadBalancer integrations. NodePort exposes a Service on every node's assigned port, while a cloud LoadBalancer Service usually creates an external balancer and routes its listeners toward those node or Pod targets.

The concrete checkpoint is kubectl get svc api -o wide; kubectl describe svc api; compare the NodePort owner, LoadBalancer state, and Cloud LB outcome instead of treating YAML acceptance as proof.

Verify LoadBalancer, not only object creation

Run kubectl get svc api -o wide; kubectl describe svc api after the change and correlate the result with Events and the owning object. NodePort exposes a Service on every node's assigned port, while a cloud LoadBalancer Service usually creates an external balancer and routes its listeners toward those node or Pod targets.

Key takeaway: NodePort is implemented only when this invariant remains observable: NodePort exposes a Service on every node's assigned port, while a cloud LoadBalancer Service usually creates an external balancer and routes its listeners toward those node or Pod targets.

LoadBalancer: failure boundary and production cost

Firewall rules, health checks, provider quotas, and externalTrafficPolicy can create a provisioned address that still reaches no ready backend. The prerequisite contract is concrete: NodePort exposes a Service on every node's assigned port, while a cloud LoadBalancer Service usually creates an external balancer and routes its listeners toward those node or Pod targets.

LoadBalancer services are simple to request but often consume one cloud load balancer per object and leak provider-specific behavior into portable manifests. A safe design limits blast radius, records the last good configuration, and uses kubectl get svc api -o wide; kubectl describe svc api as a deterministic rollback checkpoint.

Recover from LoadBalancer drift

Capture the current state with kubectl get svc api -o wide; kubectl describe svc api, then correct the controlling manifest rather than patching a child object; the relevant divergence signal is specific: Firewall rules, health checks, provider quotas, and externalTrafficPolicy can create a provisioned address that still reaches no ready backend.

Key takeaway: Accept the trade-off consciously: LoadBalancer services are simple to request but often consume one cloud load balancer per object and leak provider-specific behavior into portable manifests.

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: NodePort exposes a Service on every node's assigned port, while a cloud LoadBalancer Service usually creates an external balancer and routes its listeners toward those node or Pod targets.

NodePort contract → owned state
Key numbers at this step
Goal
Publish services externally with NodePort or cloud LoadBalancer integrations.
Owner
NodePort

When to use it & trade-offs

What it is

Publish services externally with NodePort or cloud LoadBalancer integrations. NodePort exposes a Service on every node's assigned port, while a cloud LoadBalancer Service usually creates an external balancer and routes its listeners toward those node or Pod targets.

Why it matters: Firewall rules, health checks, provider quotas, and externalTrafficPolicy can create a provisioned address that still reaches no ready backend. The invariant at risk is specific: NodePort exposes a Service on every node's assigned port, while a cloud LoadBalancer Service usually creates an external balancer and routes its listeners toward those node or Pod targets. The quickest fact check before changing the design is kubectl get svc api -o wide; kubectl describe svc api.

When to reach for it

  • Use NodePort to enforce this invariant: NodePort exposes a Service on every node's assigned port, while a cloud LoadBalancer Service usually creates an external balancer and routes its listeners toward those node or Pod targets.
  • Use LoadBalancer evidence from kubectl get svc api -o wide; kubectl describe svc api in reviews and incident timelines. Publish services externally with NodePort or cloud LoadBalancer integrations.
  • Choose the managed ingress or mesh route only when this cost is justified by governance or scale: LoadBalancer services are simple to request but often consume one cloud load balancer per object and leak provider-specific behavior into portable manifests.

When to avoid or be careful

  • Avoid assuming NodePort is complete after YAML submission; the required behavior is concrete: NodePort exposes a Service on every node's assigned port, while a cloud LoadBalancer Service usually creates an external balancer and routes its listeners toward those node or Pod targets.
  • Avoid treating the next symptom as random; check the owner and state with kubectl get svc api -o wide; kubectl describe svc api first: Firewall rules, health checks, provider quotas, and externalTrafficPolicy can create a provisioned address that still reaches no ready backend.
  • Avoid adopting a heavier platform wrapper before measuring its cost: LoadBalancer services are simple to request but often consume one cloud load balancer per object and leak provider-specific behavior into portable manifests.

Native, manual, and managed paths for NodePort

Built-in API path
Best for: Publish services externally with NodePort or cloud LoadBalancer integrations. A concrete incident check is kubectl get svc api -o wide; kubectl describe svc api.

Strengths: NodePort exposes a Service on every node's assigned port, while a cloud LoadBalancer Service usually creates an external balancer and routes its listeners toward those node or Pod targets.

Watch out: LoadBalancer services are simple to request but often consume one cloud load balancer per object and leak provider-specific behavior into portable manifests. Recovery must also recognize this signal: Firewall rules, health checks, provider quotas, and externalTrafficPolicy can create a provisioned address that still reaches no ready backend.

Datapath-specific extension
Best for: Quickly testing the LoadBalancer assumption with kubectl get svc api -o wide; kubectl describe svc api; the expected invariant is: NodePort exposes a Service on every node's assigned port, while a cloud LoadBalancer Service usually creates an external balancer and routes its listeners toward those node or Pod targets.

Strengths: kubectl get svc api -o wide; kubectl describe svc api gives immediate feedback without first building a platform layer.

Watch out: A manual change can hide drift, and unlike NodePort, it does not make this symptom self-documenting: Firewall rules, health checks, provider quotas, and externalTrafficPolicy can create a provisioned address that still reaches no ready backend.

Managed ingress or mesh
Best for: Teams that need Cloud LB integrated with guardrails; the evidence path is kubectl get svc api -o wide; kubectl describe svc api.

Strengths: Platform controls can wrap this exact behavior in policy or dashboards: NodePort exposes a Service on every node's assigned port, while a cloud LoadBalancer Service usually creates an external balancer and routes its listeners toward those node or Pod targets.

Watch out: The added platform ownership buys value at this cost: LoadBalancer services are simple to request but often consume one cloud load balancer per object and leak provider-specific behavior into portable manifests.

Interview signals & numbers to know

When this topic comes up

  • Interview anchor: NodePort exposes a Service on every node's assigned port, while a cloud LoadBalancer Service usually creates an external balancer and routes its listeners toward those node or Pod targets.
  • Trace NodePort to Cloud LB through LoadBalancer; the invariant is: NodePort exposes a Service on every node's assigned port, while a cloud LoadBalancer Service usually creates an external balancer and routes its listeners toward those node or Pod targets.
  • Recognize the symptom: Firewall rules, health checks, provider quotas, and externalTrafficPolicy can create a provisioned address that still reaches no ready backend.
  • Justify the cost: LoadBalancer services are simple to request but often consume one cloud load balancer per object and leak provider-specific behavior into portable manifests.
  • Verify with kubectl get svc api -o wide; kubectl describe svc api instead of only inspecting YAML.

Benchmarks & rules of thumb

30000 -
default start of the NodePort allocation range
32767 -
default end of the NodePort allocation range
2 -
traffic policies are Cluster and Local

Common mistakes & follow-ups

Common interview mistakes

  • Debugging only the child object misses the NodePort owner contract: NodePort exposes a Service on every node's assigned port, while a cloud LoadBalancer Service usually creates an external balancer and routes its listeners toward those node or Pod targets.
  • Ignoring this telltale condition leads to unrelated changes: Firewall rules, health checks, provider quotas, and externalTrafficPolicy can create a provisioned address that still reaches no ready backend.
  • Repeating kubectl get svc api -o wide; kubectl describe svc api without an owner for remediation wastes retry cost. LoadBalancer services are simple to request but often consume one cloud load balancer per object and leak provider-specific behavior into portable manifests.

Likely interviewer follow-ups

  • How would API output and runtime evidence prove this behavior: NodePort exposes a Service on every node's assigned port, while a cloud LoadBalancer Service usually creates an external balancer and routes its listeners toward those node or Pod targets?
  • Which owner object, logs, and Events would you inspect for this symptom-Firewall rules, health checks, provider quotas, and externalTrafficPolicy can create a provisioned address that still reaches no ready backend-?
  • At what threshold would this cost become unacceptable: LoadBalancer services are simple to request but often consume one cloud load balancer per object and leak provider-specific behavior into portable manifests?
Interview tip: Interview sequence: state the invariant, run kubectl get svc api -o wide; kubectl describe svc api, name the failure, then justify the cost. Invariant: NodePort exposes a Service on every node's assigned port, while a cloud LoadBalancer Service usually creates an external balancer and routes its listeners toward those node or Pod targets. Failure: Firewall rules, health checks, provider quotas, and externalTrafficPolicy can create a provisioned address that still reaches no ready backend. Cost: LoadBalancer services are simple to request but often consume one cloud load balancer per object and leak provider-specific behavior into portable manifests.

Knowledge check

Loading quiz

Put it into practice

Practice related interview Q&A

Apply NodePort & LoadBalancer Services (Cloud Load Balancer Integration) with generative AI interview Q&A and hands-on practice.

Open DevOps Q&A →Tech Learn Q&A
Previous topic
ClusterIP Services & Virtual IP Routing (iptables vs IPVS)
Next topic
ExternalName & Headless Services (clusterIP: None)