A complete continuous integration and continuous delivery (CI/CD) pipeline can trigger builds based on code commits, push the image to Container Registry, and then trigger Distributed Cloud Container Platform for Kubernetes (ACK One) GitOps to deploy the updated application to multiple clusters. This topic describes the terms used in ACK One GitOps and the procedure of a CI/CD pipeline.
Terms
Procedure
This best practice describes how to use ACK One GitOps and Container Registry to create CI/CD pipelines in Dev, Staging, and Production clusters. These pipelines can automatically synchronize image changes to applications and deploy the updated image in the preceding clusters by using the recommended deployment method after you commit code changes to your Git repository.
Dev cluster: automatically synchronizes image changes and deploys the latest image.
Staging and Production clusters: deploy the latest image based on Rollouts after you manually synchronize image changes.
Prepare a business code repository and a deployment repository.
Enable and log on to ACK One GitOps. The O&M team first needs to configure a CI pipeline and filter rules, and associate the pipeline with a Container Registry Enterprise Edition instance.
The developer team commits code changes to the business code repository to trigger the Container Registry Enterprise Edition instance to build an image. After the image is built, the Container Registry Enterprise Edition instance pushes the image to the image repository.
When ACK One GitOps detects image changes in the image repository, it proposes the latest image version tag back to the deployment repository.
When ACK One GitOps detects image version tag changes in the deployment repository, it triggers the application to deploy the latest image to the Dev cluster.
If the Staging cluster is configured with auto application synchronization, ACK One GitOps automatically updates the image version.
The image updater can detect image updates that match the specified filter rules in the image repository.
Argo CD can monitor YAML changes in the deployment repository.
After the continuous delivery is complete, the developer team can check whether the application in the Dev cluster meets their requirements.
If the application meets the requirements, the O&M team triggers ACK One GitOps to deploy the application to the Staging and Production clusters. The O&M team also uses Argo Rollout or Kruise Rollout to perform canary releases. For more information, see Use ACK One GitOps and Argo Rollouts to perform canary releases and Use Kruise Rollout to implement canary releases based on ACK One GitOps.
ImportantAdditional steps are required for performing rolling updates in the Staging and Production clusters across regions. You cannot directly deploy the updated image in the Staging and Production clusters by committing code changes.
Step 1: View the directory tree of the deployment repository
You can reference the directory tree of the deployment repository in this best practice. For more information, see Introduction to sample applications deployed based on ACK One GitOps.
Step 2: Enable and log on to ACK One GitOps
You can use the ACK One console or CLI to enable and log on to ACK One GitOps.
Use the console
Log on to the ACK One console. In the left-side navigation pane, choose .
On the Multi-cluster GitOps page, click
to the right of the Fleet instance name in the upper-left corner and then select a Fleet instance from the drop-down list. By default, GitOps is enabled for newly created Fleet instances. If GitOps is disabled for your Fleet instance, click Enable GitOps. In the dialog box that appears, click OK.
If GitOps is enabled for your Fleet instance, the GitOps page displays GitOps Console and Access Control.
On the GitOps page, click GitOps Console.
If you want to access GitOps over the Internet, enable public access to GitOps first. For more information, see Enable public access to GitOps.
Use the CLI
For more information about how to use the CLI to enable and log on to ACK One GitOps, see the Step 1: Enable public access to the GitOps console section of the "Work with GitOps" topic and Log on to the GitOps system.
Step 3: Build an image CI pipeline
You can use the following methods to build an image CI pipeline. You can also use a third-party CI system to build the pipeline.
Method 1: Build a CI pipeline based on Container Registry
Create an image repository based on Container Registry Enterprise Edition, bind the image repository to the business code repository, and configure build rules. For more information, see Use a Container Registry Enterprise Edition instance to build an image. You can turn on Pull from Anonymous Users on the overview page of the Container Registry Enterprise Edition instance or use aliyun-acr-credential-helper to pull images without using Secrets. For more information, see Use the aliyun-acr-credential-helper component to pull images without using a secret.
If your business code repository is a Git repository and image pulling times out, enable the Build With Servers Deployed Outside Chinese Mainland feature.
Method 2: Build a CI pipeline based on an ACK One workflow cluster
For more information about how to build a CI pipeline based on an ACK One workflow cluster, see Use an ACK One workflow cluster to build an image CI pipeline.
Step 4: Use ACK One GitOps to deploy an application
After ACK One GitOps is enabled, you can use the ACK One GitOps (Argo CD) console or Argo CD CLI to deploy and manage applications. You can use ApplicationSets to deploy multi-cluster applications based on GitOps. For more information, see Use ACK One GitOps to deploy applications.
Step 5: Use the ACK One GitOps image updater to build a CI/CD pipeline
ACK One GitOps fixes the continuous delivery issue. However, the developer team requires an end-to-end automated solution that covers code commits, image building, and automated deployment to improve development efficiency.
To fix this issue, ACK One GitOps integrates the Argo CD image updater and supports Container Registry image repositories. When the CI pipeline is triggered by code commits to build and push images to a Container Registry Enterprise Edition image repository, the image updater can monitor image changes and automatically update the corresponding image version tag in the deployment repository.
After the image version tag is updated, the Argo CD Application detects the change and initiates a Sync operation to deploy the latest image. Based on the image updater, ACK One GitOps can work with CI pipelines to automate continuous integration and continuous delivery.
For more information, see Use ACK One GitOps and Container Registry to build CI/CD pipelines.
Argo CD can monitor changes in the deployment repository. Therefore, if you want to directly update the YAML image in the deployment repository to trigger continuous delivery, you do not need to use the image updater to monitor changes in the image repository.
Step 6: Perform canary releases
Additional steps are required for performing rolling updates in the Staging and Production clusters across regions. You cannot directly deploy the updated image in the Staging and Production clusters by committing code changes. For more information, see Use ACK One GitOps and Argo Rollouts to perform canary releases and Use Kruise Rollout to implement canary releases based on ACK One GitOps.
Step 7: Roll back an application
You may want to roll back an application when a release fails. You can use one of the following methods to roll back an application.
Quick rollback
On the Applications page of the Argo CD console, click HISTORY AND ROLLBACK, select a version, and then click ROLLBACK. For more information, see the Step 4: Roll back to an application version section of the "Use ACK One GitOps to deploy applications" topic.
Use the Argo CD CLI to roll back the application. For more information, see the Use the Argo CD CLI section of the "Application management" topic.
End-to-end rollback
Run the following command to roll back to a historical commit and trigger the CI/CD pipeline:
# Roll back to a historical commit.
git revert HEAD
# git revert HEAD~3.. HEAD~3 indicates the fourth last commit from the current one.
# git revert <commit-id-1> <commit-id-2> ... <commit-id-n> indicates the number of commits from which changes can be reverted. The commits are not consecutive.
# After the revert operation is complete, push the local branch to the remote repository to trigger the CI/CD pipeline.
git push origin HEAD:${branch}The image updater synchronizes the reverted changes to the deployment repository and updates the changes to the application.
Step 8: Manage user permissions in ACK One GitOps
Argo CD provides a powerful user permission management feature. This feature allows you to manage the permissions of a user on a resource by using the following permission policy template. The supported resources include applications, clusters, and repositories. You can also specify the project to which the resources belong. You can limit users from performing actions such as create, update, delete, and get.
p, <user/group>, <resource>, <action>, <project>/<object>For more information, see Configure multi-tenant permissions for ACK One GitOps.