ACK One integrates the GitOps capabilities of Argo CD and works with Argo Rollouts, a progressive delivery controller, to enable fully automated canary releases through Git commits. This solution combines ACK One GitOps with Argo Rollouts to build canary release capabilities for your applications.
Prerequisites
You have enabled the fleet management feature.
An ACK cluster is created and associated with an ACK One Fleet instance. For more information, see Create an ACK managed cluster and Add associated clusters.
Obtain the KubeConfig for the Fleet instance from the ACK One console, and connect to the Fleet instance using kubectl.
Install the latest version of Cloud Assistant CLI and configure Cloud Assistant CLI.
The latest Argo Rollouts kubectl plugin is installed. For more information, see Argo Rollouts documentation.
The NGINX Ingress Controller add-on is deployed in the ACK cluster. The canary release in this topic routes traffic through an NGINX Ingress and collects metrics from it.
The Argo CD CLI (argocd) is installed, and you have logged on to the Argo CD server of the ACK One Fleet instance.
Key concepts
Considerations
If you use GitHub repositories, avoid using regions in the Chinese mainland. To run in the Chinese mainland, you can select a suitable Git provider.
In this topic, the Fleet instance for fleet management and the associated ACK cluster are both deployed in the China (Hong Kong) region as an example.
Step 1: Deploy Argo Rollouts in the ACK cluster
Run the following commands to deploy Argo Rollouts in the ACK cluster. Before you run the commands, switch the kubectl context to the ACK cluster. For more information, see Argo Rollouts documentation.
kubectl create namespace argo-rollouts
kubectl apply -n argo-rollouts -f https://github.com/argoproj/argo-rollouts/releases/latest/download/install.yamlStep 2: Deploy the ack-arms-prometheus add-on in the ACK cluster
-
Log on to the ACK console. In the left navigation pane, click Clusters.
-
On the Clusters page, click the name of your cluster. In the left navigation pane, click Components and Add-ons .
On the Add-ons page, click the Logs and Monitoring tab and find the ack-arms-prometheus add-on.
If Installed is displayed in the upper-right corner of the card, the ack-arms-prometheus add-on was already installed when the cluster was created, and no further action is required.
If no information is displayed in the upper-right corner of the card, click Install in the lower-right corner of the card to install the add-on in the ACK cluster.
Step 3: Deploy an application by using ACK One GitOps
Two methods are available to deploy an application through GitOps.
Deploy the application by using the Argo CD CLI. The following procedure uses this method as an example to describe how to deploy an application through GitOps.
Deploy the application through the GitOps console. For more information, see Getting started with GitOps.
Add a Git repository.
argocd repo add https://github.com/AliyunContainerService/gitops-demo.git --name gitops-demoExpected output:
Repository 'https://github.com/AliyunContainerService/gitops-demo.git' addedRun the following command to view the list of added Git repositories.
argocd repo listExpected output:
TYPE NAME REPO INSECURE OCI LFS CREDS STATUS MESSAGE PROJECT git gitops-demo https://github.com/AliyunContainerService/gitops-demo.git false false false false SuccessfulRun the following command to view the list of clusters.
argocd cluster listExpected output:
SERVER NAME VERSION STATUS MESSAGE PROJECT https://192.168.XX.XX:6443 c76073b011afb4de2a8****-ack-gitops-demo-192-10-110-0-0-16 1.26+ Successful https://kubernetes.default.svc in-cluster Unknown Cluster has no applications and is not being monitored.Create an application by using an Application resource. Replace 192.168.XX.XX with the SERVER value of your cluster in the output of the argocd cluster list command.
argocd app create rollouts-demo --repo https://github.com/AliyunContainerService/gitops-demo.git --project default --sync-policy automated --revision rollouts --path . --dest-namespace default --dest-server https://192.168.XX.XX:6443Run the following command to view the list of applications.
argocd app listExpected output:
NAME CLUSTER NAMESPACE PROJECT STATUS HEALTH SYNCPOLICY CONDITIONS REPO PATH TARGET rollouts-demo https://192.168.XX.XX:6443 default default Synced Healthy Auto <none> https://github.com/AliyunContainerService/gitops-demo.git . rolloutsRun the following command to view the rollout status.
kubectl argo rollouts get rollout rollouts-demo --watchExpected output:
Name: rollouts-demo Namespace: default Status: ✓ Healthy Strategy: Canary Step: 8/8 SetWeight: 100 ActualWeight: 100 Images: argoproj/rollouts-demo:red (stable) Replicas: Desired: 4 Current: 4 Updated: 4 Ready: 4 Available: 4 NAME KIND STATUS AGE INFO ⟳ rollouts-demo Rollout ✓ Healthy 18s └──# revision:1 └──⧫ rollouts-demo-5747959bdb ReplicaSet ✓ Healthy 17s stable ├──□ rollouts-demo-5747959bdb-8m825 Pod ✓ Running 17s ready:1/1 ├──□ rollouts-demo-5747959bdb-kpqvh Pod ✓ Running 17s ready:1/1 ├──□ rollouts-demo-5747959bdb-vfqtm Pod ✓ Running 17s ready:1/1 └──□ rollouts-demo-5747959bdb-xdkv8 Pod ✓ Running 17s ready:1/1
Step 4: Start the canary release
During an Argo Rollouts canary release, you can use the following two methods to verify whether the new application version works as expected. You can then decide whether to further increase the traffic weight of the new version until all traffic is routed to it. The first method is manual verification. The second method is to decide whether to increase the traffic weight of the new version based on the business metrics of the new application version that are collected by Managed Service for Prometheus.
Each setWeight step in the rollout routes that percentage of live user traffic to the new application version.
On the automatic verification path, if the success rate stays below the 95% threshold for 10 consecutive metric evaluations (failureLimit: 10), the rollout is aborted and all traffic returns to the stable version.
Before you commit the change to the rollout.yaml file, make sure that the image tag is correct. An incorrect image tag affects production users.
Manual verification
In the rollout.yaml file, modify the following content, and then save and commit the changes.
apiVersion: argoproj.io/v1alpha1 kind: Rollout metadata: name: rollouts-demo spec: replicas: 4 strategy: canary: # The analysis metric collection section is not required. canaryService: rollouts-demo-canary stableService: rollouts-demo-stable trafficRouting: nginx: stableIngress: rollouts-demo-stable steps: - setWeight: 20 - pause: {} # This is a pause that requires manual intervention. - setWeight: 40 - pause: {duration: 5m} - setWeight: 60 - pause: {duration: 5m} - setWeight: 80 - pause: {duration: 5m} revisionHistoryLimit: 2 selector: matchLabels: app: rollouts-demo template: metadata: labels: app: rollouts-demo spec: containers: - name: rollouts-demo image: argoproj/rollouts-demo:yellow # Change the image tag. ports: - name: http containerPort: 8080 protocol: TCP resources: requests: memory: 32Mi cpu: 5mRun the following command to view the rollout status.
kubectl argo rollouts get rollout rollouts-demo --watchExpected output:
Name: rollouts-demo Namespace: default Status: ‖ Paused Message: CanaryPauseStep Strategy: Canary Step: 1/8 SetWeight: 20 ActualWeight: 20 Images: argoproj/rollouts-demo:red (stable) argoproj/rollouts-demo:yellow (canary) Replicas: Desired: 4 Current: 5 Updated: 1 Ready: 5 Available: 5 NAME KIND STATUS AGE INFO ⟳ rollouts-demo Rollout ‖ Paused 6m39s ├──# revision:2 │ └──⧫ rollouts-demo-6cf78c66c5 ReplicaSet ✓ Healthy 79s canary │ └──□ rollouts-demo-6cf78c66c5-kqp7x Pod ✓ Running 79s ready:1/1 └──# revision:1 └──⧫ rollouts-demo-5747959bdb ReplicaSet ✓ Healthy 6m38s stable ├──□ rollouts-demo-5747959bdb-8m825 Pod ✓ Running 6m38s ready:1/1 ├──□ rollouts-demo-5747959bdb-kpqvh Pod ✓ Running 6m38s ready:1/1 ├──□ rollouts-demo-5747959bdb-vfqtm Pod ✓ Running 6m38s ready:1/1 └──□ rollouts-demo-5747959bdb-xdkv8 Pod ✓ Running 6m38s ready:1/1In the rollout.yaml file, at the first
pausestep, no pause duration is set. The canary release therefore stays paused at this step until a resume or promote action is performed.Resume the canary release.
In the rollout.yaml file, modify the following content, and then save and commit the changes.
steps: - setWeight: 20 - pause: {duration: 10s} # Add a short duration here so that the rollout quickly proceeds to the next step.After the change is committed, the canary release resumes. Run the following command to view the rollout status.
kubectl argo rollouts get rollout rollouts-demo --watchExpected output:
Name: rollouts-demo Namespace: default Status: ‖ Paused Message: CanaryPauseStep Strategy: Canary Step: 3/8 SetWeight: 40 ActualWeight: 40 Images: argoproj/rollouts-demo:red (stable) argoproj/rollouts-demo:yellow (canary) Replicas: Desired: 4 Current: 6 Updated: 2 Ready: 6 Available: 6 NAME KIND STATUS AGE INFO ⟳ rollouts-demo Rollout ‖ Paused 11m ├──# revision:2 │ └──⧫ rollouts-demo-6cf78c66c5 ReplicaSet ✔ Healthy 6m17s canary │ ├──□ rollouts-demo-6cf78c66c5-kqp7x Pod ✔ Running 6m17s ready:1/1 │ └──□ rollouts-demo-6cf78c66c5-lbfcv Pod ✔ Running 7s ready:1/1 ├──# revision:1 │ └──⧫ rollouts-demo-5747959bdb ReplicaSet ✔ Healthy 11m stable │ ├──□ rollouts-demo-5747959bdb-8m825 Pod ✔ Running 11m ready:1/1 │ ├──□ rollouts-demo-5747959bdb-kpqvh Pod ✔ Running 11m ready:1/1 │ ├──□ rollouts-demo-5747959bdb-vfqtm Pod ✔ Running 11m ready:1/1 │ └──□ rollouts-demo-5747959bdb-xdkv8 Pod ✔ Running 11m ready:1/1
After the canary release is complete, the result is as follows.
Name: rollouts-demo Namespace: default Status: ✓ Healthy Strategy: Canary Step: 8/8 SetWeight: 100 ActualWeight: 100 Images: argoproj/rollouts-demo:yellow (stable) Replicas: Desired: 4 Current: 4 Updated: 4 Ready: 4 Available: 4 NAME KIND STATUS AGE INFO ⟳ rollouts-demo Rollout ✓ Healthy 27m ├──# revision:2 │ └──⧫ rollouts-demo-6cf78c66c5 ReplicaSet ✓ Healthy 22m stable │ ├──□ rollouts-demo-6cf78c66c5-kqp7x Pod ✓ Running 22m ready:1/1 │ ├──□ rollouts-demo-6cf78c66c5-lbfcv Pod ✓ Running 16m ready:1/1 │ ├──□ rollouts-demo-6cf78c66c5-74zcv Pod ✓ Running 11m ready:1/1 │ └──□ rollouts-demo-6cf78c66c5-vt7ns Pod ✓ Running 6m3s ready:1/1 ├──# revision:1 │ └──⧫ rollouts-demo-5747959bdb ReplicaSet • ScaledDown 27m
Automatic verification based on Managed Service for Prometheus metrics
In the rollout.yaml file, modify the following content, and then save and commit the changes.
strategy: canary: analysis: # Metric analysis configuration. templates: # Metric analysis templates. - templateName: success-rate startingStep: 2 #delay starting analysis run until setWeight: 40% args: - name: service-name value: rollouts-demo-stable canaryService: rollouts-demo-canary stableService: rollouts-demo-stable trafficRouting: nginx: stableIngress: rollouts-demo-stable steps: - setWeight: 20 - pause: {duration: 5m} - setWeight: 40 - pause: {duration: 5m} - setWeight: 60 - pause: {duration: 5m} - setWeight: 80 - pause: {duration: 5m} revisionHistoryLimit: 2 selector: matchLabels: app: rollouts-demo template: metadata: labels: app: rollouts-demo spec: containers: - name: rollouts-demo image: argoproj/rollouts-demo:blue # Set a new image tag.Obtain the Service address of Managed Service for Prometheus.
The Service address uses the standard Kubernetes Service address format
{ServiceName}.{Namespace}.svc.{ClusterDomain}:{ServicePort}. For example, in this topic, the Service for Managed Service for Prometheus is deployed in the arms-prom namespace and the exposed Service name isarms-prom-server, the default ClusterDomain of the cluster iscluster.local, and the Service port is9090. Therefore, the Service address of Managed Service for Prometheus ishttp://arms-prom-server.arms-prom.svc.cluster.local:9090.In the analysis.yaml file, add the following configuration for Managed Service for Prometheus business metrics.
In the following sample, the
addressfield specifies the Service address of Managed Service for Prometheus that you obtained in the previous step. For example, in the following sample code, the canary release succeeds when the proportion of successful requests to the canary application reaches 95% within a collection period, and the canary release then automatically proceeds to the next step. For more information about how to configure metric collection, see Metric collection documentation.apiVersion: argoproj.io/v1alpha1 kind: AnalysisTemplate metadata: name: success-rate spec: args: - name: service-name metrics: - name: success-rate interval: 5m successCondition: result[0] >= 0.95 # Metric evaluation condition. failureLimit: 10 provider: prometheus: # Metric collection service address. address: http://arms-prom-server.arms-prom.svc.cluster.local:9090 # Managed Service for Prometheus service address obtained in the previous step. query: | sum( irate(nginx_ingress_controller_requests{status=~"(1|2).*", canary!="" ,service="{{args.service-name}}"}[5m])) / sum(irate(nginx_ingress_controller_requests{canary!="",service="{{args.service-name}}"}[5m]) )Make sure that Managed Service for Prometheus has continuous metric data.
Run the following command to obtain the Ingress information of the ACK cluster, so that you can continuously access the Ingress entry point of the application.
kubectl get ingressExpected output:
NAME CLASS HOSTS ADDRESS PORTS AGE rollouts-demo-rollouts-demo-stable-canary nginx rollouts-demo.local 8.217.XX.XX 80 9h rollouts-demo-stable nginx rollouts-demo.local 8.217.XX.XX 80 9hModify the local Hosts file and add the following configuration.
8.217.XX.XX rollouts-demo.localIn a separate terminal window, continuously generate access traffic for the application.
while true; do curl -s "http://rollouts-demo.local/" | grep -o "<title>.*</title>" ;sleep 0.2;done
Run the following command to view the rollout status.
kubectl argo rollouts get rollout rollouts-demo --watchExpected output:
Name: rollouts-demo Namespace: default Status: ॥ Paused Message: CanaryPauseStep Strategy: Canary Step: 3/8 SetWeight: 40 ActualWeight: 40 Images: argoproj/rollouts-demo:blue (canary) argoproj/rollouts-demo:yellow (stable) Replicas: Desired: 4 Current: 6 Updated: 2 Ready: 6 Available: 6 NAME KIND STATUS AGE INFO ◇ rollouts-demo Rollout ॥ Paused 38m ├── # revision:3 │ ├── ⧫ rollouts-demo-687d76d795 ReplicaSet ✔ Healthy 5m40s canary │ │ ├── □ rollouts-demo-687d76d795-xvrzc Pod ✔ Running 5m40s ready:1/1 │ │ └── □ rollouts-demo-687d76d795-8ds55 Pod ✔ Running 39s ready:1/1 │ └── α rollouts-demo-687d76d795-3 AnalysisRun ◌ Running 39s ✔ 1 ├── # revision:2 │ ├── ⧫ rollouts-demo-6cf78c66c5 ReplicaSet ✔ Healthy 32m stable │ │ ├── □ rollouts-demo-6cf78c66c5-kap7x Pod ✔ Running 32m ready:1/1 │ │ ├── □ rollouts-demo-6cf78c66c5-lbfcv Pod ✔ Running 26m ready:1/1 │ │ ├── □ rollouts-demo-6cf78c66c5-74zcv Pod ✔ Running 21m ready:1/1 │ │ └── □ rollouts-demo-6cf78c66c5-vt7ns Pod ✔ Running 16m ready:1/1 └── # revision:1 └── ⧫ rollouts-demo-5747959bdb ReplicaSet ● ScaledDown 37mView the Managed Service for Prometheus metrics.
-
Log on to the ACK console. In the left navigation pane, click Clusters.
-
On the Clusters page, click the name of your cluster. In the left navigation pane, click .
On the Prometheus Monitoring page, click the Network Monitoring tab, and then click Ingresses.
The following figure shows the Managed Service for Prometheus metrics.

