# Canary releases with the Gateway API

> A header rule to test, a small weight for real users, then all of it: running a canary with HTTPRoute weights, what to watch at each step, and why you scale the new version before you raise its weight.

- Canonical: https://www.alpacamango.com/docs/gateway-api-canary-releases
- Author: Captain Spitt McGee
- Published: 2026-11-23 · Updated: 2026-11-20
- Topics: Kubernetes, DevOps, Gateway API

**A canary with the Gateway API is three edits to one HTTPRoute: a header rule so you can try the new version yourself, then a small weight for real users, then all the weight. The route moves requests, not capacity, so scale the new version before you raise its weight, and decide before you start which number on which dashboard sends you back.**

*Based on the article from Gazeek, our sister site for hands-on CKA and CKAD labs: *[*Blue/green deployments with the Gateway API*](https://gazeek.com/blog/blue-green-deployments-with-gateway-api?utm_source=alpacamango)*. It has the complete Gateway and HTTPRoute, the patch commands and a walkthrough on a real cluster; this page is about running the release.*

## Weights are shares of requests, not of users

Each backend in a rule gets its weight divided by the sum of the weights in that rule. 9 and 1 is the same split as 90 and 10; an omitted weight counts as 1; a weight of 0 sends nothing. Two consequences matter more than the arithmetic.

First, the split is per request. One user can load a page from stable and its next API call from the canary. If the two versions disagree about a cookie, a schema or an asset hash, that user sees the bug and your error graph may not. The standard channel offers no stickiness (the experimental `sessionPersistence` field is already deprecated), so make adjacent versions compatible or keep the canary to stateless paths.

Second, the split ignores Pod counts. With a Service-selector canary, one new Pod among nine old ones gets roughly a tenth of the traffic. Here, 50 per cent goes to green whether green has one replica or ten. Scale green to its share before each step, or the canary fails for capacity rather than for code and you learn nothing.

## The three steps

The order of the two rules does not matter. Both match every path, so the specification breaks the tie on header matches: a request carrying the header always reaches green, and everyone else gets the split:

```yaml
rules:
- matches:
  - headers:
    - name: x-canary
      value: "true"
  backendRefs:
  - name: shop-green
    port: 80
- backendRefs:
  - name: shop-blue
    port: 80
    weight: 90
  - name: shop-green
    port: 80
    weight: 10
```

1. **Header only** (blue 100, green 0). Your smoke tests and your own browser reach green through the real Gateway, TLS and all. Nobody else does.
2. **A small weight** (90 and 10). Real traffic, real data. Hold it long enough to see a full cycle of whatever your service does: a batch, a cache expiry, a peak hour.
3. **All of it** (0 and 100). Keep blue running and in the route at 0 until you are confident, because that is what makes rolling back one patch.

Rolling back at any step is the same move: put blue back to 100 and green to 0. Nothing is redeployed, so it takes effect as fast as the controller programs its proxies.

## What to watch at each step

Before any weight changes, read the route's status. `Accepted` means the Gateway took the route; `ResolvedRefs` means every backend exists. The second one matters more than it looks: the specification says requests sent to a backend that cannot be resolved get a 500. Misspell the green Service and a 10 per cent canary becomes a 10 per cent outage that looks exactly like a bad release.

After that, compare green with blue, not with yesterday. Error rate and latency per backend, side by side, during the same minutes. Absolute thresholds hide a canary at 10 per cent: a doubling of green's errors barely moves the total. Write the rollback condition down before step 2, such as "green's 5xx rate above blue's for five minutes", so nobody argues about it at 2am.

Long-lived connections are the other trap. Ordinary keep-alive requests are routed one by one, but a WebSocket stays on the backend it opened against, so for those clients a weight change takes effect only as they reconnect.

## By hand or by controller

The Gateway API moves traffic; it does not judge the result. Patching weights by hand is fine for a team that releases weekly and watches the dashboards anyway. Once you release several times a day, hand the judging to a progressive-delivery controller: Flagger, or Argo Rollouts with its Gateway API plugin. Both step HTTPRoute weights and roll back on metrics. They then own those weights, so a manual patch will not last.

If you have not yet moved off Ingress annotations, [the Gateway API for people who know Ingress](/docs/gateway-api-for-ingress-users) covers the model, and the [blue/green version of this route](/docs/kubernetes-blue-green-with-gateway-api) is the same YAML with only two weights. Gazeek's CKAD course practises the strategies themselves in its [rollouts and strategies module](https://gazeek.com/courses/ckad?utm_source=alpacamango#module-04-rollouts-and-strategies).

## The diagram

One HTTPRoute behind a Gateway, with the header rule sending testers to green and the weighted rule splitting everyone else, and the three steps of the release beside it. [Open it in archhy](https://archhy.com/d/Yu2cFjwh2TF5?utm_source=alpacamango) and press Make a copy to adapt it.

## Go deeper

Gazeek's [full article](https://gazeek.com/blog/blue-green-deployments-with-gateway-api?utm_source=alpacamango) builds the Gateway and the route on a real cluster and shows the JSON patch that changes the weights. Once your Gateway serves HTTPS, [TLS on a Gateway with cert-manager](/docs/cert-manager-gateway-api-tls) covers the certificate side.
