

π 1. Core Idea (1-line)
π Deployment manages ReplicaSets and provides rolling updates + rollback
π§ 2. Why Deployment Exists
We already have:
-
Pod β
-
ReplicaSet β
But problem:
β No safe updates
β No version control
β No rollback
π Deployment solves all this
βοΈ 3. What Deployment Actually Does
Deployment:
-
Creates ReplicaSet
-
Manages Pods via ReplicaSet
-
Handles updates (rolling updates)
-
Maintains history (revisions)
π Flow:
Deployment β ReplicaSet β Pods
π₯ 4. Rolling Update (VERY IMPORTANT π₯)
Scenario:
You update image:
image: app:v2π Kubernetes will:
-
Create new pods (v2)
-
Slowly terminate old pods (v1)
-
Ensure zero downtime
π₯ 5. Strategy Types
β RollingUpdate (default)
-
Gradual replacement
-
No downtime
β Recreate
-
Kill all old pods first
-
Then create new ones (downtime)
π¦ 6. Example YAML
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-deployment
spec:
replicas: 3
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
spec:
containers:
- name: app
image: nginx:1.21π 7. Rollback Feature (LIFE SAVER π―)
If new version breaks:
kubectl rollout undo deployment my-deploymentπ Instantly goes back to previous working version
π§ 8. Revision History
Each update = new version stored
Check history:
kubectl rollout history deployment my-deploymentβ‘ 9. Real-world DevOps Example
You deploy ML API:
-
v1 β working
-
v2 β bug introduced
π Deployment:
-
Detects issue (via probes / monitoring)
-
You rollback instantly
π Zero downtime + safe deploy
πΌ 10. Interview Answer (Clean)
π βDeployment is a higher-level Kubernetes object that manages ReplicaSets and enables declarative updates, rolling deployments, and rollbacks of applications.β
β οΈ 11. Common Mistakes
β βDeployment creates Pods directlyβ
π Actually β creates ReplicaSet β then Pods
β βPods are permanentβ
π Deployment keeps replacing them
β‘ 12. CKA Commands (VERY IMPORTANT)
kubectl get deployments
kubectl describe deployment <name>
kubectl rollout status deployment <name>
kubectl rollout history deployment <name>
kubectl rollout undo deployment <name>π§ 13. Memory Trick
π Deployment = Manager π¨βπΌ
π ReplicaSet = Worker Manager
π Pod = Worker π·
π₯ 14. Pro Insight (Real-world)
π You will use Deployment 90% of the time
-
Backend apps
-
APIs
-
ML services