Skip to content

Commit 5e45f49

Browse files
authored
Merge pull request #69159 from slovern/TELCODOCS-1476-4.15
TELCODOCS-1476 Hub-side templating
2 parents ac75a22 + c75d88f commit 5e45f49

File tree

3 files changed

+138
-124
lines changed

3 files changed

+138
-124
lines changed

modules/ztp-managing-sriov-vlan-with-hub-cluster-templates-in-pgt.adoc

Lines changed: 0 additions & 74 deletions
This file was deleted.

modules/ztp-specifying-nics-in-pgt-crs-with-hub-cluster-templates.adoc

Lines changed: 138 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@
44

55
:_mod-docs-content-type: PROCEDURE
66
[id="ztp-specifying-nics-in-pgt-crs-with-hub-cluster-templates_{context}"]
7-
= Specifying host NICs in site PolicyGenTemplate CRs with hub cluster templates
7+
= Specifying group and site configuration in group PolicyGenTemplate CRs with hub templates
88

9-
You can manage host NICs in a single `ConfigMap` CR and use hub cluster templates to populate the custom NIC values in the generated polices that get applied to the cluster hosts.
10-
Using hub cluster templates in site `PolicyGenTemplate` (PGT) CRs means that you do not need to create multiple single site PGT CRs for each site.
9+
You can manage the configuration of fleets of clusters with `ConfigMap` CRs by using hub templates to populate the group and site values in the generated policies that get applied to the managed clusters.
10+
Using hub templates in site `PolicyGenTemplate` (PGT) CRs means that you do not need to create a `PolicyGenTemplate` CR for each site.
1111

12-
The following example shows you how to use a single `ConfigMap` CR to manage cluster host NICs and apply them to the cluster as polices by using a single `PolicyGenTemplate` site CR.
12+
You can group the clusters in a fleet in various categories, depending on the use case, for example hardware type or region.
13+
Each cluster should have a label corresponding to the group or groups that the cluster is in.
14+
If you manage the configuration values for each group in different `ConfigMap` CRs, then you require only one group `PolicyGenTemplate` CR to apply the changes to all the clusters in the group by using hub templates.
15+
16+
The following example shows you how to use three `ConfigMap` CRs and one group `PolicyGenTemplate` CR to apply both site and group configuration to clusters grouped by hardware type and region.
1317

1418
[NOTE]
1519
====
@@ -27,96 +31,182 @@ The repository must be accessible from the hub cluster and be defined as a sourc
2731
2832
.Procedure
2933

