1) How many pods exist on the system?
Run:2) How many ReplicaSets exist on the system?
Run:busybox777.
3) How many pods are Ready in the new ReplicaSet?
From the describe/get output above:- READY is 0
- Pod Status shows 0 Running / 4 Waiting
busybox777 does not exist (or is private), so kubelet cannot pull it and containers fail to start with ImagePullBackOff.
4) Delete any one of the pods in the ReplicaSet and observe what happens
Delete a pod managed by the ReplicaSet:ReplicaSet ensures that a specified number of pod replicas are running at any given time. Deleting a pod managed by a ReplicaSet causes the ReplicaSet controller to automatically create a replacement pod.
5) Create a ReplicaSet using the definition file at /root (fix issues if any)
List files:apiVersion: v1 is incorrect for ReplicaSet. ReplicaSet belongs to apps/v1.
Find correct API version:
apiVersion: apps/v1 for compatibility with modern Kubernetes versions.
6) Fix the issue in the second file and create the ReplicaSet
Attempt to create:selector (tier: frontend) does not match the pod template labels (tier: nginx). ReplicaSet requires the selector to match the template labels exactly so it can manage the pods it creates.
Fix: Make the labels match the selector. For example, change the template label to frontend:
spec.selector.matchLabels matches spec.template.metadata.labels. Kubernetes will reject ReplicaSets where the selector does not cover the template labels.
7) Delete the two newly created ReplicaSets
Delete both ReplicaSets:8) Fix the original ReplicaSet to use the correct busybox image
We still havenew-replica-set whose pods are failing because of the wrong image name (busybox777). Edit the ReplicaSet to correct the image:
- Delete the pods managed by the ReplicaSet; the ReplicaSet controller will create replacements using the updated template.
- Delete and re-create the ReplicaSet (not recommended for live workloads).
9) Scale the ReplicaSet up to 5 pods
Scale using kubectl:spec.replicas manually:
10) Scale the ReplicaSet down to 2 pods (edit method)
Edit the ReplicaSet:DESIRED 2 and the pod list reduced accordingly.
References and further reading: That’s it for this lab.