The NodePort service
NodePort is a Kubernetes service type designed to make Pods reachable from a port available on the host machine, the worker node. In this section, we're going to discover this type of port and be fully focused on NodePort services!
Why do you need NodePort services?
The first thing to understand is that NodePort services allow us to access a Pod running on a Kubernetes node, on a port of the node itself. After you expose Pods using the NodePort type service, you'll be able to reach the Pods by getting the IP address of the node and the port of the NodePort service such as <node_ip_address>:<node port>
The port can be declared in your YAML declaration or can get the random port assigned by Kubernetes.Let's illustrate all of this by declaring some Kubernetes objects.
Most of the time, the NodePort service is used as an entry point to your Kubernetes cluster. In the following example, We will create two Pods based on the containous/whoami...