A replicaSet is a kubernetes object which ensures that a specified number of pods is running at all times. 

Below we have a replicaSet object with three replicas of "debian" pods with the label "debian_pod":


Here is the Yaml configuration file of the replicaSet that spawns the "debian_pod" pods:


Displaying the pods:

We display the pods that the replicaSet "replica_1" spawns using the below command:


Changing the label of a pod:

We edit the Yaml file of our pod "replica_1-3f0d1" and we change its label from "debian_pod" to "non_debian_pod" using the below command:


Remark:

The edit command opens the "Vi" editor. 
We could change the default editor using the environmental variable "KUBE_EDITOR"

We then display the pods that have the label "role" :


The ReplicaSet still has three replicas with the "debian_pod" label even after changing the label of one of the replicas.

The replicaSet spwaned a new pod "replica_1-3c9d2" to replace the one with the changed label "replica_1-3f0d1" to keep the number of replicas which is "3".

Deleting the replicaSet:

When we delete the replicaSet "replica_1", all the pods attached to it will be deleted automatically:


This deletes the replicaset and all the pods attached to it, except the one with the changed label "replica_1-3f0d1".

We can check it using the below command:


Deleting the pod with the changed label:

We can delete the pod with the changed label "non_debian_pod" using the below command:


Remark:

We could use "pods" or "po" in the command line interchangeably.
Brando Sabatini and Ikbal C ©. Powered by Blogger.