Chapter 6. Migrating from SiteConfig CRs to ClusterInstance CRs
You can incrementally migrate single-node OpenShift clusters from SiteConfig custom resources (CRs) to ClusterInstance CRs. During migration, the existing and new pipelines run in parallel, so you can migrate one or more clusters at a time in a controlled and phased manner.
-
The
SiteConfigCR is deprecated from OpenShift Container Platform version 4.18 and will be removed in a future version. -
The
ClusterInstanceCR is available from Red Hat Advanced Cluster Management (RHACM) version 2.12 or later.
6.1. Overview of migrating from SiteConfig CRs to ClusterInstance CRs Copy linkLink copied to clipboard!
The ClusterInstance CR provides a more unified and generic approach to defining clusters and is the preferred method for managing cluster deployments in the GitOps ZTP workflow. The SiteConfig Operator, which manages the ClusterInstance custom resource (CR), is a fully developed controller shipped as an add-on within Red Hat Advanced Cluster Management (RHACM).
The SiteConfig Operator only reconciles updates for ClusterInstance objects. The controller does not monitor or manage deprecated SiteConfig objects.
The migration from SiteConfig CRs to ClusterInstance CRs provides several improvements, such as enhanced scalability and a clear separation of cluster parameters from the cluster deployment method. For more information about these improvements, and the SiteConfig Operator, see SiteConfig.
The migration process involves the following high-level steps:
- Set up the parallel pipeline by preparing a new Git folder structure in your repository and creating the corresponding Argo CD project and application.
To migrate the clusters incrementally, first remove the associated
SiteConfigCR from the old pipeline. Then, add a correspondingClusterInstanceCR to the new pipeline.NoteBy using the
prune=falsesync policy in the initial Argo CD application, the resources managed by this pipeline remain intact even after you remove the target cluster from this application. This approach ensures that the existing cluster resources remain operational during the migration process.-
Optionally, use the
siteconfig-convertertool to automatically convert existingSiteConfigCRs toClusterInstanceCRs.
-
Optionally, use the
- When you complete the cluster migration, delete the original Argo project and application and clean up any related resources.
The following sections describe how to migrate an example cluster, sno1, from using a SiteConfig CR to a ClusterInstance CR.
The following Git repository folder structure is used as a basis for this example migration:
6.2. Preparing a parallel Argo CD pipeline for ClusterInstance CRs Copy linkLink copied to clipboard!
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.yamlfileCopy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- The
ClusterInstanceCR manages thesiteconfig.open-cluster-management.ioobject instead of theSiteConfigCR.
Create a YAML file that defines the
Applicationresource:Example
clusters-v2.yamlfileCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteBy 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 main
$ mkdir site-configs-v2 $ touch site-configs-v2/.gitkeep $ git commit -s -m “Creates cluster-instance folder” $ git push origin mainCopy to Clipboard Copied! Toggle word wrap Toggle overflow The
.gitkeepfile is a placeholder to ensure that the empty folder is tracked by Git.NoteYou 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
$ oc apply -f ztp-app-project-v2.yaml $ oc apply -f clusters-v2.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
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-gitops
$ oc get appprojects -n openshift-gitopsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME AGE default 46h policy-app-project 42h ztp-app-project 18h ztp-app-project-v2 14s
NAME AGE default 46h policy-app-project 42h ztp-app-project 18h ztp-app-project-v2 14sCopy to Clipboard Copied! Toggle word wrap Toggle overflow Verify 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-gitops
$ oc get application.argo -n openshift-gitopsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME SYNC STATUS HEALTH STATUS clusters Synced Healthy clusters-v2 Synced Healthy policies Synced Healthy
NAME SYNC STATUS HEALTH STATUS clusters Synced Healthy clusters-v2 Synced Healthy policies Synced HealthyCopy to Clipboard Copied! Toggle word wrap Toggle overflow
6.3. Transitioning the active-ocp-version ClusterImageSet Copy linkLink copied to clipboard!
Optionally, the active-ocp-version ClusterImageSet is a GitOps Zero Touch Provisioning (ZTP) convention used in GitOps ZTP deployments. It provides a single, central definition of the OpenShift Container Platform release image to use when provisioning clusters. By default, this resource is synchronized to the hub cluster from the site-config/resources/ folder.
If your deployment uses an active-ocp-version ClusterImageSet CR, you must migrate it to the resources/ folder in the new directroy that contains ClusterInstance CRs. This prevents synchronization conflicts because both Argo CD applications cannot manage the same resource.
Prerequisites
-
You have completed the procedure to create the parallel Argo CD pipeline for
ClusterInstanceCRs. -
The Argo CD application points to the folder in your Git repository that will contain the new
ClusterInstanceCRs and associated cluster resouces. In this example, thesite-configs-v2/Argo CD application points to thesite-configs-v2/folder. -
Your Git repository contains an
active-ocp-version.yamlmanifest in theresources/folder.
Procedure
Copy the
resources/folder from thesite-configs/directory into the newsite-configs-v2/directory:cp -r site-configs/resources site-configs-v2/
$ cp -r site-configs/resources site-configs-v2/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Remove the reference to the
resources/folder from thesite-configs/kustomization.yamlfile. This ensures that the oldclustersArgo CD application no longer manages theactive-ocp-versionresource.Example updated
site-configs/resources/kustomization.yamlfileCopy to Clipboard Copied! Toggle word wrap Toggle overflow Add the
resources/folder to thesite-configs-v2/kustomization.yamlfile. This step transfers ownership of theClusterImageSetto the newclusters-v2application.Example updated
site-configs-v2/kustomization.yamlfileapiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: - resources/
apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: - resources/Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Commit and push the changes to the Git repository.
Verification
-
In Argo CD, verify that the
clusters-v2application is Healthy and Synced. If the
active-ocp-versionClusterImageSetresource in theclusterArgo application is out of sync, you can remove the Argo CD application label by running the following command:oc label clusterimageset active-ocp-version app.kubernetes.io/instance-
$ oc label clusterimageset active-ocp-version app.kubernetes.io/instance-Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
clusterimageset.hive.openshift.io/active-ocp-version unlabeled
clusterimageset.hive.openshift.io/active-ocp-version unlabeledCopy to Clipboard Copied! Toggle word wrap Toggle overflow
6.4. Performing the migration from SiteConfig CR to ClusterInstance CR Copy linkLink copied to clipboard!
Migrate a single-node OpenShift cluster from using a SiteConfig CR to a ClusterInstance CR by removing the SiteConfig CR from the old pipeline, and adding a corresponding ClusterInstance CR to the new pipeline.
Prerequisites
-
You have logged in to the hub cluster as a user with
cluster-adminprivileges. -
You have set up the parallel Argo CD pipeline, including the Argo CD project and application, that will manage the cluster using the
ClusterInstanceCR. -
The Argo CD application managing the original
SiteConfigCR pipeline is configured with the sync policyprune=false. This setting ensures that resources remain intact after you remove the target cluster from this application. - You have access to the Git repository that contains your single-node OpenShift cluster configurations.
- You have Red Hat Advanced Cluster Management (RHACM) version 2.12 or later installed in the hub cluster.
- The SiteConfig Operator is installed and running in the hub cluster.
- You have installed Podman and you have access to the registry.redhat.io container image registry.
Procedure
Mirror the
site-configsfolder structure to the newsite-configs-v2directory that will contain theClusterInstanceCRs, for example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Remove the target cluster from the original Argo CD application by commenting out the resources in the related files in Git:
Comment out the target cluster from the
site-configs/kustomization.yamlfile, for example:cat site-configs/kustomization.yaml
$ cat site-configs/kustomization.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example updated
site-configs/kustomization.yamlfileCopy to Clipboard Copied! Toggle word wrap Toggle overflow Comment out the target cluster from the
site-configs/pre-reqs/kustomization.yamlfile. This removes thesite-configs/pre-reqs/sno1folder, which also requires migration and has resources such as the image registry pull secret, the baseboard management controller credentials, and so on, for example:cat site-configs/pre-reqs/kustomization.yaml
$ cat site-configs/pre-reqs/kustomization.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example updated
site-configs/pre-reqs/kustomization.yamlfileCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Commit the changes to the Git repository.
NoteAfter you commit the changes, the original Argo CD application reports an
OutOfSyncsync status because the Argo CD application still attempts to monitor the status of the taget cluster’s resources. However, because the sync policy is set toprune=false, the Argo CD application does not delete any resources.To ensure that the original Argo CD application no longer manages the cluster resources, you can remove the Argo CD application label from the resources by running the following command:
for cr in bmh,hfs,clusterdeployment,agentclusterinstall,infraenv,nmstateconfig,configmap,klusterletaddonconfig,secrets; do oc label $cr app.kubernetes.io/instance- --all -n sno1; done && oc label ns sno1 app.kubernetes.io/instance- && oc label managedclusters sno1 app.kubernetes.io/instance-
$ for cr in bmh,hfs,clusterdeployment,agentclusterinstall,infraenv,nmstateconfig,configmap,klusterletaddonconfig,secrets; do oc label $cr app.kubernetes.io/instance- --all -n sno1; done && oc label ns sno1 app.kubernetes.io/instance- && oc label managedclusters sno1 app.kubernetes.io/instance-Copy to Clipboard Copied! Toggle word wrap Toggle overflow The Argo CD application label is removed from all resources in the
sno1namespace and the sync status returns toSynced.Create the
ClusterInstanceCR for the target cluster by using thesiteconfig-convertertool packaged with theztp-site-generatecontainer image:NoteThe siteconfig-converter tool cannot translate earlier versions of the
AgentClusterInstallresource that uses the following deprecated fields in theSiteConfigCR:-
apiVIP -
ingressVIP -
manifestsConfigMapRef
To solve this issue, you can do one of the following options:
- Create a custom cluster template that includes these fields. For more information about creating custom templates, see Creating custom templates with the SiteConfig operator
-
Suppress the creation of the
AgentClusterInstallresource by adding it to thesuppressedManifestslist in theClusterInstanceCR, or by using the-sflag in thesiteconfig-convertertool. You must remove the resource from thesuppressedManifestslist when reinstalling the cluster.
Pull the
ztp-site-generatecontainer image by running the following command:podman pull registry.redhat.io/openshift4/ztp-site-generate-rhel8:4.20
podman pull registry.redhat.io/openshift4/ztp-site-generate-rhel8:4.20Copy to Clipboard Copied! Toggle word wrap Toggle overflow Run the
siteconfig-convertertool interactively through the container by running the following command:podman run -v "${PWD}":/resources:Z,U -it registry.redhat.io/openshift4/ztp-site-generate-rhel8:{product-version} siteconfig-converter -d /resources/<output_folder> /resources/<path_to_siteconfig_resource>$ podman run -v "${PWD}":/resources:Z,U -it registry.redhat.io/openshift4/ztp-site-generate-rhel8:{product-version} siteconfig-converter -d /resources/<output_folder> /resources/<path_to_siteconfig_resource>Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Replace
<output_folder>with the output directory for the generated files. Replace
<path_to_siteconfig_resource>with the path to the targetSiteConfigCR file.Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThe
ClusterInstanceCR requires the extra manifests to be defined in aConfigMapresource.To meet this requirement, the
siteconfig-convertertool generates akustomization.yamlsnippet. The generated snippet uses Kustomize’sconfigMapGeneratorto automatically package your manifest files into the requiredConfigMapresource. You must merge this snippet into your originalkustomization.yamlfile to ensure that theConfigMapresource is created and managed alongside your other cluster resources.
-
Replace
-
Configure the new Argo CD application to manage the target cluster by referencing it in the new pipelines
Kustomizationfiles, for example:cat site-configs-v2/kustomization.yaml
$ cat site-configs-v2/kustomization.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example updated
site-configs-v2/kustomization.yamlfileCopy to Clipboard Copied! Toggle word wrap Toggle overflow cat site-configs-v2/pre-reqs/kustomization.yaml
$ cat site-configs-v2/pre-reqs/kustomization.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example updated
site-configs-v2/pre-reqs/kustomization.yamlfileapiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: - sno1/
apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: - sno1/Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Commit the changes to the Git repository.
Verification
Verify that the
ClusterInstanceCR is successfully deployed and the provisioning status complete by running the following command:oc get clusterinstance -A
$ oc get clusterinstance -ACopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME PAUSED PROVISIONSTATUS PROVISIONDETAILS AGE clusterinstance.siteconfig.open-cluster-management.io/sno1 Completed Provisioning completed 27s
NAME PAUSED PROVISIONSTATUS PROVISIONDETAILS AGE clusterinstance.siteconfig.open-cluster-management.io/sno1 Completed Provisioning completed 27sCopy to Clipboard Copied! Toggle word wrap Toggle overflow At this point, the new Argo CD application that uses the
ClusterInstanceCR is managing thesno1cluster. You can continue to migrate one or more clusters at a time by repeating these steps until all target clusters are migrated to the new pipeline.Verify the folder structure and files in the
site-configs-v2/directory contain the migrated resources for thesno1cluster, for example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- This
ClusterInstanceCR for thesno1cluster. - 2
- The tool automatically generates the extra manifests referenced by the
ClusterInstanceCR. After generation, the file names might change. You can rename the files to match the original naming convention in the associatedkustomization.yamlfile. - 3
- The tool generates a
kuztomization.yamlfile snippet to create theConfigMapresources that specifies the extra manifests. You can merge the generatedkustomizationsnippet with your originalkuztomization.yamlfile.
6.4.1. Reference flags for the siteconfig-converter tool Copy linkLink copied to clipboard!
The following matrix describes the flags for the siteconfig-converter tool.
| Flag | Type | Description |
|---|---|---|
| -d | string |
Define the output directory for the converted |
| -t | string |
Define a comma-separated list of template references for clusters in namespace/name format. The default value is |
| -n | string |
Define a comma-separated list of template references for nodes in namespace/name format. The default value is |
| -m | string |
Define a comma-separated list of |
| -s | string | Define a comma-separated list of manifest names to suppress at the cluster level. |
| -w | boolean |
Write conversion warnings as comments to the head of the converted YAML files. The default value is |
| -c | boolean |
Copy comments from the original |
6.5. Deleting the Argo CD pipeline post-migration Copy linkLink copied to clipboard!
After you migrate all single-node OpenShift clusters from using SiteConfig CRs to ClusterInstance CRs, you can delete the original Argo CD application and related resources that managed the SiteConfig CRs.
Only delete the Argo CD application and related resources after you have confirmed that all clusters are successfully managed by the new Argo CD application that uses ClusterInstance CRs. Additionally, if the Argo CD project was only used for the migrated cluster’s Argo application, you can also delete this project.
Prerequisites
-
You have logged in to the hub cluster as a user with
cluster-adminprivileges. -
All single-node OpenShift clusters have been successfully migrated to use
ClusterInstanceCRs and are managed by another Argo CD application.
Procedure
Delete the original Argo CD application that managed the
SiteConfigCRs:oc delete application.argo clusters -n openshift-gitops
$ oc delete application.argo clusters -n openshift-gitopsCopy to Clipboard Copied! Toggle word wrap Toggle overflow -
Replace
clusterswith the name of your original Argo CD application.
-
Replace
Delete the original Argo CD project by running the following command:
oc delete appproject ztp-app-project -n openshift-gitops
$ oc delete appproject ztp-app-project -n openshift-gitopsCopy to Clipboard Copied! Toggle word wrap Toggle overflow -
Replace
ztp-app-projectwith the name of your original Argo CD project.
-
Replace
Verification
Confirm that the original Argo CD application is deleted by running the following command:
oc get appproject -n openshift-gitops
$ oc get appproject -n openshift-gitopsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME AGE default 6d20h policy-app-project 2d22h ztpv2-app-project 44h
NAME AGE default 6d20h policy-app-project 2d22h ztpv2-app-project 44hCopy to Clipboard Copied! Toggle word wrap Toggle overflow -
The original Argo CD project in this example,
ztp-app-projectis not present in the output.
-
The original Argo CD project in this example,
Confirm that the original Argo CD project is deleted by running the following command:
oc get applications.argo -n openshift-gitops
oc get applications.argo -n openshift-gitopsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME SYNC STATUS HEALTH STATUS clusters-v2 Synced Healthy policies Synced Healthy
NAME SYNC STATUS HEALTH STATUS clusters-v2 Synced Healthy policies Synced HealthyCopy to Clipboard Copied! Toggle word wrap Toggle overflow -
The original Argo CD application in this example,
clustersis not present in the output.
-
The original Argo CD application in this example,
6.6. Troubleshooting the migration to ClusterInstance CRs Copy linkLink copied to clipboard!
Consider the following troubleshooting steps if you encounter issues during the migration from SiteConfig CRs to ClusterInstance CRs.
Procedure
Verify that the SiteConfig Operator rendered all the required deployment resources by running the following command:
oc -n <target_cluster> get clusterinstances <target_cluster> -ojson | jq .status.manifestsRendered
$ oc -n <target_cluster> get clusterinstances <target_cluster> -ojson | jq .status.manifestsRenderedCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow