Dec 1, live webinar: Agents in production, live: who gives the agent production access?

Canary Deploys and Automatic Rollback for Coding Agents

How to let a coding agent deploy to production Kubernetes with a safety net: scoped tokens, health checks, canary analysis with Argo Rollouts or Flagger, automatic rollback, and where Qovery's MCP server and policy tokens fit.

Romaric Philogene
CEO & Co-founder
Published · 13 min
Canary Deploys and Automatic Rollback for Coding Agents

This article is part of our guide to Agentic Infrastructure.

A coding agent can deploy to production Kubernetes safely if three things stand between its change and your users: a token that limits what it may deploy and where, health checks that stop a version that does not start, and a canary that sends a small share of traffic to the new version and aborts on bad metrics. Rolling updates with readiness probes cover the first failure mode. Argo Rollouts or Flagger cover the second one, the version that starts fine and then returns errors. Neither tool undoes a database migration, so keep schema changes out of agent deploys.

Qovery · Agentic DevOps platform
Build with Claude Code, Deploy with Qovery
Learn more

I run Qovery, the Agentic DevOps platform, so weigh my take with that in mind. This post is about the last step of an agent's change, the production rollout. For the step before it, how code gets from an agent's sandbox to a governed deploy, read From Sandbox to Cluster. For which tool to connect the agent to, read What to connect a coding agent to.

Key points:

  • Agents change the volume, not the failure modes. A bad release still fails in one of three ways: it does not start, it starts and misbehaves, or it changes data. Agents ship more releases with less human review, so each guardrail runs more often.
  • Kubernetes alone stops the first kind. A rolling update waits for readiness probes before moving traffic. A stalled Deployment is only reported: Kubernetes "takes no action on a stalled Deployment other than to report a status condition."
  • Canary analysis catches the second kind. Argo Rollouts and Flagger shift traffic in steps, query Prometheus or another metrics provider, and roll back when a success rate or latency threshold fails.
  • Nothing rolls back the third kind. Use expand-and-contract migrations and keep them in separate deploys that a human approves.
  • What Qovery does here: a policy token limits what the agent can deploy, the MCP server is read-only unless you turn on writes, RollingUpdate rolls back automatically when new pods fail to start, and every call lands in the audit log. Qovery does not run canary analysis itself. For that, run Argo Rollouts on the same cluster and ship the app as a Helm chart.

Why do AI coding agents need canary releases and automatic rollback?

Because an agent will eventually ship a version that passes tests, starts cleanly and is still wrong. A human-reviewed change goes through the same risk, but a team that lets Claude Code or Cursor open and merge pull requests ships more often, with smaller reviews. The guardrail that used to run once a week now runs ten times a day, and it has to work without someone watching the dashboard.

Here are the three ways a release goes wrong, and what catches each one:

FailureExampleCaught byRolled back by
Does not startMissing env var, crash on boot, wrong portReadiness and liveness probes during a rolling updateThe rolling update keeps the old pods serving
Starts, then misbehaves5% of requests return 500, p99 latency doubles, a worker drops messagesMetric analysis during a canaryArgo Rollouts or Flagger shift traffic back to stable
Changes dataA migration drops a column, a job rewrites rowsReview before deploy, backupsNothing automatic. Restore or fix forward

Most of the "the agent broke production" stories I hear sit in the second row. The deploy looked green, and the error rate climbed ten minutes later.

What does Kubernetes already give you without a canary tool?

A Deployment with a rolling update and proper probes already stops the first failure mode. New pods start, the readiness probe must pass before they receive traffic, and old pods are removed only as new ones become ready. If the new pods never become ready, the rollout stalls with the old version still serving.

What a plain Deployment does not do is roll back. Once progressDeadlineSeconds passes, Kubernetes marks the rollout as failed and "takes no action on a stalled Deployment other than to report a status condition" (Kubernetes docs). Someone, or something, has to run kubectl rollout undo.

On Qovery, that step is built in. The default RollingUpdate strategy "will gracefully rollout new versions of your application and automatically rollback if the new version fails to start" (Qovery docs). Probes are configurable per service over HTTP, TCP, gRPC or a command, and the configured probes must pass for a deployment to complete (health checks). Deploy Other Version redeploys any earlier commit or image tag, and cancelling a running deployment rolls that service back to the previous version (deployment actions).

That covers "does not start". It does not cover "starts and returns errors", because the probe only checks that the process answers.

How do canary releases with Argo Rollouts or Flagger work?

Both controllers send a small share of traffic to the new version, measure it, and either continue or roll back. They differ in shape.

Argo Rollouts replaces your Deployment with a Rollout resource. You list steps (setWeight: 20, pause: {duration: 10m}, and so on) and attach an AnalysisTemplate that queries a metrics provider. In Argo's own example, an analysis that measures the HTTP success rate below 95% three times is marked Failed, and "the failed analysis causes the Rollout to abort, setting the canary weight back to zero" (Argo Rollouts docs). Without a traffic router, it approximates the weight with replica counts: 10% of 10 replicas is 1 canary pod. With NGINX, AWS ALB, Istio, Traefik or Gateway API (through a plugin), it shifts real traffic percentages.

Flagger wraps an existing Deployment with a Canary resource. It creates a primary copy, moves traffic in steps (stepWeight, maxWeight), checks built-in metrics such as request success rate and p99 duration, and rolls back after a number of failed checks (threshold). It works with Istio, Linkerd, NGINX, Contour, Gloo, Traefik, Skipper, Kuma, Knative and Gateway API implementations (Flagger). It also runs webhooks for load tests or acceptance tests during the analysis.

As of 30 Nov 2026, Argo Rollouts' latest stable release is v1.10.2 and Flagger's is v1.45.0. We compared them in depth in progressive delivery tools for Kubernetes. For an agent workflow, the choice comes down to this:

Argo RolloutsFlagger
How you adopt itReplace Deployment with Rollout (or reference one with workloadRef)Add a Canary next to your Deployment
Works without a mesh or ingress integrationYes, with replica-based weightsNeeds a supported provider for traffic shifting
Metric providersPrometheus, Datadog, New Relic, CloudWatch, web, job and othersPrometheus and other metric templates, plus webhooks
Manual promote or abortkubectl argo rollouts promote / abortThrough the Canary resource and webhooks
Fits bestArgo CD shops, or a first canaryFlux shops, or teams already on a mesh

What guardrails should a coding agent have before production?

Think in layers, each one cheap on its own. An agent that hits a guardrail should stop and report, not look for a way around it.

  1. A token that matches the job. Never AWS keys or an admin kubeconfig. The agent gets a token that can deploy to staging, and in production can only deploy a named version of named services.
  2. A preview environment per pull request. The agent's change runs with its own database before anyone merges. See preview environments for coding agents.
  3. Staging first, with the same probes as production. A probe that only exists in production is a probe nobody tested.
  4. A canary with metric gates in production. Start at 5 to 20% of traffic, hold for long enough to see real requests, and gate on error rate and latency compared with the stable version.
  5. A rollback the agent can trigger but not bypass. The agent may abort a canary or redeploy the last healthy version. It may not change the analysis thresholds or skip the canary.
  6. An audit log per agent. Every deploy, abort and rollback is attributed to the token that did it.

Layers 1, 2, 3, 5 and 6 are platform work. Layer 4 is the canary controller.

Let your coding agent deploy, inside guardrails you set.
Qovery gives coding agents a scoped token, a read-only MCP server by default, rolling deploys that roll back when new pods fail to start, and an audit log of every call, on Kubernetes in your own cloud. Start on the Free plan, no credit card.

How do Qovery's MCP server and policy tokens fit into this?

Qovery covers the token, the environments, the rolling deploy and the audit trail. A canary controller covers the traffic analysis. Here is who does what:

GuardrailWith QoveryNotes
Scoped accessAPI policy token (Preview): a Rego policy checked on every API request, deny by defaultA request the policy does not allow gets a 401 before it reaches the endpoint
Agent interfaceMCP server at https://mcp.qovery.com/mcp, read-only by defaultWrites need ?read_write=true and write access enabled in the Console
Preview and stagingPreview environment per pull request, environments per stageSame probes in every environment
Does not startRollingUpdate with automatic rollback, configurable probesBuilt in
Starts and misbehavesArgo Rollouts on the same cluster, app shipped as a Helm chartNot built into Qovery
Roll back to a known versionDeploy Other Version, or the roll back a bad release agent policyThe agent must name the commit or tag
AuditAudit logs record policy token calls as policy:<token-id>:<token-name>Per agent, per call

The rollback policy from our docs is a good template for agents in production. The agent can read the production environment except its environment variables, and it can deploy a given commit of the listed applications or a given image tag of the listed containers. It cannot deploy without naming a version, change configuration or delete anything. The docs also say what the policy cannot know: it "cannot know whether a commit is older than the current one", so the agent could deploy a newer version too. Keep tests and review on the main branch.

REGO|Deploy a given commit of an application. The commit must be named in the request.
deploy_application_version if {
	input.request.method == "POST"
	input.request.path[1] == "application"
	input.request.path[2] in application_ids
	input.request.path[3] == "deploy"
	count(input.request.path) == 4
	count(input.request.body.git_commit_id) > 0
}

That is one rule from the full policy in the roll back a bad release example. You do not have to write Rego by hand: describe the job with /qovery-policy-token and the skill writes, tests and creates the token after you approve it.

Adding a canary on a Qovery cluster

Qovery generates and manages the Kubernetes objects behind its application services, so to get metric-gated canaries, ship the service as a Helm chart that contains a Rollout:

  1. Install the Argo Rollouts controller as a Helm service in a platform environment on the cluster. Qovery deploys any public or private Helm chart (Helm docs).
  2. Ship the app as a Helm service whose chart defines a Rollout and an AnalysisTemplate, with the image tag as a chart value. Argo Rollouts "will always respond to changes in Rollouts resources regardless of how the change was made", so a Helm upgrade starts the canary.
  3. Point the analysis at your metrics. Prometheus is the common choice. Gate on the success rate and p99 latency of the canary.
  4. Let the agent deploy a new image tag through Qovery, then read the Rollout's status. Helm finishes when the chart is applied, and the canary keeps progressing after that, so "deployed" in Qovery means "canary started", not "canary passed".

A minimal canary for the chart looks like this:

YAML
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
  name: api
spec:
  replicas: 10
  selector:
    matchLabels:
      app: api
  template:
    metadata:
      labels:
        app: api
    spec:
      containers:
        - name: api
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
          readinessProbe:
            httpGet:
              path: /healthz
              port: 8080
  strategy:
    canary:
      analysis:
        templates:
          - templateName: api-success-rate
        startingStep: 1
      steps:
        - setWeight: 10
        - pause: {duration: 10m}
        - setWeight: 50
        - pause: {duration: 10m}
---
apiVersion: argoproj.io/v1alpha1
kind: AnalysisTemplate
metadata:
  name: api-success-rate
spec:
  metrics:
    - name: success-rate
      interval: 2m
      failureLimit: 2
      successCondition: result[0] >= 0.99
      provider:
        prometheus:
          address: http://prometheus.monitoring:9090
          query: |
            sum(rate(http_requests_total{app="api",code!~"5.."}[2m]))
            /
            sum(rate(http_requests_total{app="api"}[2m]))

Replace the query with one your app exports, and scope it to canary pods if your traffic router supports it. With replica-based weights and this query, the metric mixes stable and canary traffic, which hides a small canary's errors. A traffic router with per-version metrics fixes that.

I would not put Flagger on top of an application service that Qovery manages directly: two controllers would then write to the same object. We have not validated that setup, so use a Helm service. If your team already runs Argo CD with Rollouts, keep it. Qovery's Argo CD integration shows Argo CD applications in the Console, read-only for now.

What can automatic rollback not undo?

