> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Demo Argo Rollout Canary

> Guide demonstrating Argo Rollouts canary deployments for gradual traffic shifting, including Rollout manifests, setWeight steps, pauses, promotion, inspection, and rollback commands.

In this lesson we demonstrate how to perform a gradual release using the canary deployment model provided by Argo Rollouts. Argo Rollouts extends Kubernetes Deployments with more control over update behavior — enabling canary, blue-green, and progressive delivery strategies. The canary strategy routes a percentage of traffic to a new revision and increases that percentage in controlled steps with optional pauses for validation.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/t4oxgWWg0SQKJwoX/images/Prep-Course-GitOps-Certified-Associate-CGOA/GitOps-Patterns/Demo-Argo-Rollout-Canary/canary-deployment-strategy-argo-rollouts.jpg?fit=max&auto=format&n=t4oxgWWg0SQKJwoX&q=85&s=aaa86d054563209aca4b9153868db104" alt="The image shows a webpage titled &#x22;Canary Deployment Strategy&#x22; from Argo Rollouts, discussing a method for gradually releasing a new software version. It includes an overview and table of contents on the right." width="1920" height="1080" data-path="images/Prep-Course-GitOps-Certified-Associate-CGOA/GitOps-Patterns/Demo-Argo-Rollout-Canary/canary-deployment-strategy-argo-rollouts.jpg" />
</Frame>

## Rollout manifest (canary strategy) — overview

A Rollout manifest (kind: `Rollout`) looks like a Deployment but gives you fine-grained control of updates. Instead of replacing all pods at once, the canary strategy lets you increment traffic using `setWeight` steps and `pause` actions (timed or indefinite).

Example Rollout (illustrative):

```yaml theme={null}
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
  name: example-rollout
spec:
  replicas: 10
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
        - name: nginx
          image: nginx:1.15.4
          ports:
            - containerPort: 80
  minReadySeconds: 30
  revisionHistoryLimit: 3
  strategy:
    canary:
      maxSurge: 25%
      maxUnavailable: 0
      steps:
        - setWeight: 10
          pause:
            duration: 1h
        - setWeight: 20
          pause: {} # pause indefinitely until manual promotion
```

Pause duration formats supported: seconds (`10s`), minutes (`10m`), hours (`1h`), or an empty object (`{}`) for an indefinite (manual) pause:

```yaml theme={null}
spec:
  strategy:
    canary:
      steps:
        - pause: { duration: 10s }  # 10 seconds
        - pause: { duration: 10m }  # 10 minutes
        - pause: { duration: 1h }   # 1 hour
        - pause: {}                 # pause indefinitely (manual promotion)
```

<Callout icon="warning" color="#FF6B6B">
  A `pause: {}` is an indefinite pause — the rollout will wait until you manually promote the next step (UI or `kubectl argo rollouts promote`). Plan for manual verification before continuing.
</Callout>

### Blue-green (reference snippet)

For comparison, here is a sample blue-green configuration (used for preview/promotion workflows):

```yaml theme={null}
revisions: 3
strategy:
  blueGreen:
    activeService: active-service
    previewService: preview-service
    previewReplicaCount: 1
    autoPromotionEnabled: false
    prePromotionAnalysis:
      templates:
        - templateName: success-rate
          args:
            - name: service-name
              value: guestbook-svc.default.svc.cluster.local
    postPromotionAnalysis:
      templates:
        - templateName: success-rate
          args:
            - name: service-name
              value: guestbook-svc.default.svc.cluster.local
```

## Applying the canary example from the repository

This repository contains a `patterns/canary/` folder with `rollout.yml` and `service.yml`. Below are the manifests used in the demo.

Initial `rollout.yml` (canary steps):

```yaml theme={null}
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
  name: app-rollout
  namespace: canary
spec:
  replicas: 10
  selector:
    matchLabels:
      app: app-rollout
  template:
    metadata:
      labels:
        app: app-rollout
    spec:
      containers:
        - name: app
          image: siddharth67/app:v1
  strategy:
    canary:
      steps:
        - setWeight: 20
          pause: {}
        - setWeight: 40
          pause:
            duration: 1m
        - setWeight: 60
          pause:
            duration: 1m
        - setWeight: 80
          pause:
            duration: 1m
```

For demo speed we adjusted timed pauses to `10s` so the rollout completes faster:

