This scenario covers:
- Creating a Deployment
- Verifying rollout
- Updating image (rolling update)
- Verifying rollout status
- Checking rollout history
- Performing rollback
β Step 1 β Create the Deployment (nginx v1)
Create file:
# deploy-nginx.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deploy
spec:
replicas: 3
selector:
matchLabels:
app: nginx-app
template:
metadata:
labels:
app: nginx-app
spec:
containers:
- name: nginx
image: nginx:1.21
ports:
- containerPort: 80
Apply:
kubectl apply -f deploy-nginx.yaml
β Step 2 β Verify Deployment & Pods
Check Deployment:
kubectl get deploy
Check ReplicaSet (auto-created by Deployment):
kubectl get rs
Check Pods:
kubectl get pods -l app=nginx-app -o wide
or
kubectl get pods -o wide
You should see 3 Pods from a ReplicaSet.
β Step 3 β Observe Rollout Status
kubectl rollout status deployment/nginx-deploy
Expected:
deployment "nginx-deploy" successfully rolled out
π¨ Step 4 β Update Deployment (Rolling Update)
Letβs update the container image from 1.21 β 1.25 using YAML edit:
kubectl apply -f deploy-nginx.yaml
π‘ Step 5 β Watch Rolling Update in Real Time
kubectl get pods -l app=nginx-app -w
You will see:
- old pods terminating
- new pods starting
Rolling updates replace pods gradually β ensures zero downtime.
π΅οΈββοΈ Step 6 β Check Rollout History
kubectl rollout history deployment/nginx-deploy
You will see revisions:
deployment.apps/nginx-deploy
REVISION CHANGE-CAUSE
1 <none>
2 kubectl set image deployment/nginx-deploy nginx=nginx:1.25
π Step 7 β Rollback Deployment (If Needed)
Rollback to previous revision:
kubectl rollout undo deployment/nginx-deploy
Verify again:
kubectl rollout status deployment/nginx-deploy
π§Ή Step 8 β Validate Final Pods
kubectl get pods -l app=nginx-app -o wide
You will see pods with the updated (or rolled back) version.
π Thanks for reading! If this post added value, a like β€οΈ, follow, or share would encourage me to keep creating more content.
β Latchu | Senior DevOps & Cloud Engineer
βοΈ AWS | GCP | βΈοΈ Kubernetes | π Security | β‘ Automation
π Sharing hands-on guides, best practices & real-world cloud solutions






Top comments (0)