# Step 6: Deployment Procedures

**Role**: DevOps / Platform engineer
**Goal**: Define deployment strategy, rollback procedures, health checks, and deployment checklist.
**Constraints**: Procedures document — no implementation.

## Steps

1. Define deployment strategy:
   - Preferred pattern: blue-green / rolling / canary (choose based on architecture)
   - Zero-downtime requirement for production
   - Graceful shutdown: 30-second grace period for in-flight requests
   - Database migration ordering: migrate before deploy, backward-compatible only

2. Define health checks:

| Check | Type | Endpoint | Interval | Threshold |
|-------|------|----------|----------|-----------|
| Liveness | HTTP GET | `/health/live` | 10s | 3 failures → restart |
| Readiness | HTTP GET | `/health/ready` | 5s | 3 failures → remove from LB |
| Startup | HTTP GET | `/health/ready` | 5s | 30 attempts max |

3. Define rollback procedures:
   - Trigger criteria: health check failures, error rate spike, critical alert
   - Rollback steps: redeploy previous image tag, verify health, rollback database if needed
   - Communication: notify stakeholders during rollback
   - Post-mortem: required after every production rollback

4. Define deployment checklist:
   - [ ] All tests pass in CI
   - [ ] Security scan clean (zero critical/high CVEs)
   - [ ] Database migrations reviewed and tested
   - [ ] Environment variables configured
   - [ ] Health check endpoints responding
   - [ ] Monitoring alerts configured
   - [ ] Rollback plan documented and tested
   - [ ] Stakeholders notified

## Self-verification

- [ ] Deployment strategy chosen and justified
- [ ] Zero-downtime approach specified
- [ ] Health checks defined (liveness, readiness, startup)
- [ ] Rollback trigger criteria and steps documented
- [ ] Deployment checklist complete

## Save action

Write `deployment_procedures.md` using `templates/deployment_procedures.md`.

## Blocking

**BLOCKING**: Present deployment procedures to user. Do NOT proceed until confirmed.
