Chapter 9. Advanced managed cluster configuration with SiteConfig resources
You can use SiteConfig custom resources (CRs) to deploy custom functionality and configurations in your managed clusters at installation time.
SiteConfig v1 is deprecated starting with OpenShift Container Platform version 4.18. Equivalent and improved functionality is now available through the SiteConfig Operator using the ClusterInstance custom resource. For more information, see Procedure to transition from SiteConfig CRs to the ClusterInstance API.
For more information about the SiteConfig Operator, see SiteConfig.
9.1. Customizing extra installation manifests in the GitOps ZTP pipeline Copy linkLink copied to clipboard!
You can define a set of extra manifests for inclusion in the installation phase of the GitOps Zero Touch Provisioning (ZTP) pipeline. These manifests are linked to the SiteConfig custom resources (CRs) and are applied to the cluster during installation. Including MachineConfig CRs at install time makes the installation process more efficient.
Prerequisites
- Create a Git repository where you manage your custom site configuration data. The repository must be accessible from the hub cluster and be defined as a source repository for the Argo CD application.
Procedure
- Create a set of extra manifest CRs that the GitOps ZTP pipeline uses to customize the cluster installs.
In your custom
/siteconfigdirectory, create a subdirectory/custom-manifestfor your extra manifests. The following example illustrates a sample/siteconfigwith/custom-manifestfolder:siteconfig ├── site1-sno-du.yaml ├── site2-standard-du.yaml ├── extra-manifest/ └── custom-manifest └── 01-example-machine-config.yamlNoteThe subdirectory names
/custom-manifestand/extra-manifestused throughout are example names only. There is no requirement to use these names and no restriction on how you name these subdirectories. In this example/extra-manifestrefers to the Git subdirectory that stores the contents of/extra-manifestfrom theztp-site-generatecontainer.-
Add your custom extra manifest CRs to the
siteconfig/custom-manifestdirectory. In your
SiteConfigCR, enter the directory name in theextraManifests.searchPathsfield, for example:clusters: - clusterName: "example-sno" networkType: "OVNKubernetes" extraManifests: searchPaths: - extra-manifest/ - custom-manifest/-
The
extra-manifest/folder contains the manifests copied from theztp-site-generatecontainer. -
The
custom-manifest/folder contains your custom manifests.
-
The
Save the
SiteConfig,/extra-manifest, and/custom-manifestCRs, and push them to the site configuration repo.During cluster provisioning, the GitOps ZTP pipeline appends the CRs in the
/custom-manifestdirectory to the default set of extra manifests stored inextra-manifest/.NoteAs of version 4.14
extraManifestPathis subject to a deprecation warning.While
extraManifestPathis still supported, we recommend that you useextraManifests.searchPaths. If you defineextraManifests.searchPathsin theSiteConfigfile, the GitOps ZTP pipeline does not fetch manifests from theztp-site-generatecontainer during site installation.If you define both
extraManifestPathandextraManifests.searchPathsin theSiteconfigCR, the setting defined forextraManifests.searchPathstakes precedence.It is strongly recommended that you extract the contents of
/extra-manifestfrom theztp-site-generatecontainer and push it to the Git repository.
9.2. Customizing the br-ex bridge at installation time in the GitOps ZTP pipeline Copy linkLink copied to clipboard!
By default, OpenShift Container Platform automatically configures the Open vSwitch (OVS) br-ex bridge on bare-metal nodes. For advanced networking requirements, you can override this default behavior by defining a customized br-ex bridge in an NMState configuration. When you configure the customized br-ex bridge as part of the GitOps Zero Touch Provisioning (ZTP) installation, the configuration is applied during cluster provisioning. This eliminates the need for the Day 2 migration procedure, which requires a node reboot.
To customize the br-ex bridge at installation time in the GitOps ZTP pipeline, you create a MachineConfig object that includes the customized br-ex bridge configuration, package it as a ConfigMap, and reference it in your ClusterInstance CR.
The customized br-ex bridge configuration cannot be included directly in the ClusterInstance CR. Using a MachineConfig object as an extra manifest is currently the only supported method to configure a customized br-ex bridge at installation time.
Prerequisites
- You configured a Git repository where you manage your custom site configuration data. The repository must be accessible from the hub cluster and be defined as a source repository for the Argo CD application.
-
You created a
MachineConfigobject that includes your customizedbr-exbridge NMState configuration. For detailed instructions on creating the NMState configuration andMachineConfigobject, see "Creating a manifest object that includes a customized br-ex bridge".
Procedure
-
In your
/clusterinstancedirectory, create anextra-manifestsubdirectory and save theMachineConfigobject to a file in this directory, for example,extra-manifest/10-br-ex-master.yaml. Create or update the
kustomization.yamlfile to useconfigMapGeneratorto package theMachineConfigobject into aConfigMap:apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: - site1-sno-du.yaml configMapGenerator: - name: br-ex-extra-manifest namespace: site1-sno-du files: - extra-manifest/10-br-ex-master.yaml generatorOptions: disableNameSuffixHash: true-
The
configMapGenerator.namespacevalue must match theClusterInstancenamespace. -
Setting
generatorOptions.disableNameSuffixHashtotruedisables the hash suffix so theConfigMapname is predictable.
-
The
In your
ClusterInstanceCR, reference theConfigMapin theextraManifestsRefsfield:apiVersion: siteconfig.open-cluster-management.io/v1alpha1 kind: ClusterInstance metadata: name: "site1-sno-du" namespace: "site1-sno-du" spec: clusterName: "site1-sno-du" networkType: "OVNKubernetes" extraManifestsRefs: - name: br-ex-extra-manifest # ...Commit the
ClusterInstanceCR,MachineConfigobject, andkustomization.yamlfile to your Git repository and push the changes.During cluster provisioning, the SiteConfig Operator applies the
MachineConfigobject as an extra manifest, and the customizedbr-exbridge configuration is applied to each node without requiring a reboot.
Verification
On the hub cluster, verify that the
ConfigMapthat contains theMachineConfigobject exists by running the following command:$ oc get configmap br-ex-extra-manifest -n site1-sno-duAfter the cluster installation is complete, verify that the
MachineConfigobject exists on the managed cluster by running the following command:$ oc get machineconfig 10-br-ex-master
9.3. Configuring cluster network MTU at installation time Copy linkLink copied to clipboard!
You can explicitly set the cluster network maximum transmission unit (MTU) during installation by including a Network custom resource (CR) as an extra manifest in the GitOps Zero Touch Provisioning (ZTP) pipeline.
Setting the cluster network MTU with additional headroom during deployment prevents the need for a Day 2 MTU update that requires at least two rolling reboots of all cluster nodes.
During installation, the Cluster Network Operator (CNO) automatically calculates the cluster network MTU based on the primary network interface MTU. When you enable IPsec at installation time, the calculation includes both the OVN-Kubernetes overhead of 100 bytes and the IPsec overhead. If you plan to enable IPsec or another encapsulation technology as a Day 2 operation, the calculated MTU includes only the OVN-Kubernetes overhead and might be insufficient.
By explicitly setting the cluster network MTU at installation time, you can include additional headroom for those future needs and avoid a disruptive MTU migration.
The cluster network MTU value must be lower than the machine network MTU by at least 100 bytes to account for OVN-Kubernetes overlay overhead. If you plan to enable IPsec as a Day 2 operation, allow an additional 46 bytes for IPsec headroom. For example, with a machine network MTU of 9100 bytes, set the cluster network MTU to 8900 bytes, which accounts for the following offset:
- OVN-Kubernetes overhead: 100 bytes
- IPsec headroom: 46 bytes
- Extra headroom: 54 bytes
- Total offset: 200 bytes
To avoid selecting an MTU value that a node cannot support, verify the maximum MTU (maxmtu) that the network interface accepts by running the ip -d link command.
Prerequisites
- You have configured the hub cluster to provision managed clusters by using the GitOps ZTP pipeline.
- You have a Git repository where you manage your custom site configuration data. The repository must be accessible from the hub cluster and be defined as a source repository for the Argo CD application.
Procedure
In your
SiteConfigCR, set the machine network MTU on the network interface for all nodes.The following example configures a VLAN interface with MTU
9100:apiVersion: ran.openshift.io/v1 kind: SiteConfig metadata: name: "site1-sno-du" namespace: "site1-sno-du" spec: clusters: - clusterName: "site1-sno-du" nodes: - hostName: "node1.example.com" nodeNetwork: interfaces: - name: "bond0.120" macAddress: "00:00:00:00:00:00" config: interfaces: - name: bond0.120 type: vlan state: up mtu: 9100 ipv4: enabled: true dhcp: false address: - ip: "192.168.120.15" prefix-length: 25 vlan: base-iface: bond0 id: 120 # ...Create a
NetworkCR manifest file namedset-cluster-mtu.yamlthat sets the cluster network MTU:apiVersion: operator.openshift.io/v1 kind: Network metadata: name: cluster spec: defaultNetwork: ovnKubernetesConfig: mtu: 8900where:
mtu- Specifies the cluster network MTU value. This value must be at least 100 bytes less than the machine network MTU. In this example, the value is 200 bytes less than the machine network MTU of 9100 to allow headroom for IPsec and other future requirements.
In your
siteconfigdirectory, place the manifest file in a custom extra manifests subdirectory:siteconfig/ ├── site1-sno-du.yaml ├── extra-manifest/ └── custom-manifest/ └── set-cluster-mtu.yamlIn your
SiteConfigCR, enter the directory name in theextraManifests.searchPathsfield:apiVersion: ran.openshift.io/v1 kind: SiteConfig metadata: name: "site1-sno-du" namespace: "site1-sno-du" spec: clusters: - clusterName: "site1-sno-du" networkType: "OVNKubernetes" extraManifests: searchPaths: - extra-manifest/ - custom-manifest/ # ...Commit the
SiteConfigCR and theset-cluster-mtu.yamlmanifest to your Git repository and push the changes.During cluster provisioning, the GitOps ZTP pipeline applies the
NetworkCR as an extra manifest, and the CNO uses the specified MTU value instead of auto-calculating it.
Verification
After the cluster installation is complete, verify the cluster network MTU by running the following command:
$ oc get networks.operator.openshift.io cluster -o yamlExample output
apiVersion: operator.openshift.io/v1 kind: Network metadata: name: cluster # ... spec: # ... defaultNetwork: ovnKubernetesConfig: # ... mtu: 8900
9.4. Filtering custom resources using SiteConfig filters Copy linkLink copied to clipboard!
By using filters, you can easily customize SiteConfig custom resources (CRs) to include or exclude other CRs for use in the installation phase of the GitOps Zero Touch Provisioning (ZTP) pipeline.
You can specify an inclusionDefault value of include or exclude for the SiteConfig CR, along with a list of the specific extraManifest RAN CRs that you want to include or exclude. Setting inclusionDefault to include makes the GitOps ZTP pipeline apply all the files in /source-crs/extra-manifest during installation. Setting inclusionDefault to exclude does the opposite.
You can exclude individual CRs from the /source-crs/extra-manifest folder that are otherwise included by default. The following example configures a custom single-node OpenShift SiteConfig CR to exclude the /source-crs/extra-manifest/03-sctp-machine-config-worker.yaml CR at installation time.
Some additional optional filtering scenarios are also described.
Prerequisites
- You configured the hub cluster for generating the required installation and policy CRs.
- You created a Git repository where you manage your custom site configuration data. The repository must be accessible from the hub cluster and be defined as a source repository for the Argo CD application.
Procedure
To prevent the GitOps ZTP pipeline from applying the
03-sctp-machine-config-worker.yamlCR file, apply the following YAML in theSiteConfigCR:apiVersion: ran.openshift.io/v1 kind: SiteConfig metadata: name: "site1-sno-du" namespace: "site1-sno-du" spec: baseDomain: "example.com" pullSecretRef: name: "assisted-deployment-pull-secret" clusterImageSetNameRef: "openshift-4.20" sshPublicKey: "<ssh_public_key>" clusters: - clusterName: "site1-sno-du" extraManifests: filter: exclude: - 03-sctp-machine-config-worker.yamlThe GitOps ZTP pipeline skips the
03-sctp-machine-config-worker.yamlCR during installation. All other CRs in/source-crs/extra-manifestare applied.Save the
SiteConfigCR and push the changes to the site configuration repository.The GitOps ZTP pipeline monitors and adjusts what CRs it applies based on the
SiteConfigfilter instructions.Optional: To prevent the GitOps ZTP pipeline from applying all the
/source-crs/extra-manifestCRs during cluster installation, apply the following YAML in theSiteConfigCR:- clusterName: "site1-sno-du" extraManifests: filter: inclusionDefault: excludeOptional: To exclude all the
/source-crs/extra-manifestRAN CRs and instead include a custom CR file during installation, edit the customSiteConfigCR to set the custom manifests folder and theincludefile, for example:clusters: - clusterName: "site1-sno-du" extraManifestPath: "<custom_manifest_folder>"1 extraManifests: filter: inclusionDefault: exclude2 include: - custom-sctp-machine-config-worker.yamlThe following example illustrates the custom folder structure:
siteconfig ├── site1-sno-du.yaml └── user-custom-manifest └── custom-sctp-machine-config-worker.yaml
9.5. Deleting a node by using the SiteConfig CR Copy linkLink copied to clipboard!
By using a SiteConfig custom resource (CR), you can delete and reprovision a node. This method is more efficient than manually deleting the node.
Prerequisites
- You have configured the hub cluster to generate the required installation and policy CRs.
- You have created a Git repository in which you can manage your custom site configuration data. The repository must be accessible from the hub cluster and be defined as the source repository for the Argo CD application.
Procedure
Update the
SiteConfigCR to include thebmac.agent-install.openshift.io/remove-agent-and-node-on-delete=trueannotation and push the changes to the Git repository:apiVersion: ran.openshift.io/v1 kind: SiteConfig metadata: name: "cnfdf20" namespace: "cnfdf20" spec: clusters: nodes: - hostname: node6 role: "worker" crAnnotations: add: BareMetalHost: bmac.agent-install.openshift.io/remove-agent-and-node-on-delete: true # ...Verify that the
BareMetalHostobject is annotated by running the following command:oc get bmh -n <managed-cluster-namespace> <bmh-object> -ojsonpath='{.metadata}' | jq -r '.annotations["bmac.agent-install.openshift.io/remove-agent-and-node-on-delete"]'Example output
trueSuppress the generation of the
BareMetalHostCR by updating theSiteConfigCR to include thecrSuppression.BareMetalHostannotation:apiVersion: ran.openshift.io/v1 kind: SiteConfig metadata: name: "cnfdf20" namespace: "cnfdf20" spec: clusters: - nodes: - hostName: node6 role: "worker" crSuppression: - BareMetalHost # ...-
Push the changes to the Git repository and wait for deprovisioning to start. The status of the
BareMetalHostCR should change todeprovisioning. Wait for theBareMetalHostto finish deprovisioning, and be fully deleted.
Verification
Verify that the
BareMetalHostandAgentCRs for the worker node have been deleted from the hub cluster by running the following commands:$ oc get bmh -n <cluster-ns>$ oc get agent -n <cluster-ns>Verify that the node record has been deleted from the spoke cluster by running the following command:
$ oc get nodesNoteIf you are working with secrets, deleting a secret too early can cause an issue because ArgoCD needs the secret to complete resynchronization after deletion. Delete the secret only after the node cleanup, when the current ArgoCD synchronization is complete.
Next steps
To reprovision a node, delete the changes previously added to the SiteConfig, push the changes to the Git repository, and wait for the synchronization to complete. This regenerates the BareMetalHost CR of the worker node and triggers the re-install of the node.