ACK One GitOps is a managed service that is fully compatible with ArgoCD capabilities. It supports continuous iteration and allows you to use Git deployment templates instead of the template-based distribution capability. Publish an application to a target cluster by using the ACK One GitOps console or the ArgoCD CLI.
Prerequisites
You have enabled the fleet management feature.
The Fleet instance has added two associated clusters (service provider cluster, service consumer cluster).
Obtain the KubeConfig for the Fleet instance from the ACK One console, and connect to the Fleet instance using kubectl.
-
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 the operations are performed by 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 has been downloaded and installed from ArgoCD.
-
You have logged on to the GitOps system. For more information, see Log on to the GitOps system.
Deploy applications by using ACK One GitOps
After you enable ACK One GitOps, you can deploy and manage applications in two ways: by using the ACK One GitOps (ArgoCD) console or by using the ArgoCD CLI.
Deploy applications by using the ACK One GitOps (ArgoCD) console
Step 1: In the ArgoCD console, add a Git Repo and synchronize it to the target cluster
-
In your browser, enter the ArgoCD Server domain name that you obtained to access the ArgoCD console. For information about how to obtain the domain name, see Log on to the GitOps system.
-
On the ArgoCD homepage, click LOGIN VIA ALIYUN to log on to the ArgoCD console.
-
Add the Git Repo used as the deployment source.
-
In the left-side navigation pane, choose Settings > Repositories, and then click + CONNECT REPO.
-
In the panel that appears, configure the following information, and then click CONNECT.
Set the connection method to VIA SSH and configure the following parameters:
-
Project: Enter
default. -
Repository URL: Enter
https://github.com/AliyunContainerService/gitops-demo.git. -
SSH private key data: Enter the corresponding SSH private key.
After the Git Repo is added, the page shows the CONNECTION STATUS of the Git repository as Successful.
After the connection is successful, the repository connection list displays the type as git, the repository address as
https://github.com/AliyunContainerService/gitops-demo.git, and Successful in the CONNECTION STATUS column. -
-
-
Create an ArgoCD Application and publish the application to the target cluster.
-
On the Applications page, click + NEW APP and configure the following information. The Application pulls the Helm Chart from the Git Repo and deploys it to the default namespace of the target cluster.
In the NEW APP form in ArgoCD, configure the following key parameters:
-
Application Name: Enter the application name, such as
gitOps-demo. -
Project Name: Select
default. -
SYNC POLICY: Select Manual.
-
Repository URL: Enter the Git repository URL, such as
https://github.com/AliyunContainerService/gitops-demo.git. -
Revision: Enter the branch name, such as
one-demo. -
Path: Enter the path of the deployment manifest, such as
manifests/helm. -
Cluster URL: Select the URL of the target cluster.
-
Namespace: Enter
default.
-
-
After the configuration is complete, click CREATE at the top of the page.
After the application is created, you can view the status of the echo-server-app application on the Applications page of ArgoCD.
On the Applications page, you can see the echo-server application card, and the bottom of the card contains the SYNC button.
-
Click SYNC below the target application to synchronize and deploy the application to the target cluster.
-
After the synchronization is complete, the Status of the echo-server-app application shows Healthy and Synced on the right, which indicates that the application is synchronized. Click echo-server to view the details of the application. ArgoCD displays the topology of the Kubernetes resources related to the application and their corresponding status.
After the synchronization is complete, the application details page shows APP HEALTH as Healthy and CURRENT SYNC STATUS as Synced, which indicates that the application is successfully synchronized and running properly. The resource tree shows the complete deployment hierarchy from the Helm application to the Service, Deployment, ReplicaSet, and Pod.
-
Step 2: View the actual deployment of the application
Connect to the Fleet instance with its kubeconfig, and then run commands against it to view the actual deployment of the application.
-
View the associated clusters of the Fleet instance.
kubectl amc get managedclusterExpected output:
Name Alias HubAccepted cd**** ackpro-cluster2 true ce**** ackpro-cluster1 true // GitOps deployment target cluster. -
Specify the cluster with the
amc -mparameter to view the Deployment, Service, and Pod resources in the default namespace.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 -
Access the External-IP of the LoadBalancer Service and verify that the application is running.
curl http://39.XX.XX.XX:8080/versionExpected output:
"Hello Echo Server v1.0"The expected output indicates that the current application version is v1.0.
Step 3: Upgrade the application version
-
Change the Image Tag version in Git from v1.0 to v2.0.
Modify the
gitops-demo/manifests/helm/values.yamlfile and update the imagetagvalue to"v2.0":image: repository: registry.cn-hangzhou.aliyuncs.com/xxx/echo-server pullPolicy: IfNotPresent # Overrides the image tag whose default is the chart appVersion. tag: "v2.0" service: type: LoadBalancer #type: NodePort #type: ClusterIPBecause the Git Repo has changed, the ArgoCD Application displays OutOfSync.
-
Click the yellow OutOfSync icon to view the detailed differences.
On the ArgoCD application details page, APP HEALTH shows Healthy, CURRENT SYNC STATUS shows OutOfSync (highlighted in orange), and the source Comment is
update helm chart.The DIFF view shows that the container image is changed from
registry.cn-hangzhou.aliyuncs.com/xxx/echo-server:v1.0toregistry.cn-hangzhou.aliyuncs.com/xxx/echo-server:v2.0. After you confirm that the difference is correct, click the SYNC button in the upper-right corner to synchronize the application to the latest version. -
Click SYNC to start the synchronization. After the synchronization is complete, the Pod Image Tag becomes v2.0, which is as expected.
The tree view of the ArgoCD application details shows that the synchronization status of the echo-server application is Synced, the health status is Healthy, and the Pod image is
registry.cn-hangzhou.aliyuncs.com/haoshuwei24/echo-server:v2.0. -
Access the Service and view the actual version.
curl http://39.XX.XX.XX:8080/versionExpected output:
"Hello Echo Server v2.0"The expected output indicates that the application version is upgraded to v2.0.
Step 4: Roll back the application version
After the version is upgraded to v2.0, ArgoCD retains the previous ReplicaSet so that you can quickly roll back to the previous version.
-
On the ACK One Fleet instance, use the
amc -mparameter to view the resource status of the specified associated 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 // Version v2.0. echo-server-5cf54bdbcb 0 0 0 109m // Version v1.0. -
To roll back to version v1.0, you can click HISTORY AND ROLLBACK on the application page to view all historical versions of the application.
In the toolbar at the top of the ArgoCD application details page, click the HISTORY AND ROLLBACK button to open the version history panel.
-
Select the corresponding v1.0 version to roll back to, and then click Rollback.
Select the historical version in which
image.tagisv1.0, click the three-dot menu on the right, and then select Rollback to perform the rollback.At this point, the Pod Image Tag has been rolled back to v1.0. Because a difference occurs between ArgoCD and the Git Repo, the application status changes to OutOfSync. After the issue is fixed, click SYNC to start the synchronization.
NoteArgoCD also supports automatic synchronization of Git Repo information.
Deploy applications by using the ArgoCD CLI
-
Log on to the ArgoCD Server.
-
Use the kubeconfig of the Fleet instance to get the load balancer (LB) IP of the ArgoCD Server.
kubectl get svc -nargocd argocd-server -ojsonpath='{.status.loadBalancer.ingress[0].ip}' -
Get the admin password.
kubectl -nargocd get secret argocd-initial-admin-secret -ojsonpath='{.data.password}' |base64 -d -
Log on to the ArgoCD Server.
argocd login <argocd server lb ip> Username: admin Password: 'admin:login' logged in successfully Context '<argocd server lb ip>' updated
-
-
Add a Git Repo.
argocd repo add https://github.com/AliyunContainerService/gitops-demo.git --name echo-serverExpected output:
Repository 'https://github.com/AliyunContainerService/gitops-demo.git' added -
View the Git Repo list.
argocd repo listExpected 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 -
View the clusters.
argocd cluster listExpected 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.Add new associated clusters by using the ACK One Fleet instance. ACK One automatically synchronizes the clusters to ArgoCD.
-
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:6443Expected output:
application 'echo-server' created -
Pull and synchronize the application from Git and deploy it to the target cluster.
argocd app sync echo-server
Implement multi-cluster GitOps deployment by using ArgoCD ApplicationSet
For more information about how to implement multi-cluster GitOps deployment, see Use an ApplicationSet to create multiple applications.
Deploy an OCI Helm Chart by using ArgoCD Application
For more information about how to deploy an Open Container Initiative (OCI) Helm Chart, see Use ACK One GitOps to deploy Container Registry Enterprise Edition OCI Helm charts.