After the canary release is complete, the result is as follows.
Name: rollouts-demo Namespace: default Status: ✓ Healthy Strategy: Canary Step: 8/8 SetWeight: 100 ActualWeight: 100 Images: argoproj/rollouts-demo:blue (stable) Replicas: Desired: 4 Current: 4 Updated: 4 Ready: 4 Available: 4 NAME KIND STATUS AGE INFO ⟳ rollouts-demo Rollout ✓ Healthy 53m ├──# revision:3 │ ├──⧉ rollouts-demo-687d76d795 ReplicaSet ✓ Healthy 21m stable │ │ ├──□ rollouts-demo-687d76d795-xvrzc Pod ✓ Running 21m ready:1/1 │ │ ├──□ rollouts-demo-687d76d795-8ds55 Pod ✓ Running 16m ready:1/1 │ │ ├──□ rollouts-demo-687d76d795-vl58n Pod ✓ Running 11m ready:1/1 │ │ └──□ rollouts-demo-687d76d795-h5nwx Pod ✓ Running 6m ready:1/1 │ └──α rollouts-demo-687d76d795-3 AnalysisRun ✓ Successful 16m ✓ 4 ├──# revision:2 │ └──⧉ rollouts-demo-6cf78c66c5 ReplicaSet • ScaledDown 48m └──# revision:1 └──⧉ rollouts-demo-5747959bdb ReplicaSet • ScaledDown 53m-
(Optional) Step 5: Roll back the canary release
During a canary release, if you find that the application is abnormal, you can roll back the release by modifying the rollout.yaml file. The procedure is as follows.
In the rollout.yaml file, modify the following content, and then save and commit the changes.
spec:
containers:
- name: rollouts-demo
image: argoproj/rollouts-demo:yellow # Change this value to the tag of the stable version, then save and commit the change to the Git repository.Run the following command to view the rollout status.
kubectl argo rollouts get rollout rollouts-demo --watchExpected output:
Name: rollouts-demo
Namespace: default
Status: ✓ Healthy
Strategy: Canary
Step: 8/8
SetWeight: 100
ActualWeight: 100
Images: argoproj/rollouts-demo:yellow (stable)
Replicas:
Desired: 4
Current: 4
Updated: 4
Ready: 4
Available: 4
NAME KIND STATUS AGE INFO
⟳ rollouts-demo Rollout ✓ Healthy 66m
├──# revision:4
│ └──⧫ rollouts-demo-6cf78c66c5 ReplicaSet ✓ Healthy 61m stable
│ ├──□ rollouts-demo-6cf78c66c5-p7k6w Pod ✓ Running 7m18s ready:1/1
│ ├──□ rollouts-demo-6cf78c66c5-bthgh Pod ✓ Running 6m17s ready:1/1
│ ├──□ rollouts-demo-6cf78c66c5-wlw64 Pod ✓ Running 5m17s ready:1/1
│ └──□ rollouts-demo-6cf78c66c5-ldfv9 Pod ✓ Running 4m17s ready:1/1
├──# revision:3
│ ├──⧫ rollouts-demo-687d76d795 ReplicaSet • ScaledDown 34m
│ └──α rollouts-demo-687d76d795-3 AnalysisRun ✓ Successful 29m ✓ 4
├──# revision:1
│ └──⧫ rollouts-demo-5747959bdb ReplicaSet • ScaledDown 66m