๐ Kubernetes ReplicationController (RC) Practical Lab | Create, Scale, Self-Healing & Delete Pods Automatically
In this blog, I will demonstrate:
- Creating Pods manually
- Creating ReplicationController
- Automatic Pod Recovery
- Scaling Pods
- Editing ReplicationController
- Understanding Labels & Selectors
- Changing Labels
- Deleting RC with and without Pods
- Complete command output explanation
What is ReplicationController?
A ReplicationController (RC) ensures that a specified number of Pod replicas are always running.
If a Pod crashes or is deleted accidentally, Kubernetes automatically creates another Pod.
Responsibilities
- Maintain desired number of Pods
- Self-Healing
- Scaling Pods
- Managing Pod replicas
Lab-1: Create a Single Pod
Create an nginx Pod.
kubectl run pod1 --image=nginx
Output
pod/pod1 created

Check the Pod.
kubectl get pods
Output
NAME READY STATUS RESTARTS AGE
pod1 1/1 Running 0 20s
Delete the Pod
kubectl delete pod pod1
Output
pod "pod1" deleted
Check again.
kubectl get pods
Output
No resources found
Notice that Kubernetes does not recreate the Pod because it is an unmanaged Pod.
Create ReplicationController
Create rc.yaml
apiVersion: v1
kind: ReplicationController
metadata:
name: rc1
spec:
replicas: 3
selector:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80
Deploy it.
kubectl apply -f rc.yaml
Output
replicationcontroller/rc1 created
Check RC.
kubectl get rc
Output
NAME DESIRED CURRENT READY
rc1 3 3 3
Check Pods.
kubectl get pods
Output
NAME READY STATUS
rc1-abc12 1/1 Running
rc1-def34 1/1 Running
rc1-ghi56 1/1 Running
Self-Healing Demonstration
Delete one Pod.
kubectl delete pod rc1-abc12
Immediately check Pods.
kubectl get pods
Output
NAME READY STATUS
rc1-def34 Running
rc1-ghi56 Running
rc1-xyz89 Running
Notice that Kubernetes automatically created a new Pod.
This feature is called Self-Healing.
Scale Out (3 โ 5 Pods)
Modify replicas in rc.yaml
replicas: 5
Apply again.
kubectl apply -f rc.yaml
Check Pods.
kubectl get pods
Output
5 Pods Running
Kubernetes created two additional Pods.
Scale Down Using kubectl edit
Edit the ReplicationController.
kubectl edit rc rc1
Change
replicas: 5
to
replicas: 3
Save and exit.
Watch Pods.
kubectl get pods -w
Output
Terminating...
Running...
Kubernetes automatically removes extra Pods.
Scale Using Command
Increase replicas without editing YAML.
kubectl scale rc rc1 --replicas=5
Check.
kubectl get pods
Output
5 Pods Running
This is the easiest method for scaling.
Describe ReplicationController
kubectl describe rc rc1
Useful information displayed:
- Labels
- Selector
- Replica Count
- Events
- Pod Template
- Image Name
Very useful for troubleshooting.
View Labels
kubectl get pods -o wide --show-labels
Output
NAME LABELS
rc1-abc app=nginx
rc1-def app=nginx
rc1-ghi app=nginx
Change Pod Label
Overwrite label.
kubectl label pod rc1-nrsjw app=web --overwrite
Check labels again.
kubectl get pods -o wide --show-labels
Output
rc1-nrsjw app=web
others app=nginx
Delete the Modified Pod
Delete the Pod.
kubectl delete pod rc1-nrsjw
Since RC selector is
app: nginx
the modified Pod no longer matches the selector.
Kubernetes creates a new Pod with
app=nginx
to maintain the desired replica count.
This demonstrates how Selectors work.
Experiment with Selector
Modify
selector:
app: web
Apply.
kubectl apply -f rc.yaml
Observe Pod behavior.
Since selectors no longer match existing Pods, Kubernetes attempts to create new Pods.
This demonstrates why selectors must be planned carefully.
Change Container Image
Edit RC.
kubectl edit rc rc1
Change
image: nginx
to
image: redis
Existing Pods continue running with nginx.
Delete one Pod.
kubectl delete pod rc1-s7b22
RC creates a new Pod.
Check image.
kubectl describe pod <pod-name> | grep -i Image
Output
Image: redis
Only newly created Pods use the updated image.
Existing Pods remain unchanged because ReplicationController does not perform rolling updates.
Delete ReplicationController
Delete RC.
kubectl delete rc rc1
Output
replicationcontroller "rc1" deleted
Pods are also deleted because of Cascade Deletion.
Delete RC but Keep Pods
Recreate RC.
kubectl apply -f rc.yaml
Delete RC only.
kubectl delete rc rc1 --cascade=false
Check Pods.
kubectl get pods
Output
Pods continue running.
Check RC.
kubectl get rc
Output
No resources found
Pods are now unmanaged.
Important Commands Used
| Command | Purpose |
|---|---|
| kubectl run | Create Pod |
| kubectl apply | Create or Update Resources |
| kubectl get pods | View Pods |
| kubectl get rc | View ReplicationControllers |
| kubectl delete pod | Delete Pod |
| kubectl edit rc | Edit ReplicationController |
| kubectl scale | Scale Replicas |
| kubectl describe rc | Detailed Information |
| kubectl label | Change Labels |
| kubectl get pods –show-labels | View Labels |
| kubectl delete rc | Delete ReplicationController |
Key Learnings
โ Created standalone Pod
โ Understood unmanaged Pods
โ Created ReplicationController
โ Learned Self-Healing
โ Scaled Pods Up
โ Scaled Pods Down
โ Used kubectl scale
โ Edited RC
โ Worked with Labels
โ Worked with Selectors
โ Updated Container Image
โ Deleted RC
โ Deleted RC while preserving Pods
Important Interview Questions
Why is ReplicationController used?
To ensure the desired number of Pod replicas are always running.
What happens if one Pod crashes?
ReplicationController automatically creates a replacement Pod.
Does RC support Rolling Updates?
No.
Deployments should be used instead.
Difference between ReplicationController and ReplicaSet?
| ReplicationController | ReplicaSet |
|---|---|
| Equality-based selector only | Set-based selectors supported |
| Older Kubernetes object | Modern replacement |
| Rarely used today | Used by Deployments |
Kubernetes ReplicationController (RC) Complete Workflow Diagram
๐ START
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Create Standalone Pod โ
โ kubectl run pod1 --image=nginx โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Verify Pod โ
โ kubectl get pods โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Delete Standalone Pod โ
โ kubectl delete pod pod1 โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Is Pod Recreated? โ
โ โ No โ
โ (Unmanaged Pod) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
NOW CREATE A REPLICATIONCONTROLLER (RC)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Create rc.yaml โ
โ replicas = 3 โ
โ selector = app: nginx โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Apply Configuration โ
โ kubectl apply -f rc.yaml โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ RC Creates 3 Pods Automatically โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
SELF-HEALING DEMONSTRATION
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Delete One Managed Pod โ
โ kubectl delete pod <pod-name> โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
RC Detects Missing Pod
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Automatically Creates โ
โ New Replacement Pod โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
SCALING OPERATIONS
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Scale Out โ
โ replicas: 3 โ 5 โ
โ kubectl apply -f rc.yaml โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
Kubernetes Creates 2 New Pods
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Scale Down โ
โ replicas: 5 โ 3 โ
โ kubectl edit rc rc1 โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
Kubernetes Deletes 2 Pods
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Scale Using Command โ
โ kubectl scale rc rc1 --replicas=5 โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
LABELS & SELECTORS
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
View Labels
kubectl get pods --show-labels
โ
โผ
Change Pod Label
kubectl label pod <pod> app=web --overwrite
โ
โผ
Delete Modified Pod
โ
โผ
RC Creates New Pod With Correct Label (app=nginx)
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
CHANGE CONTAINER IMAGE
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
Edit RC
kubectl edit rc rc1
โ
โผ
image: nginx โ redis
โ
โผ
Delete Existing Pod
โ
โผ
New Pod Created Using Redis Image
Existing Pods Continue Using NGINX Image
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
DELETE REPLICATIONCONTROLLER
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
kubectl delete rc rc1
โ
โผ
RC Deleted + Pods Deleted
(Cascade = true)
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
DELETE RC BUT KEEP THE PODS
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
Recreate RC
kubectl apply -f rc.yaml
โ
โผ
kubectl delete rc rc1 --cascade=false
โ
โผ
RC Deleted
Pods Continue Running
(Now Unmanaged Pods)
โ
โผ
๐ END
๐ Workflow Summary
Standalone Pod
โ
โผ
Delete Pod
โ
โผ
Not Recreated
โ
โผ
Create ReplicationController
โ
โผ
3 Pods Running
โ
โผ
Delete One Pod
โ
โผ
Self-Healing โ New Pod Created
โ
โผ
Scale Out โ 5 Pods
โ
โผ
Scale Down โ 3 Pods
โ
โผ
Scale Using Command
โ
โผ
Modify Labels
โ
โผ
Selectors Match Pods
โ
โผ
Change Image (NGINX โ Redis)
โ
โผ
Delete Pod โ New Pod Uses Redis
โ
โผ
Delete RC
โ
โผ
RC + Pods Deleted
โ
โผ
Recreate RC
โ
โผ
Delete RC (--cascade=false)
โ
โผ
Pods Continue Running (Unmanaged)
โ
โผ
END
Conclusion
This practical lab demonstrated how Kubernetes ReplicationController maintains application availability through self-healing, automatic recovery, and replica management. While Deployments are the preferred option in modern Kubernetes, understanding ReplicationController provides a strong foundation for learning ReplicaSets and Deployments. Every CKA candidate should practice these concepts to better understand Kubernetes internals and cluster behavior.
