1) How many pods exist on the system?
Run:2) How many ReplicaSets exist on the system?
Run:3) What is the desired number of pods in the new ReplicaSet?
From thekubectl get replicaset output:
- Desired = 4
4) What image is used to create the pods in the new ReplicaSet?
To inspect the ReplicaSet template:busybox777.
Answer: busybox777
5) How many pods are Ready in the new ReplicaSet?
From thekubectl get replicaset / kubectl describe output:
- Ready = 0
6) Why are the pods not Ready?
Inspect a failing pod to find the root cause:busybox777 — the repository does not exist (invalid image name), causing ImagePullBackOff. Therefore pods are not Ready.
7) Delete a pod from the ReplicaSet and observe behavior
Delete one pod:8) Create a ReplicaSet from a definition file and fix apiVersion issue
List files in/root:
apiVersion is set to v1 but ReplicaSet is in the apps API group (apps/v1).
Discover the correct API with:
apiVersion to apps/v1, then create it:
ReplicaSet belongs to the
apps API group. Always use apiVersion: apps/v1. Use kubectl explain <kind> to discover the correct API version and available fields.9) Fix the second definition file: selector vs template labels
Attempt to create the second file:replicaset-definition-2.yaml (excerpt):
spec.selector.matchLabels is tier: frontend while the Pod template labels are tier: nginx. A ReplicaSet’s selector must match the Pod template labels so it can manage the created pods.
Fix: make selector.matchLabels and template.metadata.labels match (for example, set both to tier: frontend), then create:
10) Delete replicaset-1 and replicaset-2
Delete both ReplicaSets:11) Fix the original ReplicaSet to use the correct busybox image
Thenew-replica-set still references the invalid image busybox777. Edit the ReplicaSet to correct the container image:
busybox777 to busybox. Example edited snippet:
Editing a ReplicaSet’s pod template updates the ReplicaSet object, but it does not replace existing pods. To apply the new template to running pods, either delete the existing pods (so the ReplicaSet recreates them) or recreate the ReplicaSet.
12) Recreate pods to pick up the new image
Delete the ReplicaSet’s pods so the controller will create new pods using the corrected image:busybox image.
Note: When you change a ReplicaSet’s pod template, existing pods are not automatically replaced. Deleting the pods causes the ReplicaSet to recreate them with the new template.
13) Scale the ReplicaSet to 5 pods
Scale withkubectl scale:
spec.replicas to scale.
14) Scale the ReplicaSet down to 2 pods (edit approach)
Edit the ReplicaSet:spec.replicas to 2:
That’s it for this lab lesson. Links and References