A replicaSet manages stateless identical pods as a single unit, so we wouldn't have to create a single Yaml file for each of these identical pods.

We would create a replicaSet that would handle all these identical pod as a single set.


below is the Yaml file of the replicaSet:


A replicaset uses labels to relate to "its" pods

Pods and services:

The pods are accessed through an access point called a "service". 
A service has an IP address and a port.



We create a replicaSet by sending the above Yaml for our replicaSet to the kubernetes API Server using the below command:


Managing the pods:

The
replicaSet will get the "list" of the running pods from the kubernetes API Server and check whether or not there are pods running with the same label.

The replicaSet set will then make sure the number of the running pods with the label "debian" - as in our example -, matches the number of replicas "2", either by deleting 
the "surpluspods  with the label "debian" or creating new ones if the number of the "debian" pods is below "2".

We can check our pods using the below command:



We can get more detail about our replicaSet by running the below command:


Displaying pods related to a replicaSet:

We could check the pods that are managed by replicaSet using the below command, and looking at the annotations section of the pod:


We could also use the labels option to get the pods that match the selector of a replicaSet using the below command:


Brando Sabatini and Ikbal C ©. Powered by Blogger.