Continuous delivery and deployment
How a tested artifact reaches users safely: delivery against deployment, promoting one immutable image, recreate/rolling/blue-green/canary, canary statistics, feature flags, expand/contract migrations, and small batches.
Delivery and deployment
Tests run on a copy of the world; only production proves a release. Two neighbouring practices close that gap. Continuous delivery: every change that passes the pipeline is releasable — a human or a business rule pushes the button. Continuous deployment: that same change goes to production automatically when green. Both need an automated pipeline, one artifact built once, and deployments that are routine and reversible. Neither is "we have a Jenkins job that SSHes and runs scripts differently every Friday."
The distinction matters for risk policy. A bank may require a human approval gate (delivery) while an internal tool deploys on green (deployment). The machinery underneath is the same: small batches, fast feedback, and a rollback that is as boring as the rollout. DORA's change fail rate and recovery time measure whether that machinery works — not whether you renamed the gate.
One artifact, many environments
Promote the same digest through environments. Config — database addresses, credential references, replica counts, flag defaults — comes from the environment (ConfigMaps, secret stores, parameter stores), not from rebuilding the image with different ENV baked in. Rebuilding for staging vs production means you never tested the bytes you ship. In GitOps a repo holds one desired-state file (or Helm/Kustomize overlay) per environment; deploy is a commit that changes the digest pointer; rollback is git revert of that commit and another reconcile.
Strategies while v1 still serves and v2 takes over:
- Recreate — stop v1, start v2. Downtime equals boot + readiness; never both versions. Fine for internal tools with a maintenance window; hostile to a 99.9% SLO.
- Rolling — replace instances in batches; both versions serve. Needs backward-compatible APIs and schemas for the overlap window.
- Blue-green — full v2 idle beside v1; one traffic switch; fast switch-back. Costs 2× capacity during the cutover; rollback is re-pointing the balancer.
- Canary — a small traffic share (1%, then 5%, then 25%…) grows on metrics; a bad canary is stopped before the blast radius is the whole fleet.
Pick from blast radius and cost. A 40-instance service rolling 25% at a time exposes 10 instances to a bad binary — canary with 2 instances first is cheaper insurance when you have the metrics.
Canaries and statistics
A canary's error rate is noisy. At 10 RPS to a canary, a true 2% error regression yields about 0.2 errors/s — in a 60 s window you expect ~12 errors vs ~0 on a healthy baseline at 0.1%. Declare success only with enough requests that a real regression is distinguishable from chance; otherwise you "prove" a bad release good and promote it. Rule of thumb: decide the minimum detectable effect (say +1 pp absolute error) and the observation window before the canary starts, not after you are staring at a flapping graph.
Compare canary against a control slice of baseline traffic in the same window, not against yesterday's average — diurnal traffic shifts confuse absolute thresholds. Rollback must be the same operation as deploy: move the digest pointer or the traffic weight, not SSH archaeology across twenty boxes. Time-to-rollback of 2–5 minutes is a realistic target when the pipeline and balancer are the only moving parts; 45 minutes of "who has the kubeconfig" is a process failure.
Worked exposure. Canary at 5% of 2 000 RPS = 100 RPS. In 10 minutes that is 60 000 requests — enough to see a 0.5% → 2% error jump with confidence. At 0.5% of traffic you wait longer or accept more uncertainty.
Flags and migrations
Feature flags separate deploying code from enabling behaviour. Ship dark; enable for staff, then 1% of users, then everyone; disable instantly without a redeploy when the metric moves the wrong way. Flags are not free — they are branching debt — so retire them when the experiment ends.
Schema changes use expand/contract: add new structures (expand), dual-write or backfill, switch readers to the new shape, remove the old only when unused (contract). During a rolling update some pods still run v1 while others run v2; a destructive migration that drops a column v1 needs is an outage scheduled as a migration. Expand/contract keeps both versions able to read what they see.
Key idea. Make releasing boring: small, frequent, reversible; one immutable artifact; gradual exposure decided by measurements — not by hope and a status page.
Feature-flag platforms and progressive delivery controllers (Flagger, Argo Rollouts) automate the canary steps: they watch RED metrics, raise traffic weight when burn stays inside a threshold, and revert the weight when it does not. The policy is still yours — the tool only executes it. Without clear SLIs the automation flaps or rubber-stamps bad releases.
Document the rollback owner and the exact command (or Git revert path) in the runbook that the incident commander opens first. A delivery system nobody dares to roll back is continuous only in name. Measure deploy frequency and change-fail rate on the same dashboard as canary success so speed and safety stay coupled — the DORA finding from the first topic, now enforced by machinery.
Next: Networking for services — the hops a request crosses before that artifact answers.
Check your understanding
The same questions as in Pulse. Answers are shared between modes.
Go deeper — optional
Code and labs do not count toward the main percentage or the certificate.
- One artifact through stagesoptional
Promote an immutable image digest staging→canary→prod; forbid rebuild on promote.
~20 min · easier on a computer · The matching course topic has been read.
Self-check in the notebook — not part of mastery or the certificate.
Answers are saved on the server and tied to this browser until you sign in.