Kubernetes 101 : NodePort, clusterIP and LoadBalancer services

A nodePort service makes the kubernetes worker nodes reachable from the outside on fixed port. 
The fixed port makes the node accessible to outside requests.

When we create a nodePort service, a clusterIP service that will receive the request from this nodePort is automatically created by kubernetes.

Below is the Yaml configuration file for the above nodePort service, We can see the ports defined in the below Yaml file in the above diagram:

We can display our nodePort service using the below command:

The nodePort service can run over all the worker nodes.
This schema opens the same port "31500" on all the worker nodes, so the client will have access to  all the worker nodes through the nodePort.

The loadBalancer:

To avoid opening ports on all worker nodes for outside requests, we create a loadBalancer service that lives in the cloud (AWS, Azure, ...) and have access to kubernetes nodes only though a specific port defined in its configuration file.

When we create a loadBalancer, kubernetes creates a nodePort and a clusterIP service to receive the loadbalancer's requests.

Below is the Yaml configuration file of the loadBalancer:

The loadbalancer could be considered
 as an improved version of the nodePort service.


The nodePort service is a clusterIP service that is accessible from outside of the node.


Leave as a comment: