TExcelTAD
Home › GitOps: Argo CD & Flux › Argo Rollouts & Gateway API Canaries

Argo Rollouts & Gateway API Canaries

GitOps decides what version runs; it doesn't decide how carefully the switch happens. A Deployment's rolling update replaces Pods as soon as they pass readiness probes, which catches crashes but not a release that is up and returning wrong results or slowly leaking errors. Progressive delivery shifts traffic to the new version in steps, measures it, and rolls back automatically if the metrics go bad. CI/CD: Canary Releases introduced the idea with simulations; this lesson shows the Kubernetes tooling: Argo Rollouts (and its Flux-side sibling, Flagger), with traffic split by the Gateway API.

Rollout: a Deployment with a strategy

Argo Rollouts adds a Rollout CRD that replaces a Deployment (same Pod template) and a controller that manages two ReplicaSets, stable and canary, plus the traffic between them. A canary strategy is a list of steps:

yaml
strategy:
  canary:
    canaryService: linkly-canary     # Service selecting canary Pods (the controller manages the selector)
    stableService: linkly-stable     # Service selecting stable Pods
    trafficRouting:
      plugins:
        argoproj-labs/gatewayAPI:    # the Gateway API traffic-router plugin
          httpRoute: linkly
          namespace: linkly-prod
    steps:
      - setWeight: 10                # 10% of requests to the new version
      - pause: {duration: 5m}
      - analysis:                    # query metrics; failure aborts and rolls back
          templates: [{templateName: linkly-success-rate}]
      - setWeight: 50
      - pause: {duration: 10m}
      # after the last step: 100%, canary becomes the new stable

With the Gateway API plugin, the controller changes the weights of the two backendRefs in the HTTPRoute, so the split is exact at the request level, independent of how many Pods each side has. (Without a traffic router, Rollouts approximates weights by Pod counts.) The plugin is registered in the argo-rollouts-config ConfigMap under trafficRouterPlugins, with the name argoproj-labs/gatewayAPI and the download location of the plugin binary for your release.

Validate the pieces offline

The image's kubeconform has schemas for Rollouts, AnalysisTemplates and Gateway API routes, so the whole canary setup can be checked in CI:

bash · try it yourself
cat > canary.yaml <<'EOF'
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata: {name: linkly, namespace: linkly-prod}
spec:
  replicas: 4
  revisionHistoryLimit: 3
  selector: {matchLabels: {app.kubernetes.io/name: linkly}}
  template:
    metadata: {labels: {app.kubernetes.io/name: linkly}}
    spec:
      containers:
        - {name: linkly, image: "ghcr.io/acme/linkly:1.5.0", ports: [{name: http, containerPort: 8080}]}
  strategy:
    canary:
      canaryService: linkly-canary
      stableService: linkly-stable
      trafficRouting:
        plugins:
          argoproj-labs/gatewayAPI: {httpRoute: linkly, namespace: linkly-prod}
      steps:
        - setWeight: 10
        - pause: {duration: 5m}
        - analysis: {templates: [{templateName: linkly-success-rate}]}
        - setWeight: 50
        - pause: {duration: 10m}
---
apiVersion: argoproj.io/v1alpha1
kind: AnalysisTemplate
metadata: {name: linkly-success-rate, namespace: linkly-prod}
spec:
  metrics:
    - name: success-rate
      interval: 1m
      count: 5
      failureLimit: 1
      successCondition: result[0] >= 0.99
      provider:
        prometheus:
          address: http://prometheus.monitoring:9090
          query: |
            sum(rate(http_requests_total{service="linkly-canary",code!~"5.."}[2m]))
            / sum(rate(http_requests_total{service="linkly-canary"}[2m]))
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata: {name: linkly, namespace: linkly-prod}
spec:
  parentRefs: [{name: public, namespace: gateway-system}]
  hostnames: [lnk.example.com]
  rules:
    - backendRefs:
        - {name: linkly-stable, port: 80, weight: 100}
        - {name: linkly-canary, port: 80, weight: 0}
EOF
kubeconform -strict -summary canary.yaml
yq -N 'select(.kind == "HTTPRoute") | .spec.rules[0].backendRefs[] | .name + " weight=" + (.weight | tostring)' canary.yaml
Summary: 3 resources found in 1 file - Valid: 3, Invalid: 0, Errors: 0, Skipped: 0
linkly-stable weight=100
linkly-canary weight=0

The HTTPRoute starts at 100/0. During the rollout the controller patches those weights (10/90, then 50/50), which is drift by design: tell Argo CD to ignore /spec/rules weights on that HTTPRoute (ignoreDifferences with RespectIgnoreDifferences=true), or the GitOps agent and the Rollouts controller will fight. The same applies to the Services' selectors, which the controller also manages.

A canary, modelled

This model plays a release through the steps above with fixed metric readings per minute. The analysis needs 5 measurements at ≥ 99% success and tolerates one failure (failureLimit: 1, so a second failure aborts):

