Practice Test - ReplicaSets
- Take me to Practice Test
Solutions for the replicaset practice tests
-
How many pods exist on the system?
kubectl get podsCount the number of pods (if any)
-
How many ReplicaSets exist on the system?
kubectl get replicasetsCount the number of ReplicaSets (if any)
-
How about now? How many ReplicaSets do you see?
kubectl get replicasetsCount the number of ReplicaSets (if any)
-
How many PODs are DESIRED in the new-replica-set?
From the output of Q3, look in
DESIREDcolumn -
What is the image used to create the pods in the new-replica-set?
kubectl describe replicaset…and look under the containers section --- or —
kubectl get rs -o wide…and look in the
IMAGEScolumn. Kubernetes acceptsrsas shorthand forreplicaset. -
How many PODs are READY in the new-replica-set?
kubectl get rsLook in the
READYcolumn. -
Why do you think the PODs are not ready?
kubectl describe podsLook in the
Eventssection at the end. -
Delete any one of the 4 PODs.
kubectl get podsChoose any of the four.
kubectl delete pod new-replica-set-XXXX -
How many PODs exist now?
kubectl get pods -
Why are there still 4 PODs, even after you deleted one?
> ReplicaSets ensures that desired number of PODs always run -
Create a ReplicaSet using the replicaset-definition-1.yaml file located at /root/.
There is an issue with the file, so try to fix it.kubectl create -f replicaset-definition-1.yamlNote the error message.
Get the apiVersion for replicaset
$ kubectl explain replicaset | grep VERSIONUpdate the replicaset definition file in
viwith correct version and then retry creation.$ kubectl create -f replicaset-definition-1.yaml -
Fix the issue in the replicaset-definition-2.yaml file and create a ReplicaSet using it.
kubectl create -f replicaset-definition-1.yamlNote the error message.
Selector matchLabels should match with POD labels - Update
replicaset-definition-2.yamlThe values for labels on lines 9 and 13 should match.
$ kubectl create -f replicaset-definition-2.yaml -
Delete the two newly created ReplicaSets - replicaset-1 and replicaset-2
kubectl delete replicaset replicaset-1 kubectl delete rs replicaset-2--- OR ---
kubectl delete replicaset replicaset-1 replicaset-2 -
Fix the original replica set new-replica-set to use the correct busybox image.
kubectl edit replicaset new-replica-setEdit the image to be
busybox, save and exit. -
Fix the original replica set new-replica-set to use the correct busybox image.
kubectl edit replicaset new-replica-setFix the image, save and exit.
You will note if you do
kubectl get pods, that they are still broken. ReplicaSets are not very smart and do not redeploy pods when the container specification has been edited.We must either delete and recreate the replicaset by exporting its YAML…
kubectl get rs new-replica-set -o yaml > rs.yaml kubectl delete rs new-replica-set kunectl create -f rs.yaml— OR —
Delete each broken pod. The ReplicaSet will deploy a new one in its place which should be working.
— OR —
Scale it to zero, then back to 4
kubectl scale rs new-replica-set --replicas 0 kubectl scale rs new-replica-set --replicas 4 -
Scale the ReplicaSet to 5 PODs.
kubectl scale rs new-replica-set --replicas 5