You can use Distributed Cloud Container Platform for Kubernetes (ACK One) GitOps to manage applications. ACK One GitOps is completely compatible with ArgoCD and supports continuous iterations. You can use Git repositories as data sources to deploy applications instead of distributing YAML templates. This topic describes how to use the ACK One GitOps console and CLI to deploy applications.
Prerequisites
The Fleet management feature is enabled. For more information, see Enable Fleet management.
Multiple clusters are associated with the Fleet instance. For more information, see Associate clusters with a Fleet instance.
The kubeconfig file of the Fleet instance is obtained in the ACK One console and a kubectl client is connected to the Fleet instance.
The latest version of Alibaba Cloud CLI is installed and credentials are configured. For more information, see Install Alibaba Cloud CLI and Configure credentials. If you use a Resource Access Management (RAM) user, make sure that the RAM user is granted the AliyunAdcpFullAccess permission. For more information, see Grant permissions to a RAM user.
The latest version of the ArgoCD CLI is downloaded and installed through ArgoCD.
You are logged on to the GitOps system. For more information, see Log on to the GitOps system.
Use ACK One GitOps to deploy applications
After ACK One GitOps is enabled, you can use the ACK One GitOps (ArgoCD) console or the ArgoCD CLI to deploy and manage applications.
Use the ACK One GitOps (ArgoCD) console to deploy applications
Step 1: Add a Git repository in the ArgoCD console and synchronize application configurations to specified clusters
Access the ArgoCD server domain name from a web browser to log on to the ArgoCD console. For more information about how to obtain the domain name of the ArgoCD server, see Log on to the GitOps system.
On the ArgoCD homepage, click LOGIN VIA ALIYUN.
Add a source Git repository.
In the left-side navigation pane, choose Settings > Repositories and click + CONNECT REPO.
In the panel that appears, specify the following information and click CONNECT.
Then, the CONNECTION STATUS column of the Git repository displays Successful.
Create an ArgoCD application and deploy the application to the specified cluster.
On the Applications page, click + NEW APP and specify the following information. The application will pull the Helm chart in the source Git repository and deploy it to the default namespace of the specified cluster.
After the configuration is complete, click CREATE in the upper part of the panel.
Then, you can view the status of the echo-server-app application on the Applications page.
Click SYNC below the application to deploy the application to the specified cluster.
If Healthy and Synced appear to the right of Status, the application is deployed. Click echo-server to view the details of the application, including the topology and status of the Kubernetes resources related to the application.
Step 2: Query the deployment of the application
Use the kubeconfig file to connect to the Fleet instance and run the following commands to query the deployment of the application.
Run the following command to query information about the clusters that are associated with the Fleet instance:
kubectl amc get managedcluster
Expected output:
Name Alias HubAccepted cd**** ackpro-cluster2 true ce**** ackpro-cluster1 true // The cluster in which the application is deployed.
Run the following command to query Deployments, Services, and pods in the default namespace. Configure the
amc -m
parameter to specify the cluster in which the application is deployed.kubectl amc get all -n default -m ce****
Expected output:
Run on ManagedCluster ce**** (ackpro-cluster1) NAME READY STATUS RESTARTS AGE pod/echo-server-5cf54bdbcb-jv58k 1/1 Running 0 59m NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/echo-server LoadBalancer 192.XX.XX.XX 39.XX.XX.XX 8080:31769/TCP 59m 21d NAME READY UP-TO-DATE AVAILABLE AGE deployment.apps/echo-server 1/1 1 1 59m
Run the following command to access the public IP address of the LoadBalancer Service to query the version of the application:
curl http://39.XX.XX.XX:8080/version
Expected output:
"Hello Echo Server v1.0"
The application version is v1.0.
Step 3: Update the application
Change the tag of the pod image in the Git repository from v1.0 to v2.0.
Due to the tag change in the Git repository, the ArgoCD application displays OutOfSync.
Click the OutOfSync icon in yellow to view the difference.
The following figure shows the difference.
Click SYNC to initiate a synchronization task. After the task is completed, the tag of the pod image changes to v2.0.
Run the following command to access the Service and check the actual version:
curl http://39.XX.XX.XX:8080/version
Expected output:
"Hello Echo Server v2.0"
The output indicates that the application is updated to v2.0.
Step 4: Roll back to an application version
After the application is updated to v2.0, ArgoCD retains the original ReplicaSet for rollback.
Run the following command with the
amc -m
parameter on the Fleet instance to query the status of the resources in the specified cluster:kubectl amc get replicaset -n default -m ce****
Expected output:
Run on ManagedCluster ce**** (ackpro-cluster1) NAME DESIRED CURRENT READY AGE echo-server-55664c4677 1 1 1 26m // The version is v2.0. echo-server-5cf54bdbcb 0 0 0 109m // The version is v1.0.
To roll back the application to v1.0, click HISTORY AND ROLLBACK on the application page to view all historical versions of the application.
Select v1.0 and click Rollback.
Then, the pod image tag changes to v1.0. Due to the difference between the ArgoCD application and the source Git repository, the status of the application changes to OutOfSync. Click SYNC to initiate a synchronization task.
NoteArgoCD automatically synchronizes information from the source Git repository.
Use the ArgoCD CLI to deploy applications
Run the following command to access ArgoCD through the ArgoCD server domain name. The ArgoCD CLI will open the web browser to complete single sign-on (SSO).
argocd login argocd.<ackone cluster id>.<region>.alicontainer.com --sso Opening browser for authentication Performing authorization_code flow login: https://signin.aliyun.com/oauth2/v1/auth?xxx Authentication successful 'root' logged in successfully Context 'argocd.<ackone cluster id>.<region>.alicontainer.com' update
Run the following command to add a source Git repository:
argocd repo add https://github.com/AliyunContainerService/gitops-demo.git --name echo-server
Expected output:
Repository 'https://github.com/AliyunContainerService/gitops-demo.git' added
Run the following command to query Git repositories:
argocd repo list
Expected output:
TYPE NAME REPO INSECURE OCI LFS CREDS STATUS MESSAGE PROJECT git https://github.com/AliyunContainerService/gitops-demo.git false false false false Successful default
Run the following command to query clusters:
argocd cluster list
Expected output:
SERVER NAME VERSION STATUS MESSAGE PROJECT https://10.XX.XX.XX:XX ce****-ackpro-cluster1 Unknown Cluster has no applications and is not being monitored. https://10.XX.XX.XX:XX cd****-ackpro-cluster2 Unknown Cluster has no applications and is not being monitored. https://kubernetes.default.svc in-cluster Unknown Cluster has no applications and is not being monitored.
You can associate clusters with the Fleet instance. ACK One automatically synchronizes information about the newly associated clusters to ArgoCD.
Run the following command to create an application:
argocd app create echo-server --repo https://github.com/AliyunContainerService/gitops-demo.git --path manifests/helm --revision one-demo --dest-namespace default --dest-server https://10.0.XX.XX:6443
Expected output:
application 'echo-server' created
Run the following command to pull the application configuration from the Git repository and deploy the application in the specified cluster.
argocd app sync echo-server
Deploy an application to multiple clusters with an ArgoCD ApplicationSet
For more information, see Use an ApplicationSet to create multiple applications.
Deploy an OCI Helm chart with an ArgoCD application
For more information, see Use ACK One GitOps to deploy a Container Registry Enterprise Edition OCI Helm chart.