05/09/2025

K8s- Service NodePort

A static IP address thats attached to each Pod so that when pod dies a new one comes with a new IP address but Service is attached so other applications (pods) will keep accessing it.

NodePort

A service can also listen to a port on the node and forward request on that port to a port on the pod running.

The structure of NodePort is as below

In this structure the selector is missing.

So the “Target Port” is the port on the pod, “port” is the port on the Service and “NodePort” is the port on the Node. These names are from the POV of Service. But as you see the service has also its own IP this is called the “cluster IP of the service“.
Here is the full service definition yaml file

LoadBalancer

If the service is a multinode load balancer NodePort it will look like this