🚀 Master Kubernetes Deployments & Rollouts with Real Commands! 🚀
In Kubernetes, Deployments manage Pods and ReplicaSets to ensure your application runs smoothly. Understanding rolling updates, rollbacks, and deployment strategies is essential for reliable application delivery. Let’s break it down with real commands! 👇
🔹 1️⃣ Creating a Deployment
$ kubectl create deployment my-app --image=nginx:latest kubectl get pods
✅ Creates a Deployment and starts Pods using the specified container image.
🔹 2️⃣ Rolling Updates (Default Strategy)
Rolling updates gradually replace old pods with new ones, ensuring zero downtime.
$ kubectl set image deployment my-app nginx=nginx:1.19 kubectl rollout status deployment my-app
✅ Ensures no downtime by updating pods one by one.
✅ Uses maxSurge (extra pods allowed) & maxUnavailable (pods that can go offline).
🔹 3️⃣ Rollback in Case of Issues
If the new version causes problems, rollback to the previous stable version:
$ kubectl rollout undo deployment my-app kubectl rollout history deployment my-app
✅ Instantly reverts to the last working version.
✅ Keeps a history of deployments for easy tracking.
🔹 4️⃣ Pause & Resume Deployments for Bulk Updates
When making multiple changes, pause the rollout to apply them all at once:
$ kubectl rollout pause deployment my-app
$ kubectl set env deployment/my-app APP_MODE=production
$ kubectl set image deployment/my-app nginx=nginx:1.20
$ kubectl rollout resume deployment my-app
✅ Prevents multiple rollouts for every small change.
✅ Ensures a single, controlled rollout after all updates.
🔹 5️⃣ Recreate Strategy (For Clean Deployments)
Stops all old Pods before deploying new ones. This may cause downtime but ensures a clean deployment:
$ kubectl rollout restart deployment my-app
✅ No leftover old versions, but downtime occurs. ✅ Ideal when version compatibility is an issue.
🔹 6️⃣ Monitoring & Debugging Rollouts
📌 Check rollout history
$ kubectl rollout history deployment my-app
📌 Check deployment status
$ kubectl get deployment my-app -o wide
📌 Track why a deployment was changed
$ kubectl annotate deployment my-app kubernetes.io/change-cause="Updated app to v2"
✅ Helps in debugging & audit tracking of deployments.
💡 Key Takeaways:
✅ Use Rolling Updates for smooth deployments.
✅ Pause rollouts when making multiple updates.
✅ Rollback instantly if an update breaks your app.
✅ Monitor & track deployment changes using commands.
🚀 Kubernetes gives you full control over your deployments, ensuring high availability and reliability. Which deployment strategy do you prefer? Let’s discuss! 👇
#Kubernetes #DevOps #CI/CD #CloudNative #OpenShift #SRE #Infrastructure
📌 Make your skill assessment here : https://lnkd.in/gPeRwj6T
📌 Get your free RHLS today : https://lnkd.in/gWnsbHRi
📌 To Register : https://lnkd.in/gTDVhwy9
📌 Visit Us : www.hawkstack.com
Managing Director at HawkStack Technologies with expertise in infrastructure automation.
4moHelpful insight, Gurdeep
https://www.linkedin.com/feed/update/urn:li:activity:7313032440288026626