Kubernetes 101: Services -NodePort-
A service is a kubernetes object that has a fixed IP address and port. It is the link to a group of pods that offer the same service (web server for example).
Programs like web clients connect to the service and get their requests forwarded to the right pod.
The service server handle the networking and the communication between the different components of kubernetes as well as the communication with the outside world.
The nodePort service allows programs from outside the cluster to talk to the application inside the Pod through a port on the node (30033) in our example. The service then forwards the packets to a port (target port) on the Pod (300) where the applications is listening to requests.
When we create a nodePort service, kubernetes reserves the same port number on all the nodes
Pod Network : it is an internal network that makes it possible for Pods to communicate on any mode. Kubernetes allocates an internal IP address to each node.
Three port types:
Port on the node (Nodeport) : 30033, we use it to access the application in the Pod form the outside.
Port on the service : The service server (in red in the above diagram) has an IP address (cluster IP of the service) -10.3.11.5 and a port 82 in our example, it could be considered as a virtual server inside the node.
Port on the Pod (Target port) : 300 and 301.
Nodeport services (the above diagram): exposes pods to external requests.
Cluster IP services: accessible only from within the kubernetes cluster.
Load-balancer services: accessible from outside the kubernetes cluster.