Q: New deployment breaks production — how would you rollback?
Fast-response production incident runbook for rolling back broken Kubernetes deployments across native kubectl, GitOps (ArgoCD/Flux), and handling database migration traps.
Kubernetes Deployment Broke Production? Rollback First!
Watch Naveed break down how to handle a broken Kubernetes deployment in production—halting rollouts with kubectl rollout pause, executing instant ReplicaSet rollbacks with kubectl rollout undo, overcoming the ArgoCD GitOps self-heal trap, and avoiding destructive database schema migration failures in 60 seconds.
- Pause failing rollout immediately: Stop the deployment controller from replacing healthy pods
- Imperative rollback: Inspect revisions with kubectl rollout history and revert with kubectl rollout undo
- Overcoming the GitOps trap: Disable ArgoCD auto-sync/self-heal or git revert to prevent self-heal fighting
- Database schema safety: Verify backward compatibility before code rollbacks to avoid catastrophic crashes
Want to master this scenario in a live sandbox? KodeKloud's CKA & CKAD Hands-On Certification Track covers this exact problem with hands-on terminal drills.
🛠️ Production Runbook & Step-by-Step Resolution
Direct Answer: When a new deployment causes production degradation, the priority is mean time to recovery (MTTR). The rollback path depends on whether you run imperative deployments or declarative GitOps.
Immediate Imperative Rollback (kubectl rollout undo)
If using native Kubernetes deployments:
kubectl rollout undo deployment/<deployment-name> -n <ns>: Instantly rolls back to the previous revision.kubectl rollout status deployment/<deployment-name>: Monitor the rollback progress in real-time.- To target a specific revision:
kubectl rollout history deployment/<name>followed bykubectl rollout undo deployment/<name> --to-revision=3. - How it works under the hood: Kubernetes points the Deployment back to the previous healthy
ReplicaSet, scaling it up while scaling down the broken ReplicaSet.
GitOps Rollback (ArgoCD / Flux Reality)
In GitOps, manual kubectl rollouts will be reverted by self-healing:
- The GitOps Trap: If you run
kubectl rollout undowhile ArgoCD hasauto-sync+self-healenabled, ArgoCD will detect drift and immediately re-deploy the broken version! - Proper GitOps Rollback: Run
git revert HEAD && git push origin mainin the manifest repository. ArgoCD syncs and restores the previous commit cleanly. - Emergency Fast-Path: In ArgoCD UI/CLI, click Disable Auto-Sync, roll back revision, then fix Git repository.
The Database Migration Trap
Can code be safely rolled back if database schema migrated?
- If the release included destructive database schema migrations (e.g. dropped a column or renamed a table), rolling back application code will crash the previous version because old code expects the old schema.
- The Rule: Production deployments must follow Expand and Contract database migrations (additive changes first, deploy code, cleanup in next release).
- If a migration broke backward compatibility: Coordinate with DBAs to apply a compensating forward migration or restore DB snapshot before reverting code.
Post-Incident & Blameless Post-Mortem
Preventing the same failure in future releases:
- Conduct blameless post-mortem: Why didn't automated CI tests or staging catch this?
- Implement Canary Deployments with Argo Rollouts or Flagger: Route 5% traffic to canary; automatically abort if 5xx errors spike without human intervention.
- Add automated smoke tests and readiness probe validation.
- Immediate action: Run 'kubectl rollout undo deployment/<name>' to revert to previous ReplicaSet.
- If GitOps (ArgoCD/Flux): Disable auto-sync immediately or 'git revert HEAD && git push' so self-heal doesn't re-break it.
- Database check: Verify if DB migrations ran. If additive, rollback is safe. If destructive, apply compensating migration.
- Verify recovery: Monitor 'kubectl rollout status', ALB 5xx metrics, and application logs.
- Post-mortem: Implement progressive delivery (Argo Rollouts/Canary) with automatic metric-based rollback.
Mastered this procedure? Subscribe to @naveedkumbhar01 on YouTube for daily 60-second SRE incident runbooks, Kubernetes triage shortcuts, and high-impact interview elevator pitches.
Senior hiring managers and bar raisers evaluate how you prioritize during outages. Avoid these common anti-patterns:
- Over-granting cluster-admin permissions to pod ServiceAccounts instead of scoping namespace Roles when configuring Deployment Breaks Fast Over-granting cluster-wide permissions violates least-privilege principles and allows compromised pods to escalate privileges across namespaces.
-
Referencing mutable latest container tags across production Kubernetes Deployment specs when configuring Deployment Breaks Fast
Deployments referencing
:latestrisk inconsistent versions across replica pods and break deterministic rollback capabilities. - Omitting pod readiness probes, causing traffic to hit uninitialized application containers when configuring Deployment Breaks Fast Readiness probes gate traffic delivery; missing probes cause Kubernetes to route user requests to pods before dependencies or caches are loaded.
- Executing diagnostic triage without analyzing chronological cluster events and describe outputs when configuring Deployment Breaks Fast Cluster events provide sequential timestamps of scheduler decisions, probe failures, and image pull timeouts essential for rapid root-cause isolation.