python · try it yourself
STEPS = [("setWeight", 10), ("pause", 5), ("analysis", 5), ("setWeight", 50), ("pause", 10)]

def run(release, success_rates):
    weight, minute, failures, readings = 0, 0, 0, iter(success_rates)
    for kind, value in STEPS:
        if kind == "setWeight":
            weight = value
            print(f"  t={minute:>2}m  route: stable {100 - weight} / canary {weight}")
        elif kind == "pause":
            minute += value
        else:
            for _ in range(value):
                minute += 1
                rate = next(readings)
                ok = rate >= 0.99
                failures += not ok
                print(f"  t={minute:>2}m  success-rate {rate:.3f} {'ok' if ok else 'FAILED'}")
                if failures > 1:
                    print(f"  t={minute:>2}m  analysis failed -> abort: route stable 100 / canary 0, scale canary down")
                    return f"{release}: Degraded (aborted), stable version keeps serving"
    print(f"  t={minute:>2}m  route: stable 0 / canary 100, canary promoted to stable")
    return f"{release}: Healthy, fully promoted"

print(run("1.5.0", [0.998, 0.995, 0.981, 0.997, 0.999]))
print(run("1.5.1", [0.996, 0.970, 0.962, 0.990, 0.999]))
  t= 0m  route: stable 90 / canary 10
  t= 6m  success-rate 0.998 ok
  t= 7m  success-rate 0.995 ok
  t= 8m  success-rate 0.981 FAILED
  t= 9m  success-rate 0.997 ok
  t=10m  success-rate 0.999 ok
  t=10m  route: stable 50 / canary 50
  t=20m  route: stable 0 / canary 100, canary promoted to stable
1.5.0: Healthy, fully promoted
  t= 0m  route: stable 90 / canary 10
  t= 6m  success-rate 0.996 ok
  t= 7m  success-rate 0.970 FAILED
  t= 8m  success-rate 0.962 FAILED
  t= 8m  analysis failed -> abort: route stable 100 / canary 0, scale canary down
1.5.1: Degraded (aborted), stable version keeps serving

In the bad case 90% of users never saw 1.5.1, and the abort happened without a human. Git still says 1.5.1, so the Rollout stays Degraded (Argo CD shows the app Degraded, via the built-in Rollout health check) until someone reverts the commit or ships a fix: the same "Git is the truth, the controller protects production" split as Flux's Helm remediation.

Operating a rollout (sample session)

bash
kubectl argo rollouts get rollout linkly -n linkly-prod --watch
kubectl argo rollouts promote linkly -n linkly-prod     # skip the current pause
kubectl argo rollouts abort linkly -n linkly-prod       # back to stable now
text
Name:            linkly
Namespace:       linkly-prod
Status:          ॥ Paused
Message:         CanaryPauseStep
Strategy:        Canary
  Step:          1/5
  SetWeight:     10
  ActualWeight:  10
Images:          ghcr.io/acme/linkly:1.4.1 (stable)
                 ghcr.io/acme/linkly:1.5.0 (canary)
Replicas:
  Desired:       4
  Current:       5
  Updated:       1
  Ready:         5
  Available:     5

Blue-green and the alternatives

  • Blue-green in Rollouts: strategy.blueGreen with an activeService and a previewService; the new version runs fully next to the old one, prePromotionAnalysis tests it through the preview Service, and promotion switches the active Service in one step. Simpler than canary, twice the capacity during the switch.
  • Flagger (Flux project): the same idea with a different shape. You keep a normal Deployment, and a Canary object tells Flagger to create the primary/canary copies and shift traffic, with Gateway API among its supported routers. It pairs naturally with Flux, but works with any deployment tool.
  • Gateway API alone gives you the weighted backendRefs used above. You can do a manual canary in Git (commit 90/10, watch, commit 50/50), which is slow but needs no extra controller. Prefer Gateway API over ingress annotations: the community ingress-nginx controller was retired in 2026, and Gateway API weights are portable across implementations (see Kubernetes Gateway API).

Test yourself

With the Gateway API traffic-router plugin, how does Argo Rollouts send 10% of requests to the canary?

  1. By running 10% of the Pods as canary
  2. By setting the weights of the stable and canary backendRefs in the HTTPRoute
  3. By DNS round-robin
  4. By editing the Deployment

Why must Argo CD be told to ignore the HTTPRoute's backend weights?

  1. Weights are invalid YAML
  2. The Rollouts controller changes them during a rollout; with self-heal Argo CD would reset them to the Git values
  3. Gateway API forbids it
  4. To speed up syncs

A canary's analysis fails and the Rollout aborts. What does Git say afterwards, and what should happen next?

  1. Git is rolled back automatically
  2. Git still declares the new version; revert the commit or ship a fix
  3. Argo CD deletes the Rollout
  4. Nothing: aborts are final