The below deployment "nginx-dep" manages two "nginx" pod replicas:


To check our pods, we use the below command:


A nodePort service makes the application running inside the pods accessible from the outside on the same port on all the nodes of the cluster.
The nodePort service has access to all the nodes of the cluster.


Below is a Yaml file of a nodePort service:


  • TargetPort: it exposes the application running inside the pod. The nodePort service forwards the requests to that port.
  • Port: the port on which the service is accessed.
  • NodePort: the open port on the node.


we could also use the command line to create our nodePort service as below:


It creates a nodePort service called "nginx-service", that exposes the application running inside the pods managed by the deployment "nginx-dep".

A nodePort port is automatically created for our nodePort service. We could check it using the below command:


We can access the "nginx" pods using the external  IP address of the nodes shown below:


We could also check the external IP of the nodes in the Yaml file of the nodes, using the below command:


To be able to see the endpoints of our nodePort service - ip addresses of the pods that the service represents -, we use the below command:

Brando Sabatini and Ikbal C ©. Powered by Blogger.