30-
. Create a `ConfigMap` resource that describes the NICs for a group of hosts. For example:
34+
. Create three `ConfigMap` CRs that contain the group and site configuration:
35+
+
36+
--
37+
.. Create a `ConfigMap` CR named `group-hardware-types-configmap` to hold the hardware-specific configuration. For example:
3138
+
3239
[source,yaml]
3340
----
3441
apiVersion: v1
3542
kind: ConfigMap
3643
metadata:
37-
name: sriovdata
38-
namespace: ztp-site
44+
name: group-hardware-types-configmap
45+
namespace: ztp-group
3946
annotations:
4047
argocd.argoproj.io/sync-options: Replace=true <1>
4148
data:
42-
example-sno-du_fh-numVfs: "8"
43-
example-sno-du_fh-pf: ens1f0
44-
example-sno-du_fh-priority: "10"
45-
example-sno-du_fh-vlan: "140"
46-
example-sno-du_mh-numVfs: "8"
47-
example-sno-du_mh-pf: ens3f0
48-
example-sno-du_mh-priority: "10"
49-
example-sno-du_mh-vlan: "150"
49+
# SriovNetworkNodePolicy.yaml
50+
hardware-type-1-sriov-node-policy-pfNames-1: "[\"ens5f0\"]"
51+
hardware-type-1-sriov-node-policy-pfNames-2: "[\"ens7f0\"]"
52+
# PerformanceProfile.yaml
53+
hardware-type-1-cpu-isolated: "2-31,34-63"
54+
hardware-type-1-cpu-reserved: "0-1,32-33"
55+
hardware-type-1-hugepages-default: "1G"
56+
hardware-type-1-hugepages-size: "1G"
57+
hardware-type-1-hugepages-count: "32"
5058
----
5159
<1> The `argocd.argoproj.io/sync-options` annotation is required only if the `ConfigMap` is larger than 1 MiB in size.
60+
61+
.. Create a `ConfigMap` CR named `group-zones-configmap` to hold the regional configuration. For example:
62+
+
63+
[source,yaml]
64+
----
65+
apiVersion: v1
66+
kind: ConfigMap
67+
metadata:
68+
name: group-zones-configmap
69+
namespace: ztp-group
70+
data:
71+
# ClusterLogForwarder.yaml
72+
zone-1-cluster-log-fwd-outputs: "[{\"type\":\"kafka\", \"name\":\"kafka-open\", \"url\":\"tcp://10.46.55.190:9092/test\"}]"
73+
zone-1-cluster-log-fwd-pipelines: "[{\"inputRefs\":[\"audit\", \"infrastructure\"], \"labels\": {\"label1\": \"test1\", \"label2\": \"test2\", \"label3\": \"test3\", \"label4\": \"test4\"}, \"name\": \"all-to-default\", \"outputRefs\": [\"kafka-open\"]}]"
74+
----
75+
76+
.. Create a `ConfigMap` CR named `site-data-configmap` to hold the site-specific configuration. For example:
77+
+
78+
[source,yaml]
79+
----
80+
apiVersion: v1
81+
kind: ConfigMap
82+
metadata:
83+
name: site-data-configmap
84+
namespace: ztp-group
85+
data:
86+
# SriovNetwork.yaml
87+
du-sno-1-zone-1-sriov-network-vlan-1: "140"
88+
du-sno-1-zone-1-sriov-network-vlan-2: "150"
89+
----
90+
--
5291
+
5392
[NOTE]
5493
====
55-
The `ConfigMap` must be in the same namespace with the policy that has the hub template substitution.
94+
Each `ConfigMap` CR must be in the same namespace as the policy to be generated from the group `PolicyGenTemplate` CR.
5695
====
5796

58-
. Commit the `ConfigMap` CR in Git, and then push to the Git repository being monitored by the Argo CD application.
97+
. Commit the `ConfigMap` CRs in Git, and then push to the Git repository being monitored by the Argo CD application.
5998