```yaml theme={null}
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
  name: app-rollout
  namespace: canary
spec:
  replicas: 10
  selector:
    matchLabels:
      app: app-rollout
  template:
    metadata:
      labels:
        app: app-rollout
    spec:
      containers:
        - name: app
          image: siddharth67/app:v1
  strategy:
    canary:
      steps:
        - setWeight: 20
        - pause: {}
        - setWeight: 40
        - pause:
            duration: 10s
        - setWeight: 60
        - pause:
            duration: 10s
        - setWeight: 80
        - pause:
            duration: 10s
```

Commands to create the namespace and apply the manifests:

```bash theme={null}
# create the canary namespace
kubectl create ns canary

# apply the rollout and service manifests
kubectl -n canary apply -f cgoa-demos/patterns/canary/

# confirm resources
kubectl -n canary get all
```

Expected simplified output after apply:

```bash theme={null}
namespace/canary created
rollout.argoproj.io/app-rollout created
service/app-rollout-service created

# kubectl -n canary get all
NAME                                       READY   STATUS    RESTARTS   AGE
pod/app-rollout-76f479c6bf-251rz          1/1     Running   0          8s
... (other app-rollout pods)

NAME                                       TYPE       CLUSTER-IP     PORT(S)
service/app-rollout-service                NodePort   10.109.7.217   80:30797/TCP

NAME                                           DESIRED   CURRENT   READY
replicaset.apps/app-rollout-76f479c6bf         10        10        10
```

<Callout icon="lightbulb" color="#1CB2FE">
  Argo Rollouts manages ReplicaSets and pods for `Rollout` resources. You will not see a Kubernetes `Deployment` for this workload — instead look for `rollout.argoproj.io` and ReplicaSets.
</Callout>

## Inspecting Rollouts

List rollouts in the cluster or a specific namespace:

```bash theme={null}
# list rollouts in the current namespace
kubectl get rollouts

# list rollouts in the canary namespace
kubectl get rollouts -n canary
```

Example output:

```bash theme={null}
# kubectl get rollouts -n canary
NAME         DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
app-rollout  10        10        10           10          37s
```

## Accessing the application and observing canary traffic

The `Service` exposes the app on a NodePort (e.g., `30797`). In the demo we continuously polled the `/app` endpoint and printed the reported application version. Use this local script (adjust the port as necessary):

```bash theme={null}
while true; do
  echo -n "$(date '+%H:%M:%S') - ";
  curl -s --max-time 1 http://localhost:30797/app 2>/dev/null |
  awk '{
    if ($0 ~ /Application Version:/) {
      if ($0 ~ /v1/) print "\033[34m" $0 "\033[0m";
      else if ($0 ~ /v2/) print "\033[33m" $0 "\033[0m";
      else print $0;
    } else print $0;
  }';
  sleep 1;
done
```

This output will show mostly `v1` at first, then occasional `v2` responses as the canary begins, then a growing mix of `v2` as the setWeight increases, and finally all `v2` once the rollout completes.

## Promoting a new version (UI or CLI)

To promote a new revision, update the container image to `v2` in the manifest and apply it (or use the UI). The Rollout will create a new revision and follow the configured canary steps:

* A `setWeight: 20` step means 2 of 10 pods will run `v2` while 8 run `v1`.
* If the first step contains `pause: {}`, the rollout will stop for manual promotion.
* On manual promotion, the rollout proceeds to 40%, 60%, 80%, and finally 100% (with configured pauses).

Promote with the kubectl plugin:

```bash theme={null}
# promote to the next step
kubectl argo rollouts promote <rollout-name>

# promote fully (skip intermediate steps)
kubectl argo rollouts promote --full <rollout-name>
```

Make sure the `kubectl-argo-rollouts` plugin is installed if you plan to promote from the CLI. Alternatively, use the Argo Rollouts UI.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/t4oxgWWg0SQKJwoX/images/Prep-Course-GitOps-Certified-Associate-CGOA/GitOps-Patterns/Demo-Argo-Rollout-Canary/argo-rollouts-canary-deployment-interface.jpg?fit=max&auto=format&n=t4oxgWWg0SQKJwoX&q=85&s=fbc9d818a5643ce8e4fe8a05a4224f58" alt="The image shows the interface of Argo Rollouts, displaying a canary deployment strategy with various weighted steps and a successful revision summary." width="1920" height="1080" data-path="images/Prep-Course-GitOps-Certified-Associate-CGOA/GitOps-Patterns/Demo-Argo-Rollout-Canary/argo-rollouts-canary-deployment-interface.jpg" />
</Frame>

Example progression (polling output):

