6.2. Preparing a parallel Argo CD pipeline for ClusterInstance CRs
Create a parallel Argo CD project and application to manage the new ClusterInstance CRs and associated cluster resources.
Prerequisites
-
You have logged in to the hub cluster as a user with
cluster-adminprivileges. - You have configured your GitOps ZTP environment successfully.
- You have installed and configured the Assisted Installer service successfully.
- You have access to the Git repository that contains your single-node OpenShift cluster configurations.
Procedure
Create YAML files for the parallel Argo project and application:
Create a YAML file that defines the
AppProjectresource:Example
ztp-app-project-v2.yamlfileapiVersion: argoproj.io/v1alpha1 kind: AppProject metadata: name: ztp-app-project-v2 namespace: openshift-gitops spec: clusterResourceWhitelist: - group: hive.openshift.io kind: ClusterImageSet - group: hive.openshift.io kind: ClusterImageSet - group: cluster.open-cluster-management.io kind: ManagedCluster - group: "" kind: Namespace destinations: - namespace: '*' server: '*' namespaceResourceWhitelist: - group: "" kind: ConfigMap - group: "" kind: Namespace - group: "" kind: Secret - group: agent-install.openshift.io kind: InfraEnv - group: agent-install.openshift.io kind: NMStateConfig - group: extensions.hive.openshift.io kind: AgentClusterInstall - group: hive.openshift.io kind: ClusterDeployment - group: metal3.io kind: BareMetalHost - group: metal3.io kind: HostFirmwareSettings - group: agent.open-cluster-management.io kind: KlusterletAddonConfig - group: cluster.open-cluster-management.io kind: ManagedCluster - group: siteconfig.open-cluster-management.io kind: ClusterInstance1 sourceRepos: - '*'- 1
- The
ClusterInstanceCR manages thesiteconfig.open-cluster-management.ioobject instead of theSiteConfigCR.
Create a YAML file that defines the
Applicationresource:Example
clusters-v2.yamlfileapiVersion: argoproj.io/v1alpha1 kind: Application metadata: name: clusters-v2 namespace: openshift-gitops spec: destination: namespace: clusters-sub server: https://kubernetes.default.svc ignoreDifferences: - group: cluster.open-cluster-management.io kind: ManagedCluster managedFieldsManagers: - controller project: ztp-app-project-v21 source: path: site-configs-v22 repoURL: http://infra.5g-deployment.lab:3000/student/ztp-repository.git targetRevision: main syncPolicy: syncOptions: - CreateNamespace=true - PrunePropagationPolicy=background - RespectIgnoreDifferences=true- 1
- The
projectfield must match the name of theAppProjectresource created in the previous step. - 2
- The
pathfield must match the root folder in your Git repository that will contain theClusterInstanceCRs and associated resources.注意By default,
auto-syncis enabled. However, synchronization only occurs when you push configuration data for the cluster to the new configuration folder, or in this example, thesite-configs-v2/folder.
Create and commit a root folder in your Git repository that will contain the
ClusterInstanceCRs and associated resources, for example:$ mkdir site-configs-v2 $ touch site-configs-v2/.gitkeep $ git commit -s -m “Creates cluster-instance folder” $ git push origin mainThe
.gitkeepfile is a placeholder to ensure that the empty folder is tracked by Git.注意You only need to create and commit the root
site-configs-v2/folder during pipeline setup. You will mirror the completesite-configs/folder structure intosite-configs-v2/during the cluster migration procedure.
Apply the
AppProjectandApplicationresources to the hub cluster by running the following commands:$ oc apply -f ztp-app-project-v2.yaml $ oc apply -f clusters-v2.yaml
Verification
Verify that the original Argo CD project,
ztp-app-project, and the new Argo CD project,ztp-app-project-v2are present on the hub cluster by running the following command:$ oc get appprojects -n openshift-gitopsExample output
NAME AGE default 46h policy-app-project 42h ztp-app-project 18h ztp-app-project-v2 14sVerify that the original Argo CD application,
clusters, and the new Argo CD application,clusters-v2are present on the hub cluster by running the following command:$ oc get application.argo -n openshift-gitopsExample output
NAME SYNC STATUS HEALTH STATUS clusters Synced Healthy clusters-v2 Synced Healthy policies Synced Healthy