(1) What is ReplicaSet?
A ReplicaSet's purpose is to maintain a stable set of replica Pods running at any given time. As such, it is often used to guarantee the availability of a specified number of identical Pods.
(2) Creating ReplicaSet.
Create ReplicaSet
kubectl create -f frontend.yaml
List ReplicaSet
```
kubectl get replicaset
kubectl get rs
```
(3) Test the High availability of ReplicaSet.
The main feature of ReplicaSet is to maintain a stable set of replica Pods running at any given time.
It means if you define there should be at least
3
pods should be running at any point in time, In case of failure or error any pod(s) crash or fail to load. ReplicaSet will create new pod(s) and maintain the provided number3
of running pods.
# Number of running pods
kubectl get pod
# Delete any running pod.
kubectl delete pod <pod-name>
# Check the numbers of pods running, you will find a newly created pod.
kubectl get pod
(4) Scalability in ReplicasSets.
- In
frontend.yaml
file, key :replicas
is indicate the number of pods.Currently, it sets as3
you can change it to5
.
# Before
spec:
replicas: 3
# After
spec:
replicas: 5
- Update the ReplicaSet
# Below command will again read the file and change the replicas.
kubectl apply -f frontend.yaml
# To check newly created pods.
kubectl get pods
Made with :heart: by Pratikkumar Panchal