Module 6 · Reliability and infrastructureLesson 71 of 886 minBeginner
CI/CD
CI/CD automatically builds, tests and releases every change, in small steps, so shipping is routine instead of risky.
Ship a good change, then a bug that the tests catch, then one only the canary catches.
Most outages are caused by changes. CI/CD makes change safe by making it small, automatic and reversible.
Continuous integration (CI)
Every push triggers a pipeline:
- Build the code.
- Run tests: unit, integration, linting, type checks, security scans.
- Produce an artifact, usually a container image tagged with the commit.
Developers merge small changes often (at least daily), so conflicts stay small and problems are found while the change is fresh.
Continuous delivery and deployment (CD)
- Continuous delivery: every passing build is ready to deploy with one click.
- Continuous deployment: every passing build goes to production automatically.
Safe rollout strategies
- Rolling update: replace instances a few at a time.
- Blue-green: run the new version (green) next to the old (blue), then switch all traffic at once. Switching back is instant.
- Canary: send 1 to 5% of traffic to the new version, compare its error rate and latency with the old, then increase gradually.
- Feature flags: deploy code switched off, then turn features on for some users. Separates deploying from releasing.
Rollbacks
Make rolling back boring: a single command or automatic on bad metrics. Watch out for database migrations; they can make rollback impossible. Use the expand-and-contract pattern: add the new column, deploy code that writes both, backfill, switch reads, and only later remove the old column.
Tools
GitHub Actions, GitLab CI, Jenkins and CircleCI run pipelines. Argo CD and Flux deploy to Kubernetes from Git (GitOps). Argo Rollouts and Flagger automate canaries.