Container Service for Kubernetes (ACK) GitOps is developed based on open source Argo CD. You cannot create applications from orchestration templates in ACK GitOps. To migrate applications that are created from orchestration templates, you must submit the orchestration templates to Git repositories, create GitOps applications, obtain the orchestration templates from Git repositories, and then distribute the GitOps applications to associated clusters. You can update orchestration templates in Git repositories to update applications. You can manually update the applications in associated clusters or configure GitOps to automatically update the applications in associated clusters. This topic describes how to migrate applications created from orchestration templates to ACK One GitOps.
Table of contents
Prerequisites
The multi-cluster management feature is enabled. For more information, see Enable the multi-cluster management feature.
The kubeconfig file of the master instance is obtained from the Distributed Cloud Container Platform for Kubernetes (ACK One) console. A kubectl client is connected to the master instance.
GitOps is enabled for a master instance and the Argo CD CLI is used to log on to Argo CD. For more information, see Enable GitOps for a master instance of ACK One.
The master cluster in Application Center that you want to manage is obtained from the Application Center page in the Container Service for Kubernetes (ACK) console. You are connected to the master cluster by using kubectl and the kubeconfig file of the master cluster.
Step 1: Obtain orchestration templates from Application Center
Log on to the ACK console and choose in the left-side navigation pane.
On the Application Center page, you can view information about the applications that you want to migrate.
Select a master cluster from the Master Cluster drop-down list.
Find the application that you want to migrate and click the More icon to the left of the application name.
Select a cluster and click View in YAML to obtain the orchestration template that is used to deploy the application in the cluster.
You must obtain the orchestration template for each cluster where the application is deployed.

Step 2: Associate clusters with a master instance
Associate all the clusters (obtained in Step 1) where the application is deployed with a master instance. For more information, see Associate clusters with a master instance.
Step 3: Submit orchestration templates to a Git repository
We recommend that you create a new Git repository to store the orchestration templates. You can also store the orchestration templates in an existing Git repository.
Create a new directory named application1 in the Git repository to store the orchestration template of Application1.
Create a separate subdirectory in the
application1directory for each cluster where Application1 is deployed.Create a YAML file in each subdirectory and specify the orchestration template (obtained in Step 1) for the corresponding cluster. Example:
. └── applicatioin1 ├── cluster-hk │ └── template.yaml └── cluster-hk-1 └── template.yamlAdd the Git repository to ACK One GitOps. For more information, see Add Git repositories to ACK One GitOps.
Step 4: Migrate applications
Use the Argo CD CLI to access the master cluster:
Run the following command in the master cluster to import environment variables:
export ARGOCD_OPTS='--port-forward-namespace appcenter --plaintext'Run the following command in the master cluster to query applications in the cluster:
argocd app list | grep application1Expected output:
NAME CLUSTER NAMESPACE PROJECT STATUS HEALTH SYNCPOLICY CONDITIONS REPO PATH TARGET application1-451a02 https://8.217.XX.XX:6443 default default Synced Healthy <none> <none> aliyun.com HEAD application1-46b9bb https://172.17.XX.XX:6443 default default Synced Healthy <none> <none> aliyun.com HEADThe output indicates that two ArgoCD Applications are created for Application1. Each ArgoCD Application corresponds to a separate cluster. The output also includes the API server address of each cluster.
Run the following command on the master instance to obtain the API server addresses of the clusters that are associated with the master instance:
argocd cluster listExpected output:
SERVER NAME VERSION STATUS MESSAGE PROJECT https://172.17.XX.XX:6443 c03a223407a044cc7b0a9cc1c0a45****-cluster-hk 1.24+ Successful https://172.17.XX.XX:6443 c3f218b3af71b44c189485abd4846****-cluster-hk-1 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.Run the following command on the master instance to export the manifests of the
application1-451a02ArgoCD Application, which corresponds to thecluster-hkcluster.kubectl -n appcenter get application application1-451a02 -oyaml > application1-cluster-hk.yamlModify the application1-cluster-hk.yaml file that is exported in the previous step.
The
application1-451a02ArgoCD Application corresponds to thecluster-hk. The API server address of the cluster-hk cluster ishttps://8.217.XX.XX:6443, which is different from the API server addresshttps://172.17.XX.XX:6443that is used to associatecluster-hkwith the master instance. You must run the following command to replace https://8.217.XX.XX:6443 with https://172.17.XX.XX:6443 in the application1-cluster-hk.yaml file.sed -i "s/8.217.XX.XX/172.17.XX.XX/g" application1-cluster-hk.yamlRun the following shell command to change the value of the namespace parameter in the application1-cluster-hk.yaml file to argocd:
sed -i "s/namespace: appcenter/namespace: argocd/g" application1-cluster-hk.yamlRun the following shell command to change the value of the name parameter in the application1-cluster-hk.yaml file to application1-cluster-hk:
sed -i "s/name: application1-451a02/name: application1-cluster-hk/g" application1-cluster-hk.yamlChange the value of the spec.source parameter in the application1-cluster-hk.yaml file to the Git repository in Step 3.
YAML template before modification:
apiVersion: argoproj.io/v1alpha1 kind: Application metadata: name: application1-cluster-hk namespace: appcenter spec: destination: namespace: default server: https://172.17.XX.XX:6443 project: default # Change the value of the spec.source parameter to the the Git repository. source: repoURL: aliyun.com targetRevision: HEAD template: aliUID: "14****01" id: 3e****afYAML template after modification:
apiVersion: argoproj.io/v1alpha1 kind: Application metadata: name: application1-cluster-hk namespace: appcenter spec: destination: namespace: default server: https://172.17.XX.XX:6443 project: default # The Git repository. source: # The subdirectory for a cluster. path: application1/cluster-hk # The Git repository address. You can view Git repositories by running the argocd repo list command. repoURL: https://github.com/AliyunContainerService/gitops-demo # The branch of the Git repository. targetRevision: one-demoDelete all settings in the
statusparameter in the application1-cluster-hk.yaml file.
Migrate application manifests to the master instance.
Run the following command on the master instance to create an Argo CD Application by using the application1-cluster-hk.yaml file:
kubectl apply -f application1-cluster-hk.yamlRun the following command on the master instance to query Argo CD Applications and their status:
argocd app listExpected output:
NAME CLUSTER NAMESPACE PROJECT STATUS HEALTH SYNCPOLICY CONDITIONS REPO PATH TARGET application1-cluster-hk https://172.17.XX.XX:6443 default default OutOfSync Healthy <none> SharedResourceWarning(2) https://github.com/AliyunContainerService/gitops-demo application1/cluster-hk one-demo
Run the following command in the master cluster to delete applications from Application Center:
ImportantYou must specify
--cascade=falsein the delete command. Otherwise, the Kubernetes resources trelated to the applications are also deleted.argocd app delete application1-451a02 --cascade=falseRun the following command on the master instance to synchronize the application. Check the output to verify that the application is in the
Syncedstate.argocd app sync application1-cluster-hkExpected output:
argocd app list NAME CLUSTER NAMESPACE PROJECT STATUS HEALTH SYNCPOLICY CONDITIONS REPO PATH TARGET application1-cluster-hk https://172.17.XX.XX:6443 default default Synced Healthy <none> <none> https://github.com/AliyunContainerService/gitops-demo application1/cluster-hk one-demoRepeat Step 3 to Step 7 to migrate the remaining applications.