In this lesson, you will learn how to make your internal Kubernetes applications reachable from outside the cluster by opening a static port on every node using the NodePort service type.
The Problem: Internal Isolation
As you learned in previous lessons, Pods are ephemeral, and ClusterIP services only provide reachability to other resources inside the cluster. If you want a user on their laptop to access your application via a browser, they cannot reach these internal IP addresses directly. This is where NodePort comes into play.
How NodePort Works
A NodePort service acts as a bridge. When you define a service as type: NodePort, Kubernetes allocates a specific port (by default, in the range 30000-32767) and opens it on every single node in your cluster.
When external traffic hits any node’s IP address on that specific port, the kube-proxy component on that node intercepts the request and routes it to one of the Pods matching your service’s label selector. You don't need to know which node your Pod is running on; the cluster-wide network will automatically forward the request to the correct destination.
Example Configuration
To expose an application, you define your service manifest like this:
apiVersion: v1
kind: Service
metadata:
name: my-app-service
spec:
type: NodePort
selector:
app: my-web-app
ports:
- port: 80 # The port other Pods use to reach this service
targetPort: 8080 # The port your container is listening on
nodePort: 30007 # The port opened on every node for external traffic
Once applied, you can access your application from your browser using any node's IP address: http://<Node-IP>:30007.
This approach is excellent for simple deployments, development environments, or proof-of-concepts where you need quick external access without configuring complex load balancers or ingress controllers. It effectively turns your cluster nodes into entry points for your traffic.
Key Takeaway: NodePort services expose your application externally by opening a designated port across all cluster nodes, automatically routing traffic to your Pods regardless of where they are physically running.