Ship to 5% of users first and auto-rollback on bad metrics: canary deployments on Kubernetes with Argo Rollouts, Flagger, and Gateway API.
The traditional deployment model has a binary risk profile: either zero users see the new code, or all of them do. The moment you flip that switch, any bug, performance regression, or bad configuration hits your entire user base at once.
A deploy at dinner peak that breaks the order summary screen of a food-delivery app affects hundreds of thousands of active sessions instantly. A platform that ships bad code to 5% of users for five minutes and then rolls back automatically has a completely different risk profile. That is progressive delivery: gradual, automated, metric-driven rollout of new versions.
Progressive delivery releases changes in increments and uses real production metrics to decide whether to continue, pause, or roll back. Three strategies cover most cases:
Canary deployments are the most nuanced and the most powerful. They test the new version on real production traffic without the all-or-nothing risk, and they need no application changes.
A canary rollout moves traffic in steps and checks metrics at each step. If any check fails, all traffic returns to the stable version. The automation is what makes it production-grade, because a human checking dashboards every ten minutes is too slow and unreliable.
Argo Rollouts and Flagger both automate this loop. They differ in how they attach to your workloads and how they split traffic.
Install the controller, replace (or reference) your Deployment with a Rollout, and attach an AnalysisTemplate that queries your metrics. The Rollout CRD supports canary and blue-green strategies natively.
## Install Argo Rolloutskubectl create namespace argo-rolloutskubectl apply -n argo-rollouts \ -f https://github.com/argoproj/argo-rollouts/releases/latest/download/install.yaml ## Install the kubectl pluginbrew install argoproj/tap/kubectl-argo-rolloutsš” Tip: The latest URL above is fine for a first trial. For production, pin a specific release version so upgrades are deliberate.
Here is a Rollout with a canary strategy tied to automated analysis:
apiVersion: argoproj.io/v1alpha1kind: Rolloutmetadata: name: checkout-api namespace: productionspec: replicas: 10 selector: matchLabels: app: checkout-api template: metadata: labels: app: checkout-api spec: containers: - name: checkout-api image: example-org/checkout-api:v2.1.0 resources: requests: cpu: 200m memory: 256Mi strategy: canary: canaryService: checkout-api-canary stableService: checkout-api-stable steps: - setWeight: 5 - pause: {duration: 10m} - analysis: templates: - templateName: success-rate-check args: - name: canary-hash valueFrom: podTemplateHashValue: Latest - setWeight: 30 - pause: {duration: 10m} - setWeight: 60 - pause: {duration: 10m}The final step promotes the rollout to 100% automatically once the earlier steps pass. The analysis step queries Prometheus, compares the canary against your threshold, and either continues or aborts and rolls back.
š Remember: Without a traffic router configured, Argo Rollouts approximates weights by scaling pod counts. With 10 replicas, the smallest possible canary is 10%, not 5%. Add a traffic router (shown below) for exact percentages.
An AnalysisTemplate defines the metrics, how often to sample them, and what counts as success. The template below checks success rate and P99 latency on the canary pods only.
apiVersion: argoproj.io/v1alpha1kind: AnalysisTemplatemetadata: name: success-rate-check namespace: productionspec: args: - name: canary-hash metrics: - name: success-rate interval: 2m count: 5 successCondition: result[0] >= 0.95 failureLimit: 1 provider: prometheus: address: http://prometheus.monitoring:9090 query: | sum(rate(http_requests_total{ rollouts_pod_template_hash="{{args.canary-hash}}", status!~"5.."}[2m])) / sum(rate(http_requests_total{ rollouts_pod_template_hash="{{args.canary-hash}}" }[2m])) - name: latency-p99 interval: 2m count: 5 successCondition: result[0] <= 0.5 failureLimit: 1 provider: prometheus: address: http://prometheus.monitoring:9090 query: | histogram_quantile(0.99, sum by (le) (rate( http_request_duration_seconds_bucket{ rollouts_pod_template_hash="{{args.canary-hash}}" }[2m])))Two details matter. First, count: 5 makes the inline analysis finish after five samples, so the step can complete. Second, the query filters on the pod template hash that Argo Rollouts adds to canary pods, so it measures only the canary. Your Prometheus scrape config must map that pod label (shown here as rollouts_pod_template_hash) onto the metrics, so verify the label exists before trusting the analysis.
If the success rate drops below 95% or P99 latency exceeds 500 ms, the Rollout aborts and returns all traffic to the stable version, with no human needed at 3 AM. You can also run the analysis in the background across all steps instead of at one point, which catches problems that appear between pauses.
Flagger takes a different approach. Your existing Deployment becomes the canary target, and Flagger creates and manages a separate -primary copy that serves stable traffic. That lets you adopt it without rewriting manifests.
For the traffic layer, install Flagger with a supported provider. Since the community Nginx ingress controller is retired (see below), the Gateway API is the sensible choice for new installs:
## Install Flagger with the Gateway API providerhelm repo add flagger https://flagger.apphelm upgrade -i flagger flagger/flagger \ --namespace flagger-system \ --create-namespace \ --set meshProvider=gatewayapi:v1 \ --set metricsServer=http://prometheus.monitoring:9090Define the metric once as a MetricTemplate, then reference it from the Canary:
apiVersion: flagger.app/v1beta1kind: MetricTemplatemetadata: name: error-rate namespace: productionspec: provider: type: prometheus address: http://prometheus.monitoring:9090 query: | 100 * sum(rate(http_requests_total{ namespace="{{ namespace }}", pod=~"{{ target }}-[0-9a-zA-Z]+(-[0-9a-zA-Z]+)", status=~"5.."}[{{ interval }}])) / sum(rate(http_requests_total{ namespace="{{ namespace }}", pod=~"{{ target }}-[0-9a-zA-Z]+(-[0-9a-zA-Z]+)" }[{{ interval }}]))apiVersion: flagger.app/v1beta1kind: Canarymetadata: name: checkout-api namespace: productionspec: targetRef: apiVersion: apps/v1 kind: Deployment name: checkout-api progressDeadlineSeconds: 600 service: port: 80 targetPort: 8080 gatewayRefs: - name: public-gateway namespace: gateway-system analysis: interval: 2m threshold: 5 maxWeight: 50 stepWeight: 10 metrics: - name: error-rate templateRef: name: error-rate namespace: production thresholdRange: max: 1 interval: 1mWhen you change the container image in the Deployment, Flagger detects it and starts the analysis automatically. After five failed checks (threshold: 5) it rolls back. Flagger's built-in request-success-rate and request-duration metrics work with some providers, but a Prometheus MetricTemplate behaves the same everywhere, so it is the safer default.
Use the Kubernetes Gateway API for traffic splitting. The community ingress-nginx controller was retired in March 2026. Existing deployments keep running, but there are no further releases or security fixes, so canary setups built on nginx.ingress.kubernetes.io/canary annotations are now a liability.
The Gateway API expresses weighted routing directly in an HTTPRoute, with no controller-specific annotations:
apiVersion: gateway.networking.k8s.io/v1kind: HTTPRoutemetadata: name: checkout-api namespace: productionspec: parentRefs: - name: public-gateway namespace: gateway-system hostnames: - checkout.example.net rules: - backendRefs: - name: checkout-api-stable port: 80 weight: 90 - name: checkout-api-canary port: 80 weight: 10Flagger manages these weights itself through its Gateway API provider. Argo Rollouts reaches the Gateway API through a traffic router plugin, which you register in the argo-rollouts-config ConfigMap and then reference from the strategy:
## In the Rollout strategy.canary blocktrafficRouting: plugins: argoproj-labs/gatewayAPI: httpRoute: checkout-api namespace: productionConfirm the plugin version and install steps in the Argo Rollouts docs, because plugin releases change independently of the controller. If you run Istio or Linkerd, both tools also support mesh-based splitting, which adds per-request routing such as header-based canaries.
Pick the tool that matches your existing workflow, not the one with the longer feature list.
| Factor | Argo Rollouts | Flagger |
|---|---|---|
| Workload model | Rollout CRD or workloadRef | Wraps existing Deployment |
| GitOps fit | Native with Argo CD | Works with Flux or Argo CD |
| Traffic routing | Gateway API, Istio, others | Gateway API, Istio, Linkerd |
Pick Argo Rollouts if you already run ArgoCD, since canary progress appears in the same UI as your other application state. Rollouts can also reference an existing Deployment through workloadRef, which eases migration. Pick Flagger if you prefer to keep Deployments untouched or you already use Flux. Be careful when pairing Flagger with Argo CD, because both can try to manage replica counts, so exclude those fields from sync.
Blue-green is simpler when you cannot tolerate two versions serving at once, for example during a database schema change that is not backward compatible. Feature flags are better when the risk lives in one feature and not in the whole release.
Always pair canaries with business metrics, not only infrastructure metrics. An HTTP error rate tells you the API is broken. It does not tell you that checkout completion dropped 2% because of a subtle UI regression. Wire orders_completed_total or payment_success_rate into the analysis alongside the technical checks.
Start with a longer canary than you think you need. Ten minutes catches hard failures, while performance regressions that appear only under sustained load need 30 to 60 minutes. A brokerage platform should make sure the canary window covers the 9:15 AM IST market-open spike, because a canary that finishes at 9:05 never sees that traffic pattern.
Guard against low traffic. Require a minimum request count before the success condition can pass, and treat too few samples as inconclusive. An error rate computed from a handful of requests proves nothing.
Set a clear rollback condition and trust it. If the analysis says to roll back above 1% errors and the canary reaches 1.1%, let it roll back even if you suspect it will recover. Manual overrides of automatic rollbacks erode trust in the automation and lead teams to disable it entirely.
Finally, make database changes backward compatible. During a canary, both versions run against the same database, so use expand-and-contract migrations: add the new column first, deploy, and drop the old one in a later release.
NoteReferences and Further Reading
- Argo Rollouts Documentation - Official guide and CRD reference
- Flagger Documentation - Setup, providers, and analysis reference
- Ingress NGINX Retirement - Official Kubernetes announcement and migration advice
- Gateway API - Specification for weighted HTTPRoute traffic splitting
- DORA Metrics - Deploy frequency and change failure rate benchmarks
Argo Rollouts introduces a Rollout resource that replaces or references your Deployment and integrates natively with the Argo CD UI. Flagger keeps your Deployment as the canary target, creates and manages a primary copy itself, and reports progress through events and metrics. Both automate the analysis loop and roll back on failed metrics.
The usual cause is the analysis query. If the Prometheus query returns no data, the measurement errors instead of passing, and the analysis fails once consecutiveErrorLimit is reached. Run the query by hand against your Prometheus endpoint and confirm the labels it filters on exist on the canary pods.
Not safely. The community ingress-nginx controller was retired in March 2026 and no longer receives security fixes, although existing installs keep running. Use the Gateway API with weighted HTTPRoute backends, a service mesh such as Istio or Linkerd, or a different supported ingress controller for new work.
Without a traffic router, Argo Rollouts approximates weights by scaling pod counts, so with 10 replicas the smallest step is 10%. Exact percentages need a traffic router such as the Gateway API, Istio, or a supported ingress, which splits requests by weight regardless of replica count.
Set a minimum request volume in the query condition and extend the pause so enough samples arrive. An error rate computed from 12 requests is noise. Treat low volume as inconclusive instead of healthy, and combine technical metrics with a business metric such as successful orders per minute.
Discussion0