Deploy use when you need to work with deployment and CI/CD.
ReadWriteEditGrepGlobBash(git:*)Bash(docker:*)Bash(kubectl:*)
Managing Deployment Rollbacks
Overview
Implement and execute deployment rollback procedures for Kubernetes, ECS, Lambda, and cloud VM deployments. Detect failed deployments via health checks and error rate monitoring, then automatically or manually revert to the last known good version with minimal downtime and data integrity preservation.
Prerequisites
kubectl configured with cluster access and permission to manage deployments
- Deployment history retained (Kubernetes
revisionHistoryLimit, ECS task definition versions)
- Monitoring system tracking error rate, latency, and health check status (Prometheus, Datadog, CloudWatch)
- Previous deployment artifacts (container images, task definitions) still available in the registry
- Database migration strategy that supports backward compatibility (expand-contract pattern)
Instructions
- Detect deployment failure: monitor error rate, P99 latency, pod restart count, and health check responses for 5-10 minutes post-deploy
- Assess rollback scope: determine if the issue is application code, configuration, or infrastructure
- For Kubernetes: execute
kubectl rollout undo deployment/ to revert to the previous revision
- For ECS: update the service to use the previous task definition revision
- For Lambda: point the alias back to the previous function version
- Verify database compatibility: ensure the previous application version works with the current database schema (no forward-only migrations were applied)
- Confirm rollback success: verify health checks pass, error rate returns to baseline, and user-facing functionality is restored
- Generate a post-incident report: document what failed, when rollback was triggered, time to recovery, and root cause
- Create automated rollback rules: configure Kubernetes readiness probes, Argo Rollouts analysis, or CloudWatch alarms to trigger rollback without manual intervention
Output
- Rollback scripts for each deployment target (Kubernetes, ECS, Lambda)
- Automated rollback configuration (Kubernetes probes, Argo Rollouts AnalysisTemplate)
- Post-incident report template with timeline and root cause sections
- Monitoring dashboard with rollback trigger indicators
- Database migration rollback procedures (down migrations, backward-compatible schemas)
Error Handling
| Error |
Cause |
Solution |
no rollout history found |
Revision history limit set to 0 or deployment was created fresh |
Increase revisionHistoryLimit in deployment spec; manually specify the target image tag |
Rollback succeeded but errors persist |
Issue is in configuration or external dependenc
Ready to use deployment-rollback-manager?
|