Progressive delivery: canaries and blue-green

Advanced · 17 min

Releasing to a slice of traffic first: canaries by replica count or traffic weight, blue-green switches, automated analysis, and Argo Rollouts and Flagger.

Before thisRolling updates and rollbacksArgo CD in practiceThe Gateway API

wiggitywhitney · 17 min

Progressive delivery: canaries and blue-green

The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.

Taught by wiggitywhitneyReport a problem with this video
Not started
Set this lesson's status

What you'll learn

  • A rolling update checks only that new Pods become ready, not that they behave. Progressive delivery exposes a new version to a small, controlled share of traffic and promotes it only if real metrics stay healthy.
  • With plain Kubernetes, a canary is a second Deployment behind the same Service, and its share is its share of endpoints: 1 of 10 Pods is about 10% of connections, with no finer control.
  • Precise weights (1%, 5%) need a traffic layer: Gateway API HTTPRoute weights, an ingress controller or a service mesh, independent of replica counts.
  • Blue-green runs the full new version beside the old and switches all traffic at once, with an instant switch back. It costs double capacity during the release.
  • Argo Rollouts (a Rollout replacing the Deployment) and Flagger (a Canary wrapping an existing Deployment) automate steps, weights, pauses and metric analysis, and roll back on their own.
  • Analysis is the point: error rate and latency from Prometheus or similar, compared against thresholds at each step. Without it a canary is just a slow rollout.

Ready isn’t the same as correct

A rolling update replaces Pods a few at a time and stops if new Pods fail their readiness probes. That catches crashes and broken start-up. It doesn’t catch the new version returning wrong prices, leaking memory over twenty minutes, or erroring for 3% of users on one browser. By the time anyone notices, every Pod runs the bad version and every user has seen it.

Progressive delivery limits the blast radius. Release the new version to a small slice of traffic, measure how it behaves against the old one, then widen or roll back, ideally automatically. The two classic shapes are canary (gradual) and blue-green (all at once, with a quick way back).

A canary with nothing but Kubernetes

The simplest canary is two Deployments whose Pods share the label a Service selects:

apiVersion: apps/v1
kind: Deployment
metadata: {name: checkout-stable, namespace: shop}
spec:
  replicas: 9
  selector: {matchLabels: {app: checkout, track: stable}}
  template:
    metadata: {labels: {app: checkout, track: stable}}
    spec:
      containers: [{name: checkout, image: "registry.example.com/checkout:2.0.0"}]
---
# checkout-canary: identical but replicas: 1, track: canary, image 2.1.0
---
apiVersion: v1
kind: Service
metadata: {name: checkout, namespace: shop}
spec:
  selector: {app: checkout}
  ports: [{port: 80, targetPort: 8080}]

On a lab cluster, with Pods marked ready by hand since nothing runs containers, the Service’s EndpointSlices counted:

Counter({('checkout-stable', True): 9, ('checkout-canary', True): 1})

kube-proxy spreads connections evenly across ready endpoints, so the canary gets roughly 10% of connections. It works, but the weight is tied to replica counts (1% needs 99 stable Pods), long-lived connections skew it, and promotion and rollback are manual edits.

Weights from the traffic layer

To decouple traffic share from Pod count, route by weight above the Service. With the Gateway API:

apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata: {name: checkout, namespace: shop}
spec:
  parentRefs: [{name: public}]
  rules:
  - backendRefs:
    - {name: checkout-stable, port: 80, weight: 95}
    - {name: checkout-canary, port: 80, weight: 5}

Now one canary Pod can take exactly 5% of requests. Meshes and ingress controllers offer the same, plus header-based routing (send only internal users, or requests with a cookie, to the canary), which is how A/B tests and dark launches work.

Blue-green

Blue-green runs a complete second copy, green, alongside the live one, blue. Test green through a preview Service, then switch the live Service’s selector (or the route) to green in one step. If something’s wrong, switch back. Blue is still running. It suits releases where old and new can’t serve side by side, such as an incompatible session format. The costs are double capacity during the release, and the fact that every user moves at once, so problems that only show under full load appear all at once too.

Automating it: Argo Rollouts and Flagger

Doing the steps by hand at 2 a.m. doesn’t scale. Two CNCF tools automate them.

Argo Rollouts (v1.10.2 when checked) replaces the Deployment with a Rollout that carries the strategy:

apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata: {name: checkout, namespace: shop}
spec:
  replicas: 10
  selector: {matchLabels: {app: checkout}}
  template:
    metadata: {labels: {app: checkout}}
    spec:
      containers:
      - name: checkout
        image: registry.example.com/checkout:2.1.0
  strategy:
    canary:
      canaryService: checkout-canary
      stableService: checkout-stable
      steps:
      - setWeight: 10
      - pause: {duration: 10m}
      - analysis:
          templates: [{templateName: error-rate}]
      - setWeight: 50
      - pause: {}

I installed the Rollout CRD from v1.10.2 into the lab API server. The Rollout above was accepted, and a step with setWeight: ten was refused by the schema: setWeight in body must be of type integer. No Rollouts controller ran, so nothing progressed. Per its docs, the controller manages the ReplicaSets, sets weights through a configured traffic router (Gateway API, Istio, NGINX, ALB and others) or by replica ratio when there is none, pauses (pause: {} waits for a human promote), and runs an AnalysisRun from an AnalysisTemplate that queries Prometheus, Datadog, a Job or a web endpoint. A failed analysis aborts the rollout and shifts traffic back to stable. Blue-green is a different strategy with activeService and previewService.

Flagger (v1.45 when checked, part of the Flux project) takes the other approach. You keep your Deployment, and a Canary resource tells Flagger to create a -primary copy that serves production and to treat changes to your Deployment as canary releases. It shifts traffic in steps through a mesh, ingress or Gateway API, checks built-in metrics such as request success rate and duration, and promotes or rolls back. It fits naturally with GitOps, since Git still holds an ordinary Deployment.

What to measure

The analysis decides everything, so choose metrics that would catch a bad release:

  • Error rate of the canary compared with stable, not against a fixed number, so an incident in a shared dependency doesn’t fail every canary.
  • Latency percentiles (p95 or p99), not averages.
  • Business signals where you have them: checkouts completed, logins succeeded.
  • Enough traffic and time for the numbers to mean something. Five requests at 1% tell you nothing.

These depend on metrics and monitoring, and they only work if old and new versions are labelled distinctly in your metrics.

About the video

The embed is Whitney Lee’s “Flagger on Kubernetes: Progressive Delivery and Canary Deployments”, September 2025, 17 minutes. Going by its chapters and description, it covers why release automation matters, how Flagger works, blue-green strategies, verifying success with metrics, advanced methods, canaries with session affinity, and getting started. It’s Flagger-specific, while the lesson covers Argo Rollouts too. I judged it from chapters and description only, since transcripts couldn’t be fetched. English was judged from the title, description and English caption track. The page shows no audio-language flag. DevOps Journey’s 15-minute Argo Rollouts video in deeper shows the other tool.

What was run: the two-Deployment canary and its EndpointSlice count, the Rollout CRD install, the accepted Rollout and the schema rejection are real output from a local Kubernetes v1.37.3 API server whose nodes run no containers. No traffic was sent and no Rollouts, Flagger or Gateway controller ran. The weighted HTTPRoute and both tools’ behaviour are from their docs, and versions from their GitHub releases, checked 2026-11-29.

Where this fits

Argo Rollouts and Flagger extend Kubernetes with their own resources. Next, how that works: custom resource definitions.

Check yourself

  1. 01You run 4 stable Pods and 1 canary Pod behind one Service. What share of traffic does the canary get, and why can't you get 1%?

    About 20% of connections, since kube-proxy spreads connections across ready endpoints evenly. Getting 1% that way needs 99 stable Pods. Fine-grained weights need a layer that routes by weight, such as Gateway API, an ingress controller or a mesh.

  2. 02When is blue-green a better choice than a canary?

    When the two versions can't safely serve traffic at the same time (incompatible protocol or session formats), or when you want to test the full new stack before any user sees it and switch back instantly. The cost is double capacity during the switch.

  3. 03A canary step pauses for 10 minutes at 10% traffic, then promotes automatically. What's missing?

    Analysis. Nothing checked whether the canary's error rate or latency was worse. Add an analysis step that queries metrics and aborts and rolls back on a failed threshold, or the pause only delays the outage.

  4. 04What do Argo Rollouts and Flagger change about the Deployment object?

    Argo Rollouts replaces the Deployment with a Rollout custom resource that carries the strategy. Flagger leaves your Deployment as the source of truth, creates a primary copy and Services, and drives traffic through a Canary resource.

Go deeper

Notes

Private to you

Esc
↑↓ navigate↵ open? shortcuts

Keyboard shortcuts

Press Esc to close

Anywhere

⌘K
Search and commands
/
Search
?
This sheet
Esc
Close

Reading a lesson

J
Next lesson
K
Previous lesson
B
Bookmark