60-
. Create a site PGT CR that uses templates to pull the required data from the `ConfigMap` object. For example:
99+
. Apply the hardware type and region labels to the clusters.
100+
The following command applies to a single cluster named `du-sno-1-zone-1` and the labels chosen are `"hardware-type": "hardware-type-1"` and `"group-du-sno-zone": "zone-1"`:
101+
+
102+
[source,terminal]
103+
----
104+
$ oc patch managedclusters.cluster.open-cluster-management.io/du-sno-1-zone-1 --type merge -p '{"metadata":{"labels":{"hardware-type": "hardware-type-1", "group-du-sno-zone": "zone-1"}}}'
105+
----
106+
107+
. Create a group `PolicyGenTemplate` CR that uses hub templates to obtain the required data from the `ConfigMap` objects.
108+
This example `PolicyGenTemplate` CR configures logging, VLAN IDs, NICs and Performance Profile for the clusters that match the labels listed under `spec.bindingRules`:
61109
+
62110
[source,yaml]
63111
----
64112
apiVersion: ran.openshift.io/v1
65113
kind: PolicyGenTemplate
66114
metadata:
67-
name: "site"
68-
namespace: "ztp-site"
115+
name: group-du-sno-pgt
116+
namespace: ztp-group
69117
spec:
70-
remediationAction: inform
71118
bindingRules:
72-
group-du-sno: ""
119+
# These policies will correspond to all clusters with these labels
120+
group-du-sno-zone: "zone-1"
121+
hardware-type: "hardware-type-1"
73122
mcp: "master"
74123
sourceFiles:
75-
- fileName: SriovNetwork.yaml
76-
policyName: "config-policy"
124+
- fileName: ClusterLogForwarder.yaml # wave 10
125+
policyName: "group-du-sno-cfg-policy"
126+
spec:
127+
outputs: '{{hub fromConfigMap "" "group-zones-configmap" (printf "%s-cluster-log-fwd-outputs" (index .ManagedClusterLabels "group-du-sno-zone")) | toLiteral hub}}'
128+
pipelines: '{{hub fromConfigMap "" "group-zones-configmap" (printf "%s-cluster-log-fwd-pipelines" (index .ManagedClusterLabels "group-du-sno-zone")) | toLiteral hub}}'
129+
130+
- fileName: PerformanceProfile.yaml # wave 10
131+
policyName: "group-du-sno-cfg-policy"
77132
metadata:
78-
name: "sriov-nw-du-fh"
133+
name: openshift-node-performance-profile
134+
spec:
135+
additionalKernelArgs:
136+
- rcupdate.rcu_normal_after_boot=0
137+
- vfio_pci.enable_sriov=1
138+
- vfio_pci.disable_idle_d3=1
139+
- efi=runtime
140+
cpu:
141+
isolated: '{{hub fromConfigMap "" "group-hardware-types-configmap" (printf "%s-cpu-isolated" (index .ManagedClusterLabels "hardware-type")) hub}}'
142+
reserved: '{{hub fromConfigMap "" "group-hardware-types-configmap" (printf "%s-cpu-reserved" (index .ManagedClusterLabels "hardware-type")) hub}}'
143+
hugepages:
144+
defaultHugepagesSize: '{{hub fromConfigMap "" "group-hardware-types-configmap" (printf "%s-hugepages-default" (index .ManagedClusterLabels "hardware-type")) hub}}'
145+
pages:
146+
- size: '{{hub fromConfigMap "" "group-hardware-types-configmap" (printf "%s-hugepages-size" (index .ManagedClusterLabels "hardware-type")) hub}}'
147+
count: '{{hub fromConfigMap "" "group-hardware-types-configmap" (printf "%s-hugepages-count" (index .ManagedClusterLabels "hardware-type")) | toInt hub}}'
148+
realTimeKernel:
149+
enabled: true
150+
151+
- fileName: SriovNetwork.yaml # wave 100
152+
policyName: "group-du-sno-sriov-policy"
153+
metadata:
154+
name: sriov-nw-du-fh
79155
spec:
80156
resourceName: du_fh
81-
vlan: '{{hub fromConfigMap "ztp-site" "sriovdata" (printf "%s-du_fh-vlan" .ManagedClusterName) | toInt hub}}'
82-
- fileName: SriovNetworkNodePolicy.yaml
83-
policyName: "config-policy"
157+
vlan: '{{hub fromConfigMap "" "site-data-configmap" (printf "%s-sriov-network-vlan-1" .ManagedClusterName) | toInt hub}}'
158+
159+
- fileName: SriovNetworkNodePolicy.yaml # wave 100
160+
policyName: "group-du-sno-sriov-policy"
84161
metadata:
85-
name: "sriov-nnp-du-fh"
162+
name: sriov-nnp-du-fh
86163
spec:
87164
deviceType: netdevice
88-
isRdma: true
165+
isRdma: false
89166
nicSelector:
90-
pfNames:
91-
- '{{hub fromConfigMap "ztp-site" "sriovdata" (printf "%s-du_fh-pf" .ManagedClusterName) | autoindent hub}}'
92-
numVfs: '{{hub fromConfigMap "ztp-site" "sriovdata" (printf "%s-du_fh-numVfs" .ManagedClusterName) | toInt hub}}'
93-
priority: '{{hub fromConfigMap "ztp-site" "sriovdata" (printf "%s-du_fh-priority" .ManagedClusterName) | toInt hub}}'
167+
pfNames: '{{hub fromConfigMap "" "group-hardware-types-configmap" (printf "%s-sriov-node-policy-pfNames-1" (index .ManagedClusterLabels "hardware-type")) | toLiteral hub}}'
168+
numVfs: 8
169+
priority: 10
94170
resourceName: du_fh
95-
- fileName: SriovNetwork.yaml
96-
policyName: "config-policy"
171+
172+
- fileName: SriovNetwork.yaml # wave 100
173+
policyName: "group-du-sno-sriov-policy"
97174
metadata:
98-
name: "sriov-nw-du-mh"
175+
name: sriov-nw-du-mh
99176
spec:
100177
resourceName: du_mh
101-
vlan: '{{hub fromConfigMap "ztp-site" "sriovdata" (printf "%s-du_mh-vlan" .ManagedClusterName) | toInt hub}}'
102-
- fileName: SriovNetworkNodePolicy.yaml
103-
policyName: "config-policy"
178+
vlan: '{{hub fromConfigMap "" "site-data-configmap" (printf "%s-sriov-network-vlan-2" .ManagedClusterName) | toInt hub}}'
179+
180+
- fileName: SriovNetworkNodePolicy.yaml # wave 100
181+
policyName: "group-du-sno-sriov-policy"
104182
metadata:
105-
name: "sriov-nnp-du-mh"
183+
name: sriov-nw-du-fh
106184
spec:
107-
deviceType: vfio-pci
185+
deviceType: netdevice
108186
isRdma: false
109187
nicSelector:
110-
pfNames:
111-
- '{{hub fromConfigMap "ztp-site" "sriovdata" (printf "%s-du_mh-pf" .ManagedClusterName) hub}}'
112-
numVfs: '{{hub fromConfigMap "ztp-site" "sriovdata" (printf "%s-du_mh-numVfs" .ManagedClusterName) | toInt hub}}'
113-
priority: '{{hub fromConfigMap "ztp-site" "sriovdata" (printf "%s-du_mh-priority" .ManagedClusterName) | toInt hub}}'
114-
resourceName: du_mh
188+
pfNames: '{{hub fromConfigMap "" "group-hardware-types-configmap" (printf "%s-sriov-node-policy-pfNames-2" (index .ManagedClusterLabels "hardware-type")) | toLiteral hub}}'
189+
numVfs: 8
190+
priority: 10
191+
resourceName: du_fh
115192
----
193+
+
194+
[NOTE]
195+
====
196+
To retrieve site-specific configuration values, use the `.ManagedClusterName` field.
197+
This is a template context value set to the name of the target managed cluster.
198+
199+
To retrieve group-specific configuration, use the `.ManagedClusterLabels` field.
200+
This is a template context value set to the value of the managed cluster's labels.
201+
====
116202
117203
. Commit the site `PolicyGenTemplate` CR in Git and push to the Git repository that is monitored by the ArgoCD application.
118204
+
119205
[NOTE]
120206
====
121-
Subsequent changes to the referenced `ConfigMap` CR are not automatically synced to the applied policies. You need to manually sync the new `ConfigMap` changes to update existing PolicyGenTemplate CRs. See "Syncing new ConfigMap changes to existing PolicyGenTemplate CRs".
207+
Subsequent changes to the referenced `ConfigMap` CR are not automatically synced to the applied policies.
208+
You need to manually sync the new `ConfigMap` changes to update existing `PolicyGenTemplate` CRs. See "Syncing new ConfigMap changes to existing PolicyGenTemplate CRs".
209+
210+
You can use the same `PolicyGenTemplate` CR for multiple clusters.
211+
If there is a configuration change, then the only modifications you need to make are to the `ConfigMap` objects that hold the configuration for each cluster and the labels of the managed clusters.
122212
====

scalability_and_performance/ztp_far_edge/ztp-advanced-policy-config.adoc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,4 @@ include::modules/ztp-example-hub-template-functions.adoc[leveloffset=+2]
123123

124124
include::modules/ztp-specifying-nics-in-pgt-crs-with-hub-cluster-templates.adoc[leveloffset=+2]
125125

126-
include::modules/ztp-managing-sriov-vlan-with-hub-cluster-templates-in-pgt.adoc[leveloffset=+2]
127-
128126
include::modules/ztp-syncing-new-configmap-changes-to-existing-pgt-crs.adoc[leveloffset=+2]

0 commit comments

Comments
 (0)