ReplicaSet Exercise-01

3 min readFeb 18, 2022


If you are new to the ReplicaSet YAML file click here

i) Create a replica set YAML with 3 pods.

apiVersion: apps/v1
kind: ReplicaSet
name: frontend
app: guestbook
tier: frontend
# modify replicas according to your case
replicas: 3
tier: frontend
tier: frontend
- name: php-redis

ii) Deploy Replicaset YAML file

$ kubectl apply -f <FILENAME.YAML> or 
$ kubectl create -f <FILENAME.YAML>

iii) Display the replica set

$ kubectl get rs
$ kubectl get rs <RS-NAME>

iv) Print wide output of the replica set

$ kubectl get rs -o wide

v) Print replica set in particular NameSpace (replica set are deployed in default namespace)

$ kubectl get rs <RS-NAME> -n default

vi) Print the replica set to output in YAML/JSON format

$ kubectl get rs <POD-NAME> -o yaml  
$ kubectl get rs <POD-NAME> -o json

vii) Print the replica set labels

$ kubectl get rs --show-labels

viii) Print Pods with a specific label

$ kubectl get rs -l app=guestbook

ix) Print the details description of pods

$ kubectl describe rs <RS-NAME>

x) Scaling the number of pods of the replica set, current we have three pods and we will increase it to 5.

$ kubectl scale rs <RS-NAME> --replicas=[COUNT]

xi) Edit ReplicaSet and change the docker image to nginx.

$ kubectl edit rs <RS-NAME>

Run the kubectl edit rs frontend command and search for image section and change image as nginx.

Test the changes by checking the images

$ kubectl get rs frontend -o wide 

xii) Running operations directly on the YAML file

$ kubectl get –f [FILE-NAME.yaml]
$ kubectl describe –f [FILE-NAME.yaml]
$ kubectl edit –f [FILE-NAME.yaml]
$ kubectl delete –f [FILE-NAME.yaml]
$ kubectl apply –f [FILE-NAME.yaml]
$ kubectl describe –f [FILE-NAME.yaml]
$ kubectl edit –f [FILE-NAME.yaml]
$ kubectl delete  -f replicaset.yaml
$ kubectl apply -f replicaset.yaml

xiii) Delete the replicaset

$ kubectl delete rs <RS-NAME>




Certified Kubernetes Administrator