Este contenido no está disponible en el idioma seleccionado.
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
SiteConfig
CR is deprecated from OpenShift Container Platform version 4.18 and will be removed in a future version. -
The
ClusterInstance
CR 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 Copiar enlaceEnlace copiado en el portapapeles!
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
SiteConfig
CR from the old pipeline. Then, add a correspondingClusterInstance
CR to the new pipeline.NoteBy using the
prune=false
sync 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-converter
tool to automatically convert existingSiteConfig
CRs toClusterInstance
CRs.
-
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 Copiar enlaceEnlace copiado en el portapapeles!
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-admin
privileges. - 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
AppProject
resource:Example
ztp-app-project-v2.yaml
fileCopy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- The
ClusterInstance
CR manages thesiteconfig.open-cluster-management.io
object instead of theSiteConfig
CR.
Create a YAML file that defines the
Application
resource:Example
clusters-v2.yaml
fileCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteBy default,
auto-sync
is 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
ClusterInstance
CRs 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 main
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The
.gitkeep
file 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
AppProject
andApplication
resources 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.yaml
Copy 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-v2
are present on the hub cluster by running the following command:oc get appprojects -n openshift-gitops
$ oc get appprojects -n openshift-gitops
Copy 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 14s
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that the original Argo CD application,
clusters
, and the new Argo CD application,clusters-v2
are present on the hub cluster by running the following command:oc get application.argo -n openshift-gitops
$ oc get application.argo -n openshift-gitops
Copy 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 Healthy
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
6.3. Transitioning the active-ocp-version ClusterImageSet Copiar enlaceEnlace copiado en el portapapeles!
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
ClusterInstance
CRs. -
The Argo CD application points to the folder in your Git repository that will contain the new
ClusterInstance
CRs 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.yaml
manifest 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.yaml
file. This ensures that the oldclusters
Argo CD application no longer manages theactive-ocp-version
resource.Example updated
site-configs/resources/kustomization.yaml
fileCopy to Clipboard Copied! Toggle word wrap Toggle overflow Add the
resources/
folder to thesite-configs-v2/kustomization.yaml
file. This step transfers ownership of theClusterImageSet
to the newclusters-v2
application.Example updated
site-configs-v2/kustomization.yaml
fileapiVersion: 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-v2
application is Healthy and Synced. If the
active-ocp-version
ClusterImageSet
resource in thecluster
Argo 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 unlabeled
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
6.4. Performing the migration from SiteConfig CR to ClusterInstance CR Copiar enlaceEnlace copiado en el portapapeles!
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-admin
privileges. -
You have set up the parallel Argo CD pipeline, including the Argo CD project and application, that will manage the cluster using the
ClusterInstance
CR. -
The Argo CD application managing the original
SiteConfig
CR 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-configs
folder structure to the newsite-configs-v2
directory that will contain theClusterInstance
CRs, 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.yaml
file, for example:cat site-configs/kustomization.yaml
$ cat site-configs/kustomization.yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example updated
site-configs/kustomization.yaml
fileCopy to Clipboard Copied! Toggle word wrap Toggle overflow Comment out the target cluster from the
site-configs/pre-reqs/kustomization.yaml
file. This removes thesite-configs/pre-reqs/sno1
folder, 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.yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example updated
site-configs/pre-reqs/kustomization.yaml
fileCopy 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
OutOfSync
sync 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
sno1
namespace and the sync status returns toSynced
.Create the
ClusterInstance
CR for the target cluster by using thesiteconfig-converter
tool packaged with theztp-site-generate
container image:NoteThe siteconfig-converter tool cannot translate earlier versions of the
AgentClusterInstall
resource that uses the following deprecated fields in theSiteConfig
CR:-
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
AgentClusterInstall
resource by adding it to thesuppressedManifests
list in theClusterInstance
CR, or by using the-s
flag in thesiteconfig-converter
tool. You must remove the resource from thesuppressedManifests
list when reinstalling the cluster.
Pull the
ztp-site-generate
container 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.20
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Run the
siteconfig-converter
tool 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 targetSiteConfig
CR file.Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThe
ClusterInstance
CR requires the extra manifests to be defined in aConfigMap
resource.To meet this requirement, the
siteconfig-converter
tool generates akustomization.yaml
snippet. The generated snippet uses Kustomize’sconfigMapGenerator
to automatically package your manifest files into the requiredConfigMap
resource. You must merge this snippet into your originalkustomization.yaml
file to ensure that theConfigMap
resource 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
Kustomization
files, for example:cat site-configs-v2/kustomization.yaml
$ cat site-configs-v2/kustomization.yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example updated
site-configs-v2/kustomization.yaml
fileCopy to Clipboard Copied! Toggle word wrap Toggle overflow cat site-configs-v2/pre-reqs/kustomization.yaml
$ cat site-configs-v2/pre-reqs/kustomization.yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example updated
site-configs-v2/pre-reqs/kustomization.yaml
fileapiVersion: 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
ClusterInstance
CR is successfully deployed and the provisioning status complete by running the following command:oc get clusterinstance -A
$ oc get clusterinstance -A
Copy 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 27s
Copy to Clipboard Copied! Toggle word wrap Toggle overflow At this point, the new Argo CD application that uses the
ClusterInstance
CR is managing thesno1
cluster. 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 thesno1
cluster, for example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- This
ClusterInstance
CR for thesno1
cluster. - 2
- The tool automatically generates the extra manifests referenced by the
ClusterInstance
CR. After generation, the file names might change. You can rename the files to match the original naming convention in the associatedkustomization.yaml
file. - 3
- The tool generates a
kuztomization.yaml
file snippet to create theConfigMap
resources that specifies the extra manifests. You can merge the generatedkustomization
snippet with your originalkuztomization.yaml
file.
6.4.1. Reference flags for the siteconfig-converter tool Copiar enlaceEnlace copiado en el portapapeles!
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 Copiar enlaceEnlace copiado en el portapapeles!
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-admin
privileges. -
All single-node OpenShift clusters have been successfully migrated to use
ClusterInstance
CRs and are managed by another Argo CD application.
Procedure
Delete the original Argo CD application that managed the
SiteConfig
CRs:oc delete application.argo clusters -n openshift-gitops
$ oc delete application.argo clusters -n openshift-gitops
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Replace
clusters
with 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-gitops
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Replace
ztp-app-project
with 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-gitops
Copy 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 44h
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
The original Argo CD project in this example,
ztp-app-project
is 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-gitops
Copy 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 Healthy
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
The original Argo CD application in this example,
clusters
is not present in the output.
-
The original Argo CD application in this example,
6.6. Troubleshooting the migration to ClusterInstance CRs Copiar enlaceEnlace copiado en el portapapeles!
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.manifestsRendered
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow