All Products
Search
Document Center

:Use onectl to migrate applications to ACK One GitOps in an automated manner

Last Updated:Apr 01, 2024

Application Center is no longer updated and will be progressively discontinued. You can use onectl to migrate applications from Application Center to Distributed Cloud Container Platform for Kubernetes (ACK One) GitOps in an automated manner. This topic describes how to use onectl to migrate applications from Application Center to ACK One GitOps in an automated manner.

How applications are migrated

图片1.png

  • onectl uses kubeconfig files to migrate Argo CD from a master cluster of Application Center to a Fleet instance of ACK One. The Argo CD resources include Cluster (Secret), Repo (Secret), and Application resources. onectl migrates Cluster resources by using the associated cluster feature of ACK One.

  • Template type Application resources are an exception. onectl saves their YAML files to a local directory so you can quickly upload them to your Git repository and release them to ACK One by following the steps in Work with GitOps.

  • After onectl migrates applications, delete the Application resources in the master cluster to disassociate them from the applications and associate the applications with the Application resources on the Fleet instance of ACK One.

Prerequisites

Step 1: Configure a RAM user for onectl

You must log on as a Resource Access Management (RAM) user so that you can migrate applications from Application Center to ACK One GitOps. onectl uses the AccessKey ID and AccessKey secret of the RAM user to manage cloud resources. The RAM user must be attached with the AliyunAdcpFullAccess policy and have permissions to use custom ACK templates.

  1. For more information about how to attach the AliyunAdcpFullAccess policy to a RAM user, see Grant permissions to a RAM user.

  2. The following code block shows the policy that provides permissions to use custom ACK templates:

    {
        "Action": [
            "cs:DescribeTemplates",
            "cs:DescribeTemplateAttribute"
        ],
        "Resource": [
            "*"
        ],
        "Effect": "Allow"
    }
  3. Run the following command to specify the AccessKey ID and AccessKey secret of the RAM user for onectl.

    Specify only the Access Key Id and Access Key Secret parameters.

    onectl configure

    Expected output:

    Configuring profile default ...
    Access Key Id [*********************NaY]: 
    Access Key Secret [***************************HUd]: 
    Ram Username []: 
    Default Kubeconfig Path (default is ~/.kube/config) []: 
    Saving profile[default] ...
    Done.

Step 2: Configure environment variables

To make the migration command simple, the ID of the Fleet instance and the ID of the master cluster are specified as environment variables. onectl obtains the kubeconfig files of the Fleet instance and master cluster based on their IDs and saves the files to the ~/.onectl/ directory.

export ACKONE_HUB_CLUSTER_ID=ccc47ca148d0147519f229bba********
export ARGOCD_CLUSTER_ID=ce4bb2004bb0e409eaa4c593d********

Step 3: Migrate Cluster resources

Run the following command to migrate cluster resources from the master cluster to ACK One GitOps:

onectl migrate clusters -n appcenter

Step 4: Migrate Git resources

Run the following command to migrate Git resources from the master cluster to ACK One GitOps:

onectl migrate repos -n appcenter

(Optional) Step 5: View the migration status

Run the following command to query the status of the resources:

#onectl migrate status [clusters|repos|apps] -nappcenter

# Query the status of all resources. 
onectl migrate status -nappcenter

# Query the status of a resource. 
onectl migrate status clusters -nappcenter
onectl migrate status repos -nappcenter
onectl migrate status apps -nappcenter

Expected output:

#################### Clusters Status ####################
All 1 clusters were attached successfully to ACK One ccc47ca148d0147519f229bbaea2963b6 !
CLUSTER                            STATE    MESSAGE
ce4bb2004bb0e409eaa4c593da9e2bc96  Succeed  

#################### Repositories Status ####################
All 1 repos were migrated successfully to ACK One ccc47ca148d0147519f229bbaea2963b6 !
STATE    REPO                                     TYPE  NAME              MESSAGE
Succeed  git@github.com:ivan-cai/gitops-demo.git  git   ivan-gitops-demo  

#################### Applications Status ####################
-------------------- Git/Helm Applications --------------------
Total 'Git/Helm' type applications: 1, success to migrate: 0, pending to migrate: 1
STATE    NAME       NAMESPACE  CLUSTER  STATUS  HEALTH  REPO  PATH  TARGET  MESSAGE
Pending  app-git-2  appcenter                                               application has not been migrated to ACK One ccc47ca148d0147519f229bbaea2963b6

