A standalone Pod is a single point of failure. If the node crashes, the container exits, or the application panics, traffic hits a dead endpoint until someone manually intervenes. In production, you need:
Requirement
Bare Pod
With Controllers
Self-healing
❌ Stays down
✅ Auto-replaced
High availability
❌ Single instance
✅ Multiple replicas
Load distribution
❌ No balancing
✅ Traffic spread across replicas
Zero-downtime updates
❌ Stop-start downtime
✅ Rolling updates
Rollback
❌ Manual redeploy
✅ One-command undo
Health-aware rollout
❌ No readiness checks
✅ Rolling updates wait for readiness probes
Key Insight: You almost never create bare Pods in production. You create Deployments that manage ReplicaSets that manage Pods. Source: CKA Day 8
1. ReplicationController (Legacy)
The original Kubernetes replication mechanism. Still functional but superseded by ReplicaSet.
Attribute
Value
apiVersion
v1
kind
ReplicationController
Core Purpose
Ensure N identical Pod replicas are always running
Critical Difference: The selector.matchLabels block tells the ReplicaSet: “Manage every Pod that has the label app: nginx, regardless of who created it.” This is what allows Deployments to seamlessly take over Pods during rolling updates. Source: CKA Day 8
Scaling a ReplicaSet
Three approaches, ordered by exam speed:
Imperative (fastest)
kubectl scale --replicas=10 rs/nginx-rs
Edit live object
kubectl edit rs nginx-rs# modify replicas field in vi, save and exit
CKA Tip: Prefer imperative commands to save time. The exam is 2 hours with 16–20 tasks — seconds matter.
3. Deployment (Production Standard)
The highest-level and most commonly used workload controller. You interact with Deployments; Kubernetes handles the ReplicaSets and Pods automatically.
Attribute
Value
apiVersion
apps/v1
kind
Deployment
Manages
ReplicaSets (which manage Pods)
Superpowers
Rolling updates, rollback, revision history, pause/resume
Deployment (nginx-deploy)
└── ReplicaSet (nginx-deploy-<hash>)
├── Pod (nginx-deploy-<hash>-abc1)
├── Pod (nginx-deploy-<hash>-def2)
└── Pod (nginx-deploy-<hash>-ghi3)
When you update the Deployment (e.g., change the image), Kubernetes creates a new ReplicaSet with the new specification and scales it up while scaling the old ReplicaSet down — all without user intervention. Source: CKA Day 8
Rolling Updates
The defining feature of Deployments. Instead of deleting all old Pods at once (downtime), Kubernetes:
Creates a new ReplicaSet with the updated spec
Adds one new Pod (new version)
Removes one old Pod (old version)
Repeats until only new Pods remain
Old ReplicaSet is retained for rollback
This means users never experience an outage — traffic is continuously served by the remaining healthy Pods.
Exposing Deployments with Services
A Deployment manages Pod replicas, but Pods are ephemeral and their IPs change on restart. To provide stable access, you expose the Deployment via a Service:
# Imperative — fastest for the examkubectl expose deployment nginx-deploy --type=NodePort --port=80 --target-port=80 --node-port=30001# Declarative — create a Service YAML with selector matching Deployment labels
The Service’s selector must match the Deployment’s Pod labels. The Service then load balances traffic across all healthy Pods managed by the Deployment. Source: CKA Day 9
Rollback
# View revision historykubectl rollout history deployment/nginx-deploy# Revert to the previous revisionkubectl rollout undo deployment/nginx-deploy# Roll back to a specific revisionkubectl rollout undo deployment/nginx-deploy --to-revision=2
Each change creates a new revision. If a deployment breaks production, rollout undo restores the previous known-good state in seconds. Source: CKA Day 8
Image Updates
# Update the container image on the live objectkubectl set image deployment/nginx-deploy nginx=nginx:1.9.1
Note: This updates the live object in the cluster, not your local YAML file. Keep manifests in version control (GitOps) to avoid drift.
Resource controls: Deployment Pod templates should carry container requests/limits so replicas can be scheduled predictably and memory leaks fail as OOMKilled Pods instead of destabilizing nodes. Source: CKA Day 16
Exam-style hands-on tasks for this topic. Complete each task before reviewing the solution. Time yourself — CKA tasks average 5–7 minutes.
Task 1: Create a Deployment
You are asked to create a Deployment named web-deploy with image nginx:1.24 and 4 replicas.
Requirements: Use --dry-run=client -o yaml, save to a file, and apply.
Verification:kubectl get deploy web-deploy shows 4/4 replicas ready.
Solution:
Task 2: Imperative Scale
You are asked to scale the existing Deployment web-deploy to 6 replicas without editing any YAML file.
Requirements: Use a single imperative command.
Verification:kubectl get deploy web-deploy shows 6/6 replicas ready.
Solution:
kubectl scale deploy web-deploy --replicas=6
Task 3: Rolling Update with Strategy
You are asked to update web-deploy to use image nginx:1.25 with a rolling update strategy of maxSurge: 2 and maxUnavailable: 1.
Requirements: Edit the live object or patch the Deployment; verify the rollout completes.
Verification:kubectl rollout status deploy/web-deploySolution:
kubectl set image deploy/web-deploy nginx=nginx:1.25kubectl patch deploy web-deploy -p '{"spec":{"strategy":{"rollingUpdate":{"maxSurge":2,"maxUnavailable":1}}}}'kubectl rollout status deploy/web-deploy
Task 4: Rollback
The new image introduced a regression. Roll back web-deploy to the previous revision and verify.
Requirements: Use a single rollout command; confirm the previous image is restored.
Verification:kubectl get deploy web-deploy -o jsonpath='{.spec.template.spec.containers[0].image}'Solution:
kubectl rollout undo deploy/web-deploykubectl rollout history deploy/web-deploykubectl get deploy web-deploy -o jsonpath='{.spec.template.spec.containers[0].image}'