Cluster IP services:

Each pod gets an IP address. If the pod crashes, a new copy of the pod gets redeployed with a new  IP addresses.

Because of the volatile aspect of these IP addresses, we can't use them for  internal communication between the pods since they can change anytime.

We use a service called the Cluster IP service which is created with a static IP and port and serves as an access point to a group of pods.

The pods in a group have the same label and are members of the same Cluster IP service.

Cluster IP for different groups of pods:

If we have a group of pods running a web server and another group of pods running a database, we would need to define two Cluster IP services, one for each group of pods.

Different Cluster IP services can be used to connect different groups of pods in the cluster.


DB and Web server are respectively the labels of the database pods and the Web server pods. 

We define these labels in the YAML configuration file of the pods in the labels section.

A Cluster IP is only accessible from withing the kubernetes cluster.

Cluster IP is the default type of services. When we create a service without mentioning the type (see YAML file below) , it creates a cluster IP services.

Example:

Cluster IP service YAML file:


Below a diagram describing the Cluster IP in the above YAML file:


The Cluster IP receives requests for the pods on port 80 and forwards them to one of the pods in the group with Label_A label on the application port 8080.

Brando Sabatini and Ikbal C ©. Powered by Blogger.