Anything outside the pods. Write these down as rules for the agent:

  • Database migrations. Rolling the code back does not roll the schema back. Use expand and contract: add the new column, deploy code that writes both, backfill, then remove the old column in a later release. Keep migrations in their own deploy, run as a lifecycle job, with a human approving production.
  • Side effects. Emails sent, webhooks fired, payments captured, messages consumed from a queue. A canary at 10% still sends 10% of them.
  • Configuration and secrets. If the agent changed an environment variable along with the code, rolling back the image may keep the new variable. Deploy config changes separately, and keep variables out of the rollback agent's policy (the docs example blocks them).
  • Flapping thresholds. An analysis gate that fails on noise trains everyone, human or agent, to skip it. Start with thresholds you would page on, then tighten.

How do I set this up with Claude Code or Cursor?

Start read-only, then widen access one layer at a time.

  1. Install the skills and the MCP server, read-only.

    BASH
    curl -fsSL https://skill.qovery.com/install.sh | bash
    claude mcp add --transport http qovery https://mcp.qovery.com/mcp --callback-port 4242
    
  2. Turn on previews and staging. Ask the agent to set up a preview environment per pull request and a staging environment with the same health checks as production.

  3. Create a staging deploy token. /qovery-policy-token for an agent that may read and deploy everything in staging, nothing else.

  4. Create a production rollback token. Follow the roll back a bad release example: read production except variables, deploy named versions of named services.

  5. Add the canary for the services where a bad release hurts most, with Argo Rollouts as described above.

  6. Give the agent the runbook. "After a production deploy, watch the Rollout and the error rate for 20 minutes. If the analysis fails or errors rise, abort, deploy the last healthy version, and report the commit."

If you want to see this live, including an agent that tries to delete a production database and gets refused, we run it in Agents in production, live on December 1.

To try it on your own cluster, start on the Free plan: no credit card, one cluster of your own.


Frequently Asked Questions
How do I stop an AI coding agent from breaking production on Kubernetes?

Give it a token scoped to the job, run its changes through a preview environment and staging with the same health checks as production, and use a canary with metric analysis for production deploys. Kubernetes rolling updates stop versions that do not start. Argo Rollouts or Flagger roll back versions that start and then return errors. Keep database migrations out of automatic agent deploys.

Does Kubernetes roll back a failed deployment automatically?

No. A Deployment with readiness probes keeps old pods serving while new ones fail, and marks the rollout as failed after progressDeadlineSeconds, but it does not roll back by itself. You run kubectl rollout undo, or use a platform or controller that does it. Qovery's default RollingUpdate strategy rolls back automatically when the new version fails to start.

Argo Rollouts or Flagger for agent deployments?

Pick Argo Rollouts if you use Argo CD or need your first canary without a service mesh, since it can approximate weights with replica counts. Pick Flagger if you run Flux or a mesh already and want to keep your Deployment objects. Both abort and roll back on failed metric checks.

Does Qovery support canary deployments?

Not as a built-in strategy. Qovery supports RollingUpdate, with automatic rollback when new pods fail to start, and Recreate. For metric-gated canaries, run Argo Rollouts on the same cluster and deploy the service as a Helm chart through Qovery. Qovery handles the token, environments, deploys, rollback to a named version and the audit log.

Can an agent roll back a release on its own?

Yes, within a policy. Qovery's rollback example lets an agent read production (except environment variables) and deploy a named commit or image tag of listed services, and nothing else. Every call appears in the audit log under the token's name.

Should an AI agent run database migrations in production?

Not automatically. A rollback does not undo a schema change. Use expand-and-contract migrations, ship them in a separate deploy as a lifecycle job, and have a human approve the production run.

Romaric Philogene
About the author
Romaric Philogene

Romaric founded Qovery to make Kubernetes accessible to every engineering team. He writes about platform strategy, developer experience, and the future of cloud infrastructure.

Next step

Let your coding agent deploy, inside guardrails you set.

Qovery gives coding agents a scoped token, a read-only MCP server by default, rolling deploys that roll back when new pods fail to start, and an audit log of every call, on Kubernetes in your own cloud. Start on the Free plan, no credit card.