Day 8/40 — Kubernetes Deployment, Replication Controller and ReplicaSet Explained
The eighth installment of the Tech Tutorials with Piyush 40-day CKA course. This session moves from standalone Pods to the workload controllers that guarantee high availability, self-healing, and zero-downtime updates in production Kubernetes.
Video Summary
This ~35-minute tutorial explains the three core Kubernetes workload controllers that manage Pod replication: ReplicationController (legacy), ReplicaSet (modern), and Deployment (the production standard). Piyush combines whiteboard theory with live terminal demonstrations using kubectl and YAML manifests.
Key Concepts Covered
1. Why Pods Need Controllers A bare Pod is a single point of failure. If it crashes, user traffic receives no response. Kubernetes controllers solve this by continuously monitoring the desired state (number of replicas) and reconciling the actual state — spinning up replacements automatically.
2. ReplicationController (Legacy)
apiVersion: v1,kind: ReplicationController- Ensures a specified number of Pod replicas are running at all times
- Uses a
templatefield insidespecto define the Pod blueprint (image, ports, labels) - If a Pod dies, the controller creates a new one from the template
- Supports manual scaling by updating the
replicasfield - Limitation: Cannot adopt existing Pods that were not created by it
3. ReplicaSet (Modern Replacement)
apiVersion: apps/v1,kind: ReplicaSet- Functionally similar to ReplicationController but with a critical addition: selectors
- The
spec.selector.matchLabelsfield allows a ReplicaSet to manage existing Pods that match its label criteria, even if they were created independently - This makes ReplicaSets more flexible and is the reason Deployments use ReplicaSets under the hood
- Scaling methods demonstrated:
- Edit YAML →
kubectl apply -f - Edit live object →
kubectl edit rs <name> - Imperative command →
kubectl scale --replicas=10 rs/<name>
- Edit YAML →
4. Deployment (Production Standard)
apiVersion: apps/v1,kind: Deployment- A higher-level abstraction that manages ReplicaSets, which in turn manage Pods
- Key superpower: Rolling Updates
- Updates Pods one-by-one (or in batches) so the application never goes offline
- Old Pods serve traffic while new Pods are being created and health-checked
- Ideal for production workloads like banking or trading platforms where downtime is unacceptable
- Rollback capability
kubectl rollout history deployment/<name>— view revision historykubectl rollout undo deployment/<name>— revert to the previous revision
- Image updates
kubectl set image deployment/<name> container=image:tag— change container image on the live object
Hands-On Commands Demonstrated
| Command | Purpose |
|---|---|
kubectl apply -f rc.yaml | Create a ReplicationController |
kubectl get rc | List ReplicationControllers |
kubectl get rs | List ReplicaSets |
kubectl get deploy | List Deployments |
kubectl get all | Show all resources in the namespace |
kubectl describe pod <name> | Inspect Pod details and events |
kubectl scale --replicas=5 rs/<name> | Scale a ReplicaSet imperatively |
kubectl edit rs <name> | Edit a live ReplicaSet object |
kubectl set image deploy/<name> <container>=<image>:<tag> | Update container image |
kubectl rollout history deploy/<name> | View deployment revision history |
kubectl rollout undo deploy/<name> | Roll back to previous revision |
kubectl create deploy <name> --image=<image> --dry-run=client -o yaml > deploy.yaml | Generate a Deployment YAML via dry-run |
YAML Structure Highlight
A Deployment manifest contains:
apiVersion: apps/v1kind: Deploymentmetadata(name, labels)spec.replicas— desired number of Podsspec.selector.matchLabels— which Pods to managespec.template— the Pod template (metadata + spec.containers)
Exam Tips Emphasized
- Time is everything on the CKA exam. Prefer imperative commands (
kubectl scale,kubectl create) over manual YAML editing when possible. - Use
--dry-run=client -o yamlto quickly generate manifest skeletons, then modify and apply. - Know your shortcuts. The exam environment uses
vi; practiceShift+A(append at end of line) and other vi navigation commands. - The cheat sheet is your friend.
kubectl <command> --helpprovides copy-pasteable examples.
Sources
- Tech Tutorials with Piyush — 40-Day CKA Course
See Also
Wiki Concepts
- Deployment, ReplicaSet & Replication Controller — Full technical synthesis of these workload controllers
- Pod Fundamentals — The smallest deployable unit that these controllers manage
- Kubernetes Architecture — Where the Controller Manager fits in the control plane
- CKA Certification — Exam overview and domains
- CKA Study Roadmap — 40-day learning plan
- Why Kubernetes? — Problems that self-healing and replication solve
- Docker Fundamentals — Container basics that underpin Pods
- Client-Server Architecture — Load balancing and high-availability patterns
Related Sources
- CKA Day 7 — Pod Explained — The prerequisite video on standalone Pods
- CKA Day 6 — Kind Cluster Setup — Local cluster used for the hands-on demo
Creator / Entity
- Tech Tutorials with Piyush — Creator of the 40-day CKA challenge series