Skip to content

Commit 83bb5d2

Browse files
authored
Merge pull request stolostron#7600 from stolostron/jcberger-18037-template-addon
https://issues.redhat.com/browse/ACM-18037
2 parents 425bb1a + a89d9ae commit 83bb5d2

File tree

3 files changed

+60
-1
lines changed

3 files changed

+60
-1
lines changed

governance/adv_template_process.adoc

+56
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Continue reading for advanced template use-cases:
1111
* <<bypass-template-processing,Bypassing template processing>>
1212
* <<object-selector,Configuration policy object selector>>
1313
* <<raw-object-template-processing,Processing raw templates in configuration policies>>
14+
* <<resolve-hub-templates, Resolving hub templates after defining configuration policies >>
1415
1516
[#special-annotation-processing]
1617
== Special annotation for reprocessing
@@ -166,9 +167,64 @@ spec:
166167
{{- end }}
167168
----
168169

170+
[#resolve-hub-templates]
171+
== Resolving hub templates after defining configuration policies
172+
173+
By default, if you use the hub templates in the `ConfigurationPolicy` and `OperatorPolicy` resources, you must correspond the `Policy` resources that are defined on the hub cluster with these resources.
174+
175+
You can define configuration policies directly on the managed clusters. For example, {gitops-short} is one that you can define configuration policies directly on the managed cluster. To resolve hub templates on the managed cluster in that situation, you can enable the `governance-standalone-hub-templating` add-on.
176+
177+
To enable the `governance-standalone-hub-templating` add-on, complete the following steps:
178+
179+
. On your hub cluster, go to the managed cluster namespace.
180+
. Create a `ManagedClusterAddOn` resource with the `governance-standalone-hub-templating` name by using the following YAML sample:
181+
182+
+
183+
[source,yaml]
184+
----
185+
apiVersion: addon.open-cluster-management.io/v1alpha1
186+
kind: ManagedClusterAddOn
187+
metadata:
188+
name: governance-standalone-hub-templating
189+
namespace: <cluster name>
190+
labels:
191+
cluster.open-cluster-management.io/backup: ''
192+
spec:
193+
installNamespace: open-cluster-management-agent-addon
194+
----
195+
196+
By default, the agent on the managed cluster only has access to the `ManagedCluster` resources on the hub cluster. You can use the `.ManagedClusterLabels` template variable in the hub cluster templates inside the `ConfigurationPolicies` that are deployed directly to the managed cluster.
197+
198+
If you want the hub template to access other resources, such as the `lookup` or `fromConfigMap` function calls, you must add those specific permissions to the add-on group. You can add these permissions through resources, such as `Roles`, `ClusterRoles`, `RoleBindings`, and `ClusterRoleBindings`.
199+
200+
The name of the add-on group depends on the name of your managed cluster, but it has the following standard form: `system:open-cluster-management:cluster:<cluster name>:addon:governance-standalone-hub-templating`.
201+
202+
To allow access to `Configmaps` in your managed cluster namespace on your hub cluster, complete the following steps:
203+
204+
. Add the `Role` resource by running the following command:
205+
206+
+
207+
[source,bash]
208+
----
209+
oc create role -n <cluster name> cm-reader --verb=get,list,watch --resource=configmaps
210+
----
211+
212+
. Add the `Rolebinding` by running the following command:
213+
214+
+
215+
[source,bash]
216+
----
217+
oc create rolebinding -n <cluster name> cm-reader-binding --role=cm-reader --group=system:open-cluster-management:cluster:<cluster name>:addon:governance-standalone-hub-templating
218+
----
219+
220+
. To ensure these resources on the hub cluster get backed up and restored, add the following label to each resource that you create: `cluster.open-cluster-management.io/backup`.
221+
222+
After you add these resources, the add-on can resolve the hub templates, and the state of the policy gets saved on a secret on the managed clusters. This secret prevents interruptions if the hub cluster becomes temporarily unavailable to the managed cluster.
223+
169224
[#additional-resources-hub-temp]
170225
== Additional resources
171226

227+
* See xref:../business_continuity/backup_restore/backup_arch.adoc#resources-that-are-backed-up[Resources that are backed up] for more details on backing up and restoring resources.
172228
* See xref:../governance/template_functions.adoc#template-functions[Template functions] for more details.
173229
* Return to xref:../governance/template_support_intro.adoc#template-processing[Template processing].
174230
* See xref:../governance/manage_policies.adoc#policy-cli-commands[Policy CLI] for tools to resolve Go templates locally.

governance/pol_deploy_ext_tools.adoc

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ The {gitops-short} service account must have permission to manage {acm} policies
1414
== Additional resources
1515

1616
* See link:../gitops/gitops_manage_policy_def.adoc#config-gitops-healthcheck[Configuring policy health checks in {gitops-short}].
17-
* See link:../gitops_manage_policy_def.adoc#create-clusterrole-gitops[Creating a ClusterRole resource for {gitops}].
17+
* See link:../gitops_manage_policy_def.adoc#create-clusterrole-gitops[Creating a ClusterRole resource for {gitops}].
18+
* See link:../governance/adv_template_process.adoc#resolve-hub-templates[Resolving hub templates after defining configuration policies].

release_notes/acm_whats_new.adoc

+2
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ See link:../observability/observe_environments_intro.adoc#observing-environments
7676
[#governance-whats-new]
7777
== Governance
7878

79+
* In earlier versions, the policy framework on the hub was required to resolve hub templates. This requirement made you have to put the `ConfigurationPolicy` into a `Policy` on the hub cluster for distribution through the `Placement`. With this update, you can use the `governance-standalone-hub-templating` add-on to resolve hub templates directly on managed clusters, when the `ConfigurationPolicy` is created outside of the policy framework.
80+
7981
* `ValidatingAdmissionPolicyBindings` now appear in the `Discovered` policies tab in the Governance console. Additionally, you can also see other policy types that are in your managed clusters. The `ValidatingAdmissionPolicyBindings` details include other resources on the cluster that you can use to configure its behavior.
8082
8183
* Gatekeeper Mutation resources now appear in the `Discovered` policies tab in the Governance console. Use the Gatekeeper Mutation resource to view details of your managed clusters, including which resources might have been mutated by these policies.

0 commit comments

Comments
 (0)