From 78ef28a5522a5db232c167d3792294ad57f64c99 Mon Sep 17 00:00:00 2001 From: Shane Lovern Date: Fri, 17 Nov 2023 15:39:40 +0000 Subject: [PATCH] TELCODOCS-1476 hub-side templating --- modules/ztp-deploying-a-site.adoc | 28 +++++++++++++ modules/ztp-the-policygentemplate.adoc | 12 ++++++ ...configuring-managed-clusters-policies.adoc | 1 + .../ztp-deploying-far-edge-sites.adoc | 2 + .../ztp_example-pgt-hub-side-templating.yaml | 39 +++++++++++++++++++ 5 files changed, 82 insertions(+) create mode 100644 snippets/ztp_example-pgt-hub-side-templating.yaml diff --git a/modules/ztp-deploying-a-site.adoc b/modules/ztp-deploying-a-site.adoc index 4d384db9b530..98953603e6e9 100644 --- a/modules/ztp-deploying-a-site.adoc +++ b/modules/ztp-deploying-a-site.adoc @@ -91,6 +91,34 @@ The `enable-crun-master.yaml` and `enable-crun-worker.yaml` CR files are in the For more information, see "Customizing extra installation manifests in the {ztp} pipeline". ==== +.. Optional: To reduce the number of policies for a deployment, you can use hub-side templates with a `PolicyGenTemplate`. +You can use the `spec.clusters.siteConfigMap` section of the `SiteConfig` custom resource (CR) to specify per-site data to be used for hub-side templating. +The following is an example use of the `data` field in `SiteConfig`: ++ +[source,yaml] +---- +siteConfigMap: + name: site-example-sno <1> + namespace: ztp-pgs <2> + data: + sno-1-sriov-network-vlan-1: "140" + sno-1-sriov-network-vlan-2: "150" + updateConfigMapWithThisValue: "3" +---- +<1> Specifies the name of the `ConfigMap` to be created. If unspecified, the default name is `ztp-site-`. +<2> The default namesapce is `ztp-site`. For a successful integration with the `PolicyGenTemplate`, the `siteConfigMap.namespace` you specify must be the same as the namespace used by the `PolicyGenTemplate` resources. ++ +[IMPORTANT] +==== +The `spec.clusters.siteConfigMap` section is available for `SiteConfig` CRs with `apiVersion: ran.openshift.io/v2` only. +Earlier versions do not support this function. +==== ++ +[NOTE] +==== +As an alternative to populating the `siteConfigMap` section in the `SiteConfig` CR, you can store site-specific template data in the {ztp} repo, as `ConfigMap` CRs, and have them synced to the hub cluster. +==== + . Add the `SiteConfig` CR to the `kustomization.yaml` file in the `generators` section, similar to the example shown in `out/argocd/example/siteconfig/kustomization.yaml`. . Commit the `SiteConfig` CR and associated `kustomization.yaml` changes in your Git repository and push the changes. diff --git a/modules/ztp-the-policygentemplate.adoc b/modules/ztp-the-policygentemplate.adoc index d16c4838849b..0565b457cbd0 100644 --- a/modules/ztp-the-policygentemplate.adoc +++ b/modules/ztp-the-policygentemplate.adoc @@ -168,3 +168,15 @@ spec: domainNumber 24 ..... ---- + +The following example uses hub-side templating to generate `PerformanceProfile` {rh-rhacm} policies for clusters that match the labels defined under `spec.bindingRules`. +[source,yaml] +---- +include::snippets/ztp_example-pgt-hub-side-templating.yaml[] +---- + +Using the `fromConfigMap` function, {rh-rhacm} selects the site-specific configuration for each cluster defined in the `PolicyGenTemplate`. +This example generates policies for clusters that have the labels: + +* 'group-du-sno-zone: "zone-1"' +* 'hardware-type: "dell-poweredge-xr12"' \ No newline at end of file diff --git a/scalability_and_performance/ztp_far_edge/ztp-configuring-managed-clusters-policies.adoc b/scalability_and_performance/ztp_far_edge/ztp-configuring-managed-clusters-policies.adoc index 551629a8a0f5..13c46d57e40d 100644 --- a/scalability_and_performance/ztp_far_edge/ztp-configuring-managed-clusters-policies.adoc +++ b/scalability_and_performance/ztp_far_edge/ztp-configuring-managed-clusters-policies.adoc @@ -16,6 +16,7 @@ include::modules/ztp-pgt-config-best-practices.adoc[leveloffset=+1] .Additional resources * For recommendations about scaling clusters with {rh-rhacm}, see link:https://access.redhat.com/documentation/en-us/red_hat_advanced_cluster_management_for_kubernetes/2.6/html/install/installing#performance-and-scalability[Performance and scalability]. +* For information on working with templates, see link:https://access.redhat.com/documentation/en-us/red_hat_advanced_cluster_management_for_kubernetes/2.8/html-single/governance/index#template-processing[Template processing]. [NOTE] ==== diff --git a/scalability_and_performance/ztp_far_edge/ztp-deploying-far-edge-sites.adoc b/scalability_and_performance/ztp_far_edge/ztp-deploying-far-edge-sites.adoc index 8d9a5de3c13a..e7217ce69050 100644 --- a/scalability_and_performance/ztp_far_edge/ztp-deploying-far-edge-sites.adoc +++ b/scalability_and_performance/ztp_far_edge/ztp-deploying-far-edge-sites.adoc @@ -27,6 +27,8 @@ include::modules/ztp-deploying-a-site.adoc[leveloffset=+1] .Additional resources * xref:../../scalability_and_performance/ztp_far_edge/ztp-deploying-far-edge-sites.adoc#ztp-sno-siteconfig-config-reference_ztp-deploying-far-edge-sites[{sno-caps} SiteConfig CR installation reference] +* For information on working with templates, see xref:../../scalability_and_performance/ztp_far_edge/ztp-advanced-policy-config.html#ztp-using-hub-cluster-templates_ztp-advanced-policy-config[Using hub templates in PolicyGenTemplate CRs]. +* For information on the `fromConfigmap` function, see link:https://access.redhat.com/documentation/en-us/red_hat_advanced_cluster_management_for_kubernetes/2.8/html-single/governance/index#fromConfigMap-func[fromConfigmap function]. include::modules/ztp-sno-siteconfig-config-reference.adoc[leveloffset=+2] diff --git a/snippets/ztp_example-pgt-hub-side-templating.yaml b/snippets/ztp_example-pgt-hub-side-templating.yaml new file mode 100644 index 000000000000..b270aa7fa202 --- /dev/null +++ b/snippets/ztp_example-pgt-hub-side-templating.yaml @@ -0,0 +1,39 @@ +# For this PGT, we've considered an SNO managed cluster with the following labels: +# group-du-sno-zone: zone-1 +# hardware-type: dell-poweredge-xr12 +--- +apiVersion: ran.openshift.io/v1 +kind: PolicyGenTemplate +metadata: + # The name will be used to generate the placementBinding and placementRule names as {name}-placementBinding and {name}-placementRule + name: "group-du-sno-zone-1" + namespace: "ztp-du-sno" +spec: + bindingRules: + # These policies will correspond to all clusters with these labels + group-du-sno-zone: "zone-1" + hardware-type: "dell-poweredge-xr12" + mcp: "master" + sourceFiles: + # config-policy + ### + - fileName: PerformanceProfile.yaml # wave 10 + policyName: "config-policy" + metadata: + name: openshift-node-performance-profile + spec: + additionalKernelArgs: + - rcupdate.rcu_normal_after_boot=0 + - vfio_pci.enable_sriov=1 + - vfio_pci.disable_idle_d3=1 + - efi=runtime + cpu: + isolated: '{{hub fromConfigMap "" (printf "site-%s-configmap" .ManagedClusterName) (printf "%s-cpu-isolated" (index .ManagedClusterLabels "hardware-type")) hub}}' + reserved: '{{hub fromConfigMap "" (printf "site-%s-configmap" .ManagedClusterName) (printf "%s-cpu-reserved" (index .ManagedClusterLabels "hardware-type")) hub}}' + hugepages: + defaultHugepagesSize: '{{hub fromConfigMap "" (printf "site-%s-configmap" .ManagedClusterName) (printf "%s-hugepages-default" (index .ManagedClusterLabels "hardware-type")) hub}}' + pages: + - size: '{{hub fromConfigMap "" (printf "site-%s-configmap" .ManagedClusterName) (printf "%s-hugepages-size" (index .ManagedClusterLabels "hardware-type")) hub}}' + count: '{{hub fromConfigMap "" (printf "site-%s-configmap" .ManagedClusterName) (printf "%s-hugepages-count" (index .ManagedClusterLabels "hardware-type")) | toInt hub}}' + realTimeKernel: + enabled: true \ No newline at end of file