6.4. Performing the migration from SiteConfig CR to ClusterInstance CR
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:site-configs-v2/ ├── hub-1/1 │ └── extra-manifest/ ├── pre-reqs/ │ └── sno1/2 ├── reference-manifest/ │ └── 4.21/ └── resources/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.yamlExample updated
site-configs/kustomization.yamlfileapiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: - pre-reqs/ #- resources/ generators: #- hub-1/sno1.yaml - hub-1/sno2.yaml - hub-1/sno3.yamlComment 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.yamlExample updated
site-configs/pre-reqs/kustomization.yamlfileapiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: #- sno1/ - sno2/ - sno3/
Commit the changes to the Git repository.
注意After 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-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:注意The 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.21Run 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>-
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
Successfully read SiteConfig: sno1/sno1 Converted cluster 1 (sno1) to ClusterInstance: /resources/output/sno1.yaml WARNING: Added default extraManifest ConfigMap 'extra-manifests-cm' to extraManifestsRefs. This configmap is created automatically. Successfully converted 1 cluster(s) to ClusterInstance files in /resources/output: sno1.yaml Generating ConfigMap kustomization files... Using ConfigMap name: extra-manifests-cm, namespace: sno1, manifests directory: extra-manifests Generating ConfigMap kustomization files with name: extra-manifests-cm, namespace: sno1, manifests directory: extra-manifests Generating extraManifests for SiteConfig: /resources/sno1.yaml Successfully generated extra manifests in /resources/output/extra-manifests --- Kustomization.yaml Generator --- Scanning directory: /resources/output/extra-manifests Found and adding: extra-manifests/enable-crun-master.yaml Found and adding: extra-manifests/enable-crun-worker.yaml ------------------------------------ kustomization-configMapGenerator-snippet.yaml generated successfully at: /resources/output/kustomization-configMapGenerator-snippet.yaml Content: apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization configMapGenerator: - files: - extra-manifests/enable-crun-master.yaml - extra-manifests/enable-crun-worker.yaml name: extra-manifests-cm namespace: sno1 generatorOptions: disableNameSuffixHash: true ------------------------------------注意The
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.yamlExample updated
site-configs-v2/kustomization.yamlfileapiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: - resources/ - pre-reqs/ - hub-1/sno1.yaml$ cat site-configs-v2/pre-reqs/kustomization.yamlExample updated
site-configs-v2/pre-reqs/kustomization.yamlfileapiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: - sno1/- 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 -AExample output
NAME PAUSED PROVISIONSTATUS PROVISIONDETAILS AGE clusterinstance.siteconfig.open-cluster-management.io/sno1 Completed Provisioning completed 27sAt 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:site-configs-v2/ ├── hub-1/ │ ├── sno1.yaml1 ├── extra-manifest/ │ ├── enable-crun-worker.yaml2 │ └── enable-crun-master.yaml ├── kustomization.yaml3 ├── pre-reqs/ │ └── sno1/ │ ├── bmc-credentials.yaml │ ├── namespace.yaml │ └── pull-secret.yaml ├── kustomization.yaml ├── reference-manifest/ │ └── 4.21/ └── resources/ ├── active-ocp-version.yaml └── kustomization.yaml- 1
- This
ClusterInstanceCR for thesno1cluster. - 2
- The tool automatically generates the extra manifests referenced by the
ClusterInstanceCR. - 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 复制链接链接已复制到粘贴板!
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 |