rollback-deployment
Rollback a deployment to its previous revision. Use when a new deployment causes issues and needs to be reverted quickly. Keywords: rollback, revert, deployment, previous version, undo deployment.
When & Why to Use This Skill
This Claude skill automates the restoration of Kubernetes deployments to their previous stable revisions. Designed for SRE and DevOps teams, it streamlines incident response by quickly reverting faulty updates, ensuring service availability and minimizing downtime through automated ReplicaSet management and verification.
Use Cases
- Emergency Rollback: Quickly revert a production deployment that is causing high error rates or latency immediately after a new release.
- Configuration Recovery: Undo changes when a new deployment contains incorrect environment variables or secret references that prevent service startup.
- Failed Health Checks: Rapidly restore service when a new version passes CI/CD but fails live readiness or liveness probes in the production environment.
- Automated Remediation: Use as a programmable action within an automated healing workflow to resolve deployment-related incidents without manual CLI intervention.
| name | rollback-deployment |
|---|---|
| description | > |
| causes issues and needs to be reverted quickly. Keywords | rollback, revert, |
| domain | k8s |
| category | remediation |
| requires-approval | true |
| confidence | 0.85 |
Rollback Deployment
Preconditions
Before applying this skill, verify:
- Deployment name and namespace are known
- Previous revision exists
- Current revision is causing issues
Actions
1. Get Current Deployment
Check current revision and status.
mcp_tool: kubernetes-mcp-server/resources_get
params:
apiVersion: apps/v1
kind: Deployment
name: $deployment_name
namespace: $namespace
timeout: 30s
2. Get ReplicaSet History
List ReplicaSets to find previous revision.
mcp_tool: kubernetes-mcp-server/resources_list
params:
apiVersion: apps/v1
kind: ReplicaSet
namespace: $namespace
labelSelector: app=$app_label
timeout: 30s
3. Rollback to Previous Revision
Update deployment to use previous ReplicaSet's spec.
mcp_tool: kubernetes-mcp-server/resources_create_or_update
params:
resource: |
apiVersion: apps/v1
kind: Deployment
metadata:
name: $deployment_name
namespace: $namespace
annotations:
kubernetes.io/change-cause: "Rollback by kubani healer"
spec:
template:
$previous_pod_spec
timeout: 60s
4. Verify Rollback
Confirm new pods are running with previous spec.
mcp_tool: kubernetes-mcp-server/resources_get
params:
apiVersion: apps/v1
kind: Deployment
name: $deployment_name
namespace: $namespace
timeout: 30s
Success Criteria
The skill succeeds when:
- Deployment revision incremented
- New pods running with previous spec
- All replicas available
- No pods in error state
Failure Handling
If rollback fails:
- Check if previous revision exists
- Verify resource quotas allow rollback
- Check for immutable field violations
- May need manual intervention
Examples
Input Context:
{
"deployment_name": "api-server",
"namespace": "production",
"app_label": "api-server"
}
Output:
{
"deployment": "api-server",
"previous_revision": 5,
"current_revision": 6,
"rolled_back_to": 5,
"replicas_available": 3,
"success": true
}