| name | rollback |
| description | Roll back a failed deployment to the previous revision |
| disable-model-invocation | true |
| argument-hint | [service] [env] |
/rollback [service] [env]
Roll back a failed deployment to its previous working revision.
Arguments
service — Service to roll back (e.g., api-gateway, customers-service) or all
env — Target environment: dev or prod (default: dev)
Steps
-
Set the namespace:
dev → petclinic-dev
prod → petclinic-prod
-
Show current rollout status and history:
kubectl rollout status deployment/{service} -n petclinic-{env}
kubectl rollout history deployment/{service} -n petclinic-{env}
-
Show what changed in the current revision vs previous:
kubectl rollout history deployment/{service} -n petclinic-{env} --revision={current}
kubectl rollout history deployment/{service} -n petclinic-{env} --revision={previous}
-
For prod: require explicit confirmation.
Show: "Rolling back {service} in PRODUCTION to revision {N}. This will change the running image. Confirm?"
-
Execute the rollback:
kubectl rollout undo deployment/{service} -n petclinic-{env}
-
Monitor rollout:
kubectl rollout status deployment/{service} -n petclinic-{env} --timeout=120s
-
Verify the rollback:
kubectl get pods -l app.kubernetes.io/name={service} -n petclinic-{env}
-
If rolling back all:
- Roll back in reverse order (application services first, then discovery, then config)
- Verify each service before proceeding to the next
- If any rollback fails, stop and report
-
Show summary:
## Rollback: {service} ({env})
Previous revision: {N} (image: {old-image})
Rolled back to: {N-1} (image: {previous-image})
Status: {success/failed}
Pod status: {Running/etc}
Important
- Always get explicit confirmation for prod rollbacks
- When rolling back
all, go in reverse deployment order
- If rollback fails, do NOT retry — investigate first
- Suggest running
/smoke-test {env} after rollback to verify health