Preparing the GitOps ZTP site configuration repository for version independence
You can use GitOps ZTP to manage source custom resources (CRs) for managed clusters that are running different versions of OpenShift Container Platform. This means that the version of OpenShift Container Platform running on the hub cluster can be independent of the version running on the managed clusters.
|
|
The following procedure assumes you are using |
-
You have installed the OpenShift CLI (
oc). -
You have logged in as a user with
cluster-adminprivileges.
-
Create a directory structure with separate paths for the
ClusterInstanceandPolicyGeneratorCRs. -
Within the
PolicyGeneratordirectory, create a directory for each OpenShift Container Platform version you want to make available. For each version, create the following resources:-
kustomization.yamlfile that explicitly includes the files in that directory -
source-crsdirectory to contain reference CR configuration files from theztp-site-generatecontainerIf you want to work with user-provided CRs, you must create a separate directory for them.
-
-
In the
/clusterinstancedirectory, create a subdirectory for each OpenShift Container Platform version you want to make available. For each version, create at least one directory for reference CRs to be copied from the container. There is no restriction on the naming of directories or on the number of reference directories. If you want to work with custom manifests, you must create a separate directory for them.The following example describes a structure using user-provided manifests and CRs for different versions of OpenShift Container Platform:
├── acmpolicygenerator │ ├── kustomization.yaml │ ├── version_4.13 │ │ ├── common-ranGen.yaml │ │ ├── group-du-sno-ranGen.yaml │ │ ├── group-du-sno-validator-ranGen.yaml │ │ ├── helix56-v413.yaml │ │ ├── kustomization.yaml │ │ ├── ns.yaml │ │ └── source-crs/ │ │ └── reference-crs/ │ │ └── custom-crs/ │ └── version_4.14 │ ├── common-ranGen.yaml │ ├── group-du-sno-ranGen.yaml │ ├── group-du-sno-validator-ranGen.yaml │ ├── helix56-v414.yaml │ ├── kustomization.yaml │ ├── ns.yaml │ └── source-crs/ │ └── reference-crs/ │ └── custom-crs/ └── clusterinstance ├── kustomization.yaml ├── version_4.13 │ ├── helix56-v413.yaml │ ├── kustomization.yaml │ ├── extra-manifest/ │ └── custom-manifest/ └── version_4.14 ├── helix57-v414.yaml ├── kustomization.yaml ├── extra-manifest/ └── custom-manifest/where:
kustomization.yaml(top-level)-
Create a top-level
kustomizationYAML file. version_4.13,version_4.14-
Create the version-specific directories within the custom
/acmpolicygeneratordirectory. kustomization.yaml(per-version)-
Create a
kustomization.yamlfile for each version. source-crs/-
Create a
source-crsdirectory for each version to contain reference CRs from theztp-site-generatecontainer. reference-crs/-
Create the
reference-crsdirectory for policy CRs that are extracted from the ZTP container. custom-crs/-
Optional: Create a
custom-crsdirectory for user-provided CRs. extra-manifest/-
Create a directory within the custom
/clusterinstancedirectory to contain extra manifests from theztp-site-generatecontainer. custom-manifest/-
Create a folder to hold user-provided manifests.
In the example directory structure, each version subdirectory in the custom
/clusterinstancedirectory contains two further subdirectories, one containing the reference manifests copied from the container, the other for custom manifests that you provide. The names assigned to those directories are examples. -
Create ConfigMaps from the manifest directories and reference them in the
ClusterInstanceCR using theextraManifestsRefsfield.Example
kustomization.yamlwithconfigMapGenerator:apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization configMapGenerator: - name: extra-manifests-cm namespace: helix56-v413 files: - extra-manifest/workload-partitioning.yaml - extra-manifest/enable-crun-master.yaml - custom-manifest/custom-config.yaml # ... generatorOptions: disableNameSuffixHash: truewhere:
extra-manifest/-
Extra manifest files from the
ztp-site-generatecontainer. custom-manifest/-
User-provided custom manifest files.
-
Edit the
ClusterInstanceCR to reference theConfigMapCR:Example
ClusterInstanceCR:apiVersion: siteconfig.open-cluster-management.io/v1alpha1 kind: ClusterInstance metadata: name: helix56-v413 namespace: helix56-v413 spec: # ... extraManifestsRefs: - name: extra-manifests-cmThe
extra-manifests-cmvalue references theConfigMapcontaining the extra manifests. -
Edit the top-level
kustomization.yamlfile to control which OpenShift Container Platform versions are active. The following is an example of akustomization.yamlfile at the top level:resources: - version_4.13 #- version_4.14where:
version_4.13-
Activate version 4.13.
#- version_4.14-
Use comments to deactivate a version.