6.5. Performing advanced reference configuration customization
For scenarios where you want to allow temporary deviations from the reference design, you can apply more advanced customizations.
These customizations override the default matching process that the cluster-compare plugin uses during a comparison. Use caution when applying these advanced customizations as it can lead to unintended consequences, such as excluding consequential information from a cluster comparison.
Some advanced tasks to dynamically customize your reference configuration include the following:
- Manual matching: Configure a user configuration file to manually match a custom resource from the cluster to a template in the reference configuration.
-
Patching the reference: Patch a reference to configure a reference configuration by using a patch option with the
cluster-comparecommand.
6.5.1. Configuring manual matching between CRs and templates 링크 복사링크가 클립보드에 복사되었습니다!
In some cases, the cluster-compare plugin’s default matching might not work as expected. You can manually define how a custom resource (CR) maps to a template by using a user configuration file.
By default, the plugin maps a CR to a template based on the apiversion, kind, name, and namespace fields. However, multiple templates might match a single CR. For example, this can occur in the following scenarios:
-
Multiple templates exist with the same
apiversion,kind,name, andnamespacefields. -
Templates match any CR with a specific
apiversionandkind, regardless of itsnamespaceorname.
When a CR matches multiple templates, the plugin uses a tie-breaking mechanism that selects the template with the fewest differences. To explicitly control which template the plugin chooses, you can create a user configuration YAML file that defines manual matching rules. You can pass this configuration file to the cluster-compare command to enforce the required template selection.
Procedure
Create a user configuration file to define the manual matching criteria:
Example
user-config.yamlfilecorrelationSettings:1 manualCorrelation:2 correlationPairs:3 ptp.openshift.io/v1_PtpConfig_openshift-ptp_grandmaster: optional/ptp-config/PtpOperatorConfig.yaml4 ptp.openshift.io/v1_PtpOperatorConfig_openshift-ptp_default: optional/ptp-config/PtpOperatorConfig.yaml- 1
- The
correlationSettingssection contains the manual correlation settings. - 2
- The
manualCorrelationsection specifies that manual correlation is enabled. - 3
- The
correlationPairssection lists the CR and template pairs to manually match. - 4
- Specifies the CR and template pair to match. The CR specification uses the following format:
<apiversion>_<kind>_<namespace>_<name>. For cluster-scoped CRs that do not have a namespace, use the following format:<apiversion>_<kind>_<name>. The path to the template must be relative to themetadata.yamlfile.
Reference the user configuration file in a
cluster-comparecommand by running the following command:$ oc cluster-compare -r <path_to_reference_config>/metadata.yaml -c <path_to_user_config>/user-config.yaml1 - 1
- Specify the
user-config.yamlfile by using the-coption.