Kubernetes Services
--
Kubernetes services enable communication between various components within and outside of the application. Kubernetes services helps us connect applications together with other applications or users. Lets assume our application has groups of pods running various sections such as a group for serving our front end load to users and other group for running back end processes. Then third group connecting to an external data source.
It is services that enable connectivity between these groups of pods. Services enable the front end application to be made available to end users. It helps communication between back end and front end pods and helps in establishing connectivity to an external data source.
Lets further discuss one use case of services. We deployed our pod having a web application running on it. How do external users access the web page?
The Kubernetes node has an IP address and that is 192.168.1.2 and the host machine is on the same network. It has an IP address 192.168.1.10. The internal pod network is in 10.244.0.0 and the POD has an IP 10.244.0.2 .
Clearly we can not ping or access the pod at address 10.244.0.2 as its in a separate network.
So what are the options to see the web page? First if we were to ssh in to the kubernetes node at 192.168.1.2. Then from the node, we would be able to access the pods web page by doing a curl or if the node has a GUI, we would crack open a web browser and access the web page (http://10.244.0.2). This is from inside the kubernetes node and this is not what we need.
We want to access the web server from externally without having to ssh in to the node and simply by accessing the IP of the kubernetes node. We need something in middle to help us map request to the node from our laptop through the node to the pod running the web container.
This is where the Kubernetes Services comes in to play.
The Kubernetes service is an object just like pods, replica sets or deployments. One of its use case is to listen to a port on the node and forward request on that port to a pod running the web application. This type…