1
---
2
name: deployment-pipeline-design
3
description: Design multi-stage CI/CD pipelines with approval gates, security checks, and deployment orchestration. Use this skill when designing zero-downtime deployment pipelines, implementing canary rollout strategies, setting up multi-environment promotion workflows, or debugging failed deployment gates in CI/CD.
4
---
5
6
# Deployment Pipeline Design
7
8
Architecture patterns for multi-stage CI/CD pipelines with approval gates, deployment strategies, and environment promotion workflows.
9
10
## Purpose
11
12
Design robust, secure deployment pipelines that balance speed with safety through proper stage organization, automated quality gates, and progressive delivery strategies. This skill covers both the structural design of pipeline architecture and the operational patterns for reliable production deployments.
13
14
## Input / Output
15
16
### What You Provide
17
18
- **Application type**: Language/runtime, containerized or bare-metal, monolith or microservices
19
- **Deployment target**: Kubernetes, ECS, VMs, serverless, or platform-as-a-service
20
- **Environment topology**: Number of environments (dev/staging/prod), region layout, air-gap requirements
21
- **Rollout requirements**: Acceptable downtime, rollback SLA, traffic splitting needs, canary vs blue-green preference
22
- **Gate constraints**: Approval teams, required test coverage thresholds, compliance scans (SAST, DAST, SCA)
23
- **Monitoring stack**: Prometheus, Datadog, CloudWatch, or other metrics sources used for automated promotion decisions
24
25
### What This Skill Produces
26
27
- **Pipeline configuration**: Stage definitions, job dependencies, parallelism, and caching strategy
28
- **Deployment strategy**: Chosen rollout pattern with annotated configuration (canary weights, blue-green switchover, rolling parameters)
29
- **Health check setup**: Shallow vs deep readiness probes, post-deployment smoke test scripts
30
- **Gate definitions**: Automated metric thresholds and manual approval workflows
31
- **Rollback plan**: Automated rollback triggers and manual runbook steps
32
33
## When to Use
34
35
- Design CI/CD architecture for a new service or platform migration
36
- Implement deployment gates between environments
37
- Configure multi-environment pipelines with mandatory security scanning
38
- Establish progressive delivery with canary or blue-green strategies
39
- Debug pipelines where stages succeed but production behavior is wrong
40
- Reduce mean time to recovery by automating rollback on metric degradation
41
42
## Detailed patterns and worked examples
43
44
Detailed pattern documentation lives in `references/details.md`. Read that file when the navigation tier above is insufficient.
45
46
## Troubleshooting
47
48
### Health check passes in pipeline but service is unhealthy in production
49
50
The pipeline health check is hitting a shallow `/ping` endpoint that returns 200 even when the database is unreachable. Use a deep readiness check that verifies actual dependencies (see Health Checks section above).
51
52
### Canary deployment never promotes to 100%
53
54
Argo Rollouts requires a valid `AnalysisTemplate` to auto-promote. If the Prometheus query returns no data (e.g., metric name changed), the analysis stays inconclusive and promotion stalls. Add `inconclusiveLimit` so the rollout fails fast rather than hanging:
55
56
```yaml
57
spec:
58
metrics:
59
- name: error-rate
60
failureCondition: "result[0] > 0.05"
61
inconclusiveLimit: 2 # fail after 2 inconclusive results, not hang indefinitely
62
provider:
63
prometheus:
64
query: |
65
sum(rate(http_requests_total{status=~"5.."}[2m]))
66
/ sum(rate(http_requests_total[2m]))
67
```
68
69
### Staging deploy succeeds but production job never starts
70
71
Check that production environment protection rules are configured — a missing reviewer assignment means the approval gate waits indefinitely with no notification. In GitHub Actions, ensure `Required reviewers` is set to an existing user or team in **Settings → Environments → production**.
72
73
### Docker layer cache busted on every run causing slow builds
74
75
If `COPY . .` appears before dependency installation, any source file change invalidates the dependency layer. Reorder to copy dependency manifests first:
76
77
```dockerfile
78
# Good: dependencies cached separately from source code
79
COPY package*.json ./
80
RUN npm ci
81
COPY . .
82
RUN npm run build
83
```
84
85
### Rollback leaves database migrations applied to old code
86
87
A service rollback without a migration rollback causes schema/code mismatch errors. Always make migrations backward-compatible (additive only) for at least one release cycle, and keep undo scripts versioned alongside the migration:
88
89
```bash
90
# migrations/V20240315__add_nullable_column.sql (forward)
91
# migrations/V20240315__add_nullable_column.undo.sql (backward)
92
```
93
94
Never run destructive migrations (DROP COLUMN, ALTER NOT NULL) until the old code version is fully retired from all environments.
95
96
## Advanced Topics
97
98
For platform-specific pipeline configurations, multi-region promotion workflows, and advanced Argo Rollouts patterns, see:
99
100
- [`references/advanced-strategies.md`](references/advanced-strategies.md) — Extended YAML examples, platform-specific configs (GitHub Actions, GitLab CI, Azure Pipelines), multi-region canary patterns, and database migration rollback strategies
101
102
## Related Skills
103
104
- `github-actions-templates` - For GitHub Actions implementation patterns and reusable workflows
105
- `gitlab-ci-patterns` - For GitLab CI/CD pipeline implementation
106
- `secrets-management` - For secrets handling in CI/CD pipelines
107