Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ACM-18042: Adopt policy best practices (GRC) #7524

Open
wants to merge 5 commits into
base: 2.13_stage
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,6 @@ metadata:
name: placement-policy-mirror
namespace: default
spec:
clusterConditions:
- status: "True"
type: ManagedClusterConditionAvailable
clusterSelector:
matchExpressions:
[] <3>
Expand Down Expand Up @@ -358,9 +355,6 @@ metadata:
name: placement-policy-catalog
namespace: default
spec:
clusterConditions:
- status: "True"
type: ManagedClusterConditionAvailable
clusterSelector:
matchExpressions:
[] <2>
Expand Down Expand Up @@ -461,9 +455,6 @@ metadata:
name: placement-policy-cluster-version
namespace: default
spec:
clusterConditions:
- status: "True"
type: ManagedClusterConditionAvailable
clusterSelector:
matchExpressions:
[] <2>
Expand Down
3 changes: 0 additions & 3 deletions gitops/gitops_policy_generator.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ metadata:
name: placement-install-openshift-gitops
namespace: policies
spec:
clusterConditions:
- status: "True"
type: ManagedClusterConditionAvailable
clusterSelector:
matchExpressions:
- key: vendor
Expand Down
9 changes: 9 additions & 0 deletions governance/generate_pol_operator_install.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Generate a policy that installs the Compliance Operator onto your clusters. For
Complete the following steps:

. Create a YAML file with a `Namespace`, a `Subscription`, and an `OperatorGroup` manifest called `compliance-operator.yaml`. The following example installs these manifests in the `compliance-operator` namespace. Replace `<release-0.x>` with the correct channel:

+
[source,yaml]
----
Expand Down Expand Up @@ -36,6 +37,7 @@ spec:
----

. Create a `PolicyGenerator` configuration file. View the following `PolicyGenerator` policy example that installs the Compliance Operator on all {ocp-short} managed clusters:

+
[source,yaml]
----
Expand All @@ -59,6 +61,7 @@ policies:
----

. Add the policy generator to your `kustomization.yaml` file. The `generators` section might resemble the following configuration:

+
[source,yaml]
----
Expand All @@ -67,6 +70,7 @@ generators:
----
+
As a result, the generated policy resembles the following file:

+
[source,yaml]
----
Expand All @@ -84,6 +88,11 @@ spec:
operator: In
values:
- OpenShift
tolerations:
- key: cluster.open-cluster-management.io/unavailable
operator: Exists
- key: cluster.open-cluster-management.io/unreachable
operator: Exists
---
apiVersion: policy.open-cluster-management.io/v1
kind: PlacementBinding
Expand Down
10 changes: 10 additions & 0 deletions governance/hub_policy_framework.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ spec:
labelSelector:
matchExpressions:
- {key: environment, operator: In, values: ["dev"]}
tolerations:
- key: cluster.open-cluster-management.io/unavailable
operator: Exists
- key: cluster.open-cluster-management.io/unreachable
operator: Exists
----

+
Expand Down Expand Up @@ -270,6 +275,11 @@ spec:
labelSelector:
matchExpressions:
- {key: environment, operator: In, values: ["dev"]}
tolerations:
- key: cluster.open-cluster-management.io/unavailable
operator: Exists
- key: cluster.open-cluster-management.io/unreachable
operator: Exists
----

[#add-resources-policy-overview]
Expand Down
31 changes: 22 additions & 9 deletions governance/manage_policies.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ spec:
----

. Define a `PlacementBinding` resource to bind your policy to your `Placement` resource. Your `PlacementBinding` resource might resemble the following YAML sample:

+
[source,yaml]
----
Expand Down Expand Up @@ -169,6 +170,7 @@ subjects:
----
+
See the following `Placement` example:

+
[source,yaml]
----
Expand All @@ -182,6 +184,11 @@ spec:
labelSelector:
matchLabels:
cloud: "IBM"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting seems to be off here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

tolerations:
- key: cluster.open-cluster-management.io/unavailable
operator: Exists
- key: cluster.open-cluster-management.io/unreachable
operator: Exists
----

. *Optional:* Add a description for your policy.
Expand Down Expand Up @@ -274,20 +281,26 @@ Click *Disable policy*. Your policy is disabled.

Delete a security policy from the CLI or the console.

* Delete a security policy from the CLI:
.. Delete a security policy by running the following command:
Use the following procedure to delete from the CLI:

. Delete a security policy by running the following command:

+
----
oc delete policies.policy.open-cluster-management.io <policy-name> -n <policy-namespace>
----
+
After your policy is deleted, it is removed from your target cluster or clusters. Verify that your policy is removed by running the following command: `oc get policies.policy.open-cluster-management.io <policy-name> -n <policy-namespace>`

Copy link
Contributor

@swopebe swopebe Feb 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This had a random (+) in the file, which was overused bc it was built with bullets and steps were merged together. Quick format fix.

* Delete a security policy from the console:
+
From the navigation menu, click *Governance* to view a table list of your policies. Click the *Actions* icon for the policy you want to delete in the policy violation table.
+
Click *Remove*. From the _Remove policy_ dialog box, click *Remove policy*.
. Verify that your policy is removed by running the following command: `oc get policies.policy.open-cluster-management.io <policy-name> -n <policy-namespace>`

Use the following procedure to delete a security policy from the console.

. From the navigation menu, click *Governance* to view a table list of your policies.

. Click the *Actions* icon for the policy you want to delete in the policy violation table.

. Click *Remove*.

. From the _Remove policy_ dialog box, click *Remove policy*.

[#deleting-policy-sets]
=== Deleting policy sets from the console
Expand Down
9 changes: 9 additions & 0 deletions governance/opp_policyset_install.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Continue reading for guidance to apply the Red Hat Openshift Platform Plus polic
Complete the following steps before you apply the policy set:

. To allow for subscriptions to be applied to your cluster, you must apply the `policy-configure-subscription-admin-hub.yaml` policy and set the remediation action to `enforce`. Copy and paste the following YAML into the YAML editor of the console:

+
[source,yaml]
----
Expand Down Expand Up @@ -101,15 +102,22 @@ spec:
labelSelector:
matchExpressions:
- {key: name, operator: In, values: ["local-cluster"]}
tolerations:
- key: cluster.open-cluster-management.io/unavailable
operator: Exists
- key: cluster.open-cluster-management.io/unreachable
operator: Exists
----
+
. To apply the previous YAML from the command line interface, run the following command:

+
----
oc apply -f policy-configure-subscription-admin-hub.yaml
----
. Install the Policy Generator kustomize plugin. Use Kustomize v4.5 or newer. See link:../gitops/gitops_policy__operator.adoc#gitops-policy-operator[Generating a policy to install an Operator].
. Policies are installed to the `policies` namespace. You must bind that namespace to a `ClusterSet`. For example, copy and apply the following example YAML to bind the namespace to the default `ClusterSet`:

+
[source,yaml]
----
Expand All @@ -123,6 +131,7 @@ spec:
----
+
. Run the following command to apply the `ManagedClusterSetBinding` resource from the command line interface:

+
----
oc apply -f managed-cluster.yaml
Expand Down
5 changes: 5 additions & 0 deletions governance/policy_generator.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ spec:
- requiredClusterSelector:
labelSelector:
matchExpressions: []
tolerations:
- key: cluster.open-cluster-management.io/unavailable
operator: Exists
- key: cluster.open-cluster-management.io/unreachable
operator: Exists
---
apiVersion: policy.open-cluster-management.io/v1
kind: PlacementBinding
Expand Down
5 changes: 5 additions & 0 deletions governance/policy_set_ctrl.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ spec:
operator: In
values:
- local-cluster
tolerations:
- key: cluster.open-cluster-management.io/unavailable
operator: Exists
- key: cluster.open-cluster-management.io/unreachable
operator: Exists
----


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ subjects:
+
[source,bash]
----
oc get policy policy-mce-hcp-autoimport -n <namespace>
oc get policies.policy.open-cluster-management.io policy-mce-hcp-autoimport -n <namespace>
----

*Important:* You can _detach_ a hosted cluster from {acm-short} by using the *Detach* option in the {acm-short} console, or by removing the corresponding `ManagedCluster` custom resource from the command line.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,5 +193,5 @@ subjects:

+
----
oc get policy policy-rosa-autoimport -n <namespace>
oc get policies.policy.open-cluster-management.io policy-rosa-autoimport -n <namespace>
----