Kubernetes Service: NodePort
Expose a Service on a fixed port across every node and understand how traffic flows from outside the cluster to pods.
What Is NodePort?
A NodePort Service exposes your application on every node IP at a static port, usually in the range 30000–32767.
Traffic Flow
Service → Endpoints → Pods
Client
other pod / user
Service
my-svc:80
stable IP · DNS name
Endpoints
10.0.0.1:8080 · 10.0.0.2:8080
Pod A
Pod B
NodePort builds on top of the internal Service model. Kubernetes still load balances to matching pods.
Full YAML Example
apiVersion: v1
kind: Service
metadata:
name: web-nodeport
spec:
selector:
app: web
ports:
- port: 80
targetPort: 8080
nodePort: 30080
type: NodePort
Why It Exists
NodePort is simple and works even when you do not have a cloud load balancer. It is common in local labs and some bare-metal environments.
Limitations
| Limitation | Why it matters |
|---|---|
| High port range | Not user-friendly for public traffic |
| Node awareness | Clients need a node IP |
| Basic exposure model | Less flexible than Ingress for HTTP routing |
| Security concerns | Publicly reachable ports need careful control |
When to Use It
Use NodePort when you need quick external access for testing or when another system will route to node IPs and ports.
Think of NodePort as giving every building entrance the same special side door number. It works, but it is rarely the cleanest front entrance for users.
NodePort Range
What port range is typically used by NodePort Services?
Flow Understanding
In a NodePort setup, external traffic usually reaches pods through which chain?