```text theme={null}
11:17:45 - Application Version: v1
11:17:48 - Application Version: v2
11:17:51 - Application Version: v2
11:18:04 - Application Version: v1
11:18:14 - Application Version: v2
...
11:19:14 - Application Version: v2
11:19:29 - Application Version: v2
```

As you promote through higher `setWeight` steps, the frequency of `v2` responses increases until all pods serve `v2`.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/t4oxgWWg0SQKJwoX/images/Prep-Course-GitOps-Certified-Associate-CGOA/GitOps-Patterns/Demo-Argo-Rollout-Canary/argo-rollouts-canary-deployment-dashboard.jpg?fit=max&auto=format&n=t4oxgWWg0SQKJwoX&q=85&s=d20bbe538c027c9542cf8ee5f0a3d6ef" alt="The image shows an Argo Rollouts dashboard for managing application rollout strategies, specifically using a canary deployment strategy. It displays steps with weight settings, a container selection, and revision details." width="1920" height="1080" data-path="images/Prep-Course-GitOps-Certified-Associate-CGOA/GitOps-Patterns/Demo-Argo-Rollout-Canary/argo-rollouts-canary-deployment-dashboard.jpg" />
</Frame>

## Rollbacks and stability

Argo Rollouts keeps a revision history and supports rollback to a previous revision if issues are detected during promotion. You can revert using the UI or the CLI to restore a stable revision. The UI highlights stable revisions and current status for easy rollback.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/t4oxgWWg0SQKJwoX/images/Prep-Course-GitOps-Certified-Associate-CGOA/GitOps-Patterns/Demo-Argo-Rollout-Canary/application-rollouts-management-interface-diagram.jpg?fit=max&auto=format&n=t4oxgWWg0SQKJwoX&q=85&s=5a1ccd22e6212025acf7f5d4609dadb1" alt="The image shows a software interface for managing application rollouts, displaying steps like setting weights and pauses, with revisions marked as stable or &#x22;No Pods&#x22;." width="1920" height="1080" data-path="images/Prep-Course-GitOps-Certified-Associate-CGOA/GitOps-Patterns/Demo-Argo-Rollout-Canary/application-rollouts-management-interface-diagram.jpg" />
</Frame>

## Quick reference

Table: common pause durations and promotion commands

| Topic                | Example                                                    |
| -------------------- | ---------------------------------------------------------- |
| Pause formats        | `yaml<br>pause: { duration: 10s }` or `yaml<br>pause: {} ` |
| Promote to next step | `kubectl argo rollouts promote <rollout-name>`             |
| Promote fully        | `kubectl argo rollouts promote --full <rollout-name>`      |

Summary of best practices

* Use `setWeight` steps to route a specific percentage of traffic to a new revision.
* Combine timed pauses (e.g., `10s`, `1m`) with indefinite pauses (`{}`) for manual verification.
* Observe application metrics and logs during each pause before promoting.
* Use the Argo Rollouts UI or `kubectl-argo-rollouts` plugin to promote, inspect, and roll back as needed.

<Callout icon="lightbulb" color="#1CB2FE">
  Ensure Argo Rollouts CRDs and controller are installed in your cluster and install the `kubectl-argo-rollouts` plugin if you intend to promote or inspect rollouts from the CLI. See the Argo Rollouts installation guide for details.
</Callout>

## Links and references

* Argo Rollouts documentation: [https://argoproj.github.io/argo-rollouts/](https://argoproj.github.io/argo-rollouts/)
* kubectl-argo-rollouts plugin installation: [https://argoproj.github.io/argo-rollouts/installation/#kubectl-plugin](https://argoproj.github.io/argo-rollouts/installation/#kubectl-plugin)
* Kubernetes documentation: [https://kubernetes.io/docs/](https://kubernetes.io/docs/)

That's all for now.

<CardGroup>
  <Card title="Watch Video" icon="video" cta="Learn more" href="https://learn.kodekloud.com/user/courses/gitops-certified-associate-cgoa/module/f1538ace-dc97-454d-b894-15bdd35bcb64/lesson/6f3f1da1-beae-47f1-aab1-80bd01295229" />

  <Card title="Practice Lab" icon="flask-conical" cta="Learn more" href="https://learn.kodekloud.com/user/courses/gitops-certified-associate-cgoa/module/f1538ace-dc97-454d-b894-15bdd35bcb64/lesson/6853933e-4532-4fc2-9e48-3fb5c05ba5d7" />
</CardGroup>