-------------------- Template Applications --------------------
STATE    NAME            NAMESPACE  TEMPLATEID                            TEMPLATEPATH  MESSAGE
Pending  busybox-e2bc96  appcenter  3aa43610-cc02-463a-a600-629b2a97e887                application has not been migrated to ACK One ccc47ca148d0147519f229bbaea2963b6

Step 6: Migrate Application resources

onectl can migrate one or more Application resources at a time. We recommend that you migrate one Application resource at a time.

  • Run the following command to migrate one or more Application resources:

    onectl migrate apps ${app1Name} -n appcenter

    Expected output:

    Applications in source cluster (ArgoCD or AppCenter cluster):
    NAME       NAMESPACE  TYPE      TEMPLATEID
    app-git-2  appcenter  Git/Helm  
    will be migrated to ACK One ccc47ca148d0147519f*********b6. Please checking the source cluster and ACK One cluster. Are you sure to migrate the Applications? [Y/n] y
    
    Total 1 applications will be migrated to ACK One ccc47ca148d0147519f*********b6 ...
    -------------------- Git/Helm Applications --------------------
    Application appcenter/app-git-2 was migrated succeessfully.
    All 1 'Git/Helm' type applications has been migrated successfully o ACK One ccc47ca148d0147519f229bbaea2963b6.
    STATE    NAME       NAMESPACE  CLUSTER                     STATUS  HEALTH   REPO                                     PATH                        TARGET  MESSAGE
    Succeed  app-git-2  argocd     https://172.16.**.**:6443  Synced  Healthy  git@github.com:**/gitops-demo.git  manifests/helm/echo-server  main    
    
    -------------------- Template Applications --------------------
    No 'Template' type applications need to be migrated.
  • Run the following command to migrate all Application resources:

    onectl migrate apps -n appcenter --all

    Expected output:

    Applications in source cluster (ArgoCD or AppCenter cluster):
    NAME            NAMESPACE  TYPE      TEMPLATEID
    app-git-2       appcenter  Git/Helm  
    busybox-e2bc96  appcenter  Template  3aa43610-cc02-463a-a600-629b2a97e887
    will be migrated to ACK One ccc47ca148d0147519f*********b6. Please checking the source cluster and ACK One cluster. Are you sure to migrate the Applications? [Y/n] y
    
    Total 2 applications will be migrated to ACK One ccc47ca148d0147519f*********b6 ...
    -------------------- Git/Helm Applications --------------------
    Application appcenter/app-git-2 was migrated succeessfully.
    All 1 'Git/Helm' type applications has been migrated successfully o ACK One ccc47ca148d0147519f229bbaea2963b6.
    STATE    NAME       NAMESPACE  CLUSTER                     STATUS  HEALTH   REPO                                     PATH                        TARGET  MESSAGE
    Succeed  app-git-2  argocd     https://172.16.**.**:6443  Synced  Healthy  git@github.com:**/gitops-demo.git  manifests/helm/echo-server  main    
    
    -------------------- Template Applications --------------------
    Total 1 'Template' type applications need to be migrated, the k8s resources' templates have been saved in '/tmp/appcentertemplates/', please pushing them to your Git repository, and then using ACK One GitOps to publish applications!
    NAME            NAMESPACE  TEMPLATEID                            TEMPLATENAME  TEMPLATEPATH                                           MESSAGE
    busybox-e2bc96  appcenter  3aa43610-cc02-463a-a600-629b2a97e887  busybox       /tmp/appcentertemplates/appcenter-busybox-e2bc96.yaml  

Step 7: Delete Application resources from Application Center

Run the following command in the master cluster to delete Application resources from Application Center:

Important
  • After you confirm that the application runs properly in ACK One GitOps, remove the application from Application Center.

  • You must specify --cascade=false in the delete command. Otherwise, the Kubernetes resources related to the applications are also deleted.

kubectl --kubeconfig ${ARGOCD_CLUSTER_KUBECONFIG} delete app ${appName}  -n appcenter --cascade=false

Step 8: Uninstall the component from Application Center

After you migrate all applications in the master cluster to ACK One GitOps and ensure that the applications run as normal, you can uninstall the appcenter component on the Add-ons page if it is no longer needed.

  1. Log on to the ACK console. In the left-side navigation pane, click Clusters.

  2. On the Clusters page, click the name of the cluster that you want to manage and choose Operations > Add-ons in the left-side navigation pane.

  3. Click the Manage Applications tab on the Add-ons page. Find the appcenter component and click Uninstall.

References

You can log on to ACK One GitOps to view the status of applications and manage applications. For more information, see Best practice for ACK One GitOps.