All Products
Search
Document Center

Container Service for Kubernetes:Use ACK One GitOps to deploy applications

Last Updated:Feb 07, 2024

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

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

  1. 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.

  2. On the ArgoCD homepage, click LOGIN VIA ALIYUN.

  3. Add a source Git repository.

    1. In the left-side navigation pane, choose Settings > Repositories and click + CONNECT REPO.

    2. In the panel that appears, specify the following information and click CONNECT.添加Git repo.png

      Then, the CONNECTION STATUS column of the Git repository displays Successful.success.png

  4. Create an ArgoCD application and deploy the application to the specified cluster.

    1. 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.添加应用.png

    2. 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.查看状态.png

    3. Click SYNC below the application to deploy the application to the specified cluster.

    4. 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.同步.png

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.

  1. 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.

  2. 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
  3. 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

  1. Change the tag of the pod image in the Git repository from v1.0 to v2.0.修改tag.png

    Due to the tag change in the Git repository, the ArgoCD application displays OutOfSync.

  2. Click the OutOfSync icon in yellow to view the difference.

    更新并同步.png

    The following figure shows the difference.查看区别.png

  3. Click SYNC to initiate a synchronization task. After the task is completed, the tag of the pod image changes to v2.0.确认版本.png

  4. 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.

  1. 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.

  2. To roll back the application to v1.0, click HISTORY AND ROLLBACK on the application page to view all historical versions of the application.回滚版本.png

  3. Select v1.0 and click Rollback.确认回滚.png

    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.

    Note

    ArgoCD automatically synchronizes information from the source Git repository.

Use the ArgoCD CLI to deploy applications

  1. 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
  2. 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
  3. 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
  4. 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.

  5. 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
  6. 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.

References