# Convert a Blue-Green Argo Rollout to a Canary With Analysis in an Argo CD App

Yes. An agent rewrites the Rollout's strategy from blueGreen to canary with weighted steps and an AnalysisTemplate, renders the chart, lints it and opens a PR.

[Run this on Rush](https://cloud.getrush.ai/run/add-canary-rollouts/argo-cd/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent starts from the chart Argo CD already syncs, not from a generic example. In a repository like argoproj/argocd-example-apps, the `blue-green` directory is a Helm chart named `helm-guestbook` at `version: 0.1.0`, and `templates/rollout.yaml` is an `argoproj.io/v1alpha1` `Rollout` whose `strategy` is `blueGreen` with `activeService` set to the chart's fullname and `previewService` to the fullname with a `-preview` suffix. `templates/services.yaml` defines those two Services, both `ClusterIP` on port 80 with `targetPort: http`. `values.yaml` sets `replicaCount: 1` and the image `gcr.io/google-samples/gb-frontend` at tag `v5`, and the pod has liveness and readiness probes on `/`. The chart is registered in `apps/values.yaml` with `releaseName: blue-green`, and the app-of-apps template in `apps/templates/applications.yaml` gives every Application `automated: {prune: true, selfHeal: true}` and `CreateNamespace=true`. The README explains the current promotion as a merge patch that flips `status.verifyingPreview`.

It then rewrites the strategy. `strategy.blueGreen` becomes `strategy.canary` with `canaryService` and `stableService` pointing at the two Services, so `services.yaml` keeps both but the `-preview` Service becomes `-canary`. The steps come from values so a team can tune them without editing templates: `setWeight: 20`, a `pause` of one minute, an `analysis` step, `setWeight: 50`, another pause, then full promotion. The agent adds `templates/analysis.yaml` with an `AnalysisTemplate` whose metric uses the `job` provider by default: a Kubernetes Job that curls the canary Service and fails the analysis on any non-2xx answer, with `failureLimit: 1`. A `prometheus` block in `values.yaml`, off by default, lets a cluster with Prometheus switch the metric to a success-rate query against the `address` the reader sets, because the chart itself names no metrics backend and the agent does not invent one.

Two things in this chart change what the agent writes, and it says so in the pull request. With `replicaCount: 1` and no traffic router, Argo Rollouts approximates a weight by scaling pods, so a 20% step on one replica is a second pod rather than a split; the agent raises the default to 3 replicas in `values.yaml` and documents `trafficRouting` as the next step for a cluster with an ingress controller. And because the Application is auto-synced with `selfHeal`, the promotion must happen through the Rollout controller, not through a patch to the manifest, so the README's `argocd app patch-resource` instructions are replaced with `kubectl argo rollouts promote blue-green-helm-guestbook` and `kubectl argo rollouts abort` for the other direction.

Then it checks the chart the way the sandbox can. `helm lint blue-green` and `helm template blue-green --set image.tag=v6` render the Rollout, the two Services and the AnalysisTemplate, and the agent validates the rendered YAML with `kubeconform` using the Argo Rollouts CRD schemas, since Kubernetes' own schema does not know a `Rollout`. It installs the `kubectl-argo-rollouts` plugin and runs its `lint` command against the rendered Rollout, which catches a `canaryService` that does not match a Service name or a step that mixes `setWeight` with a missing pause. It bumps `Chart.yaml` to `0.2.0`, because the strategy change is a breaking change for anyone who was promoting with the old patch.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Convert the blue-green Argo Rollout in this Argo CD repository to a canary rollout with analysis. Read the blue-green chart first: Chart.yaml, values.yaml, every file under templates, the README, and apps/values.yaml and apps/templates/applications.yaml to see how the Application is synced. Replace strategy.blueGreen with strategy.canary, keep both Services and rename the preview one to a canary Service, drive the steps from values with weights of 20 and 50, a one-minute pause after each, and an analysis step. Add an AnalysisTemplate whose default metric is a job provider that curls the canary Service and fails on a non-2xx answer, with an optional prometheus block in values that is off by default. Raise the default replica count so pod-based weights mean something, and say in the README why traffic routing is the next step. Replace the README's promotion instructions with the kubectl argo rollouts commands, since the Application self-heals. Run helm lint and helm template, validate the output with kubeconform using the Argo Rollouts CRD schemas, run kubectl argo rollouts lint on the rendered Rollout, bump the chart version, and open a pull request that lists exactly what was verified.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

What comes back is a pull request that edits `blue-green/templates/rollout.yaml`, `blue-green/templates/services.yaml`, `blue-green/values.yaml`, `blue-green/Chart.yaml` and `blue-green/README.md`, and adds `blue-green/templates/analysis.yaml`. The description shows the rendered Rollout's `steps` list, names the canary and stable Services, and explains the replica change and the `job` metric in two short paragraphs so a reviewer who has never read an AnalysisTemplate can follow it.

The run's record keeps the `helm lint` and `helm template` output, the `kubeconform` summary against the Rollouts CRD schemas, and the plugin's lint result, so a reviewer sees the chart renders and validates before they sync anything. The pull request says plainly that no cluster was involved: the sandbox verified rendering and schema validity, not a live promotion.

Before merging, a reviewer syncs the Application to a non-production cluster, changes `image.tag`, and watches `kubectl argo rollouts get rollout blue-green-helm-guestbook --watch` step through 20%, the pause, the analysis Job and 50%. If the Job metric fails, the rollout aborts and the stable ReplicaSet keeps serving, which is the behaviour the pull request promises.

## Run it on every Argo CD application

A platform engineer hands this off from the terminal once per Application that still uses blue-green: one `POST /o/{org}/sessions` with this body and the repository in `resources`, naming the chart directory in `input` when the repository holds several. Each run reads its own chart and writes steps for it, so a chart with `replicaCount: 5` gets different advice from one with a single replica. A `request_id` that is a UUID v5 of the repository and chart path means a retried request returns the run it already started.

The key's `webhook_url` reports each run the key starts, with the pull request URL in `result`, so a script that sends ten requests can collect ten pull requests without polling.

## Why run it on Rush?

A canary strategy is five edits that must agree: the Rollout's strategy, two Service names, the AnalysisTemplate's metric, the values that drive the steps, and the README that tells the on-call engineer how to promote. The agent reads the real chart in its own sandbox, makes the edits together, and renders and validates the result with Helm, kubeconform and the Rollouts linter before a person opens Argo CD.

Every command and its output stay in the run's record. A reviewer sees the rendered `steps`, the schema check and the chart version bump in one place, which is the proof a change to a deployment strategy needs before it reaches a cluster that self-heals.

## Frequently asked questions

### Do I need an ingress controller or service mesh for this?

Not to merge it. Without `trafficRouting`, Argo Rollouts scales the canary and stable ReplicaSets to approximate each weight, which is why the pull request raises the replica count. A cluster with NGINX, ALB or Istio adds a `trafficRouting` block under the canary strategy, and the README says exactly where.

### What happens when the analysis fails?

The rollout aborts at that step: the canary ReplicaSet scales to zero and the stable Service keeps pointing at the previous version. With `failureLimit: 1`, one failed curl from the analysis Job is enough. `kubectl argo rollouts retry rollout` starts the steps again after a fix.

### Will Argo CD's self-heal undo a promotion?

No. Promotion changes the Rollout's status, not its spec, so the manifest in Git still matches and Argo CD sees nothing to heal. That is also why the pull request removes the old `patch-resource` instructions: patching the manifest in the cluster is what self-heal reverts.

### Why a job metric instead of Prometheus?

The chart names no metrics backend, and the agent does not invent an address. The `job` provider works on any cluster, and the `prometheus` block in values is ready for one that has it: set `address` and the success-rate query, flip `enabled`, and the AnalysisTemplate renders the Prometheus metric instead.

### What does the agent actually verify?

That the chart lints, renders with a new image tag, passes kubeconform against the Argo Rollouts CRD schemas, and passes the plugin's lint. It does not sync to a cluster or watch a rollout, and the pull request says so. The reviewer's first sync on a test cluster is the live check.

## More Argo CD jobs

- [Add ignoreDifferences to Argo CD Applications](https://getrush.ai/run/add-ignore-differences/argo-cd/)
- [Set Up Argo CD Image Updater for Your Applications](https://getrush.ai/run/add-image-updater/argo-cd/)
- [Add Kubeconform Validation to CI for an Argo CD Repo](https://getrush.ai/run/add-kubeconform-to-ci/argo-cd/)

## The same job on other stacks

- [Add Canary Rollouts to a Flux Repository](https://getrush.ai/run/add-canary-rollouts/flux/)

## More jobs like this: Hand off a long task

- [Add cargo-deny to a Rust CLI's CI](https://getrush.ai/run/add-cargo-deny/rust-cli/)
- [Add cargo-semver-checks to CI for a Rust Library](https://getrush.ai/run/add-cargo-semver-checks-to-ci/rust-library/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
