Checking the Initial State
Before proceeding, verify there are no existing Pods or ReplicaSets in your cluster.-
List all Pods:
Expected output:This confirms that there are currently zero Pods running.
-
List any existing ReplicaSets:
The command similarly shows no ReplicaSets at this point.
Verifying the New ReplicaSet
After applying some changes, a new ReplicaSet is created. Confirm its presence using:Determining the Image Used by the ReplicaSet
To inspect the details of the ReplicaSet and determine which image is assigned to its Pods, execute:Examining the Pod Readiness Issue
If the Pods are not transitioning to the Ready state, further investigation is required:-
Check the replica status:
You should see an excerpt like:
-
Inspect one of the Pods to identify the issue:
Notice the container is in a Waiting state with the reason:And an associated event message:
The error indicates that there is no image named “busybox777” available in the repository. Use the standard BusyBox image instead.
Deleting a Pod Managed by the ReplicaSet
ReplicaSets are designed to maintain the desired number of Pods automatically. Even if you delete a Pod, the ReplicaSet immediately replicates a new one.-
List the Pods:
Example output:
-
Delete one of the Pods:
Confirmation output:
- List the Pods again to note that the ReplicaSet has recreated the missing Pod.
Creating ReplicaSets Using YAML Definition Files
Two YAML definition files are located in the/root directory:
- replicaset-definition-1.yaml
- replicaset-definition-2.yaml
Fixing the First Definition File
The initial content of replicaset-definition-1.yaml is:apps/v1. Update the file accordingly. After the change, creation should succeed.
Fixing the Second Definition File
The content of replicaset-definition-2.yaml is:tier: frontend) does not match the Pod template labels (tier: nginx). Correct the Pod template labels to use tier: frontend so they match the selector. After this fix, create the ReplicaSet again using:
Deleting Newly Created ReplicaSets
After verification, remove replicaset-1 and replicaset-2 from your cluster.-
List the current ReplicaSets to check their status:
Example output:
-
Delete the ReplicaSets:
Updating the Original ReplicaSet’s Image
Since the original ReplicaSet (“new-replica-set”) uses an incorrect image (“busybox777”), update it to use the proper BusyBox image.-
Edit the ReplicaSet:
Locate the container section and update the image field:
-
Save the changes and verify by describing the ReplicaSet:
Scaling the ReplicaSet
Scaling Up
To increase the ReplicaSet to five replicas, run:Scaling Down
To scale the ReplicaSet down, you can edit the resource directly:-
Open the ReplicaSet for editing:
-
Modify the replicas value from 5 to 2 in the YAML:
-
Save your changes. Verify the update with: