Loading

Quipoin Menu

Learn • Practice • Grow

kubernetes / NodePort Service
tutorial

NodePort Service

Sometimes you need to access a Service from outside the Kubernetes cluster. NodePort is a simple way to do that without a cloud load balancer. It opens a specific port on every Node and forwards traffic to the Service.

What Is NodePort?

A NodePort Service exposes the Service on a static port (between 30000-32767) on each Node’s IP address. Traffic hitting that port is forwarded to the Service’s ClusterIP and then to the Pods.

NodePort makes a Service accessible from outside the cluster using <NodeIP>:<NodePort>.

NodePort YAML Example

Here’s a Service that exposes an Nginx Deployment on NodePort 30080:
apiVersion: v1
kind: Service
metadata:
name: nginx-nodeport
spec:
type: NodePort
selector:
app: nginx
ports:
- port: 80 # Service port
targetPort: 80 # Container port
nodePort: 30080 # Node port (optional, if omitted Kubernetes assigns one)
Apply it:
kubectl apply -f nginx-nodeport.yaml

Accessing the Service

Find the Node’s IP (if using Minikube, use minikube ip). Then open a browser: http://<node-ip>:30080.

If you’re on Minikube, you can also use:
minikube service nginx-nodeport
This automatically opens the correct URL.

Advantages and Disadvantages

  • Pros: Simple, works on any cluster (including bare metal and Minikube).
  • Cons: NodePort range is limited (30000-32767), and you need to manage the Node IPs manually. Not ideal for production (prefer LoadBalancer or Ingress).


Two Minute Drill
  • NodePort exposes a Service on each Node’s IP at a static port (30000-32767).
  • Set type: NodePort and optionally nodePort.
  • Access from outside: <NodeIP>:<nodePort>.
  • Good for testing or simple external access, but not production‑grade.

Need more clarification?

Drop us an email at career@quipoinfotech.com