Kubernetes 101 : An Overview of ReplicaSet and their role.
A replicaSet is a simple kubernetes controller for managing the pods.
Using a replicaSet, we can tell kubernetes to have, and keep a specific number of pods running.
Using a replicaSet, we can tell kubernetes to have, and keep a specific number of pods running.
The below replicaSet example instructs kubernetes to keep three replicas of "debian" pods running at all times.
ReplicaSet and Selectors:
Replicasets use different selectors, for example the "matchLabels" in the above Yaml file.
We could also use other variables like "matchExpressions" as a selector.
The replicaSet makes sure its "replicas" number matches the number of the running pods that have a label that matches its selector "debian-app".
When a pod with the label "debian-app" crashes or exits, the replicaSet deploys a replacement pod for it.
We create our replicaSet using the below command:
We can then check, if the replicaSet created a replacement for our deleted pod using the below command:
"replica-debian-198340978-fd89s", so that the number of the running pods always matches the "replicas" value.
Adopting pods:
If we already have a pod running with the label "debian-app", the replicaSet we created above, will only create two pods instead of three, and it will "adopt" the third pod with the label "debian-app", that is already running.
Comments