-
Notifications
You must be signed in to change notification settings - Fork 286
added placement tolerations check into best practices policyset #556
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
Merged
openshift-merge-bot
merged 1 commit into
open-cluster-management-io:main
from
ch-stark:main
Jul 20, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
...tor/policy-sets/community/ocp-best-practices/input-tolerations/placement-tolerations.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| --- | ||
| object-templates-raw: | | ||
| {{/* ## Gather all Placements from the hub cluster ## */}} | ||
| {{- $stdTolerations := dict "unreachable" "cluster.open-cluster-management.io/unreachable" | ||
| "unavailable" "cluster.open-cluster-management.io/unavailable" }} | ||
|
|
||
| {{- range $pt := (lookup "cluster.open-cluster-management.io/v1beta1" "Placement" "" "").items }} | ||
| - complianceType: musthave | ||
| objectDefinition: | ||
| apiVersion: cluster.open-cluster-management.io/v1beta1 | ||
| kind: Placement | ||
| metadata: | ||
| name: {{ $pt.metadata.name }} | ||
| namespace: {{ $pt.metadata.namespace }} | ||
| spec: | ||
| tolerations: | ||
| {{- range $t := $pt.spec.tolerations }} | ||
| - {{ $t | toRawJson | toLiteral }} | ||
|
|
||
| {{/* ## check if the toleration is unavailable or unreachable ## */}} | ||
| {{- if eq $t.key $stdTolerations.unreachable }} | ||
| {{- $_ := unset $stdTolerations "unreachable" }} | ||
| {{- else if eq $t.key $stdTolerations.unavailable }} | ||
| {{- $_ := unset $stdTolerations "unavailable" }} | ||
| {{- end }} | ||
| {{- end }} | ||
|
|
||
| {{- range $t := $stdTolerations }} | ||
| - key: {{ $t }} | ||
| operator: Exists | ||
| {{- end }} | ||
|
|
||
| {{- end }} |
11 changes: 11 additions & 0 deletions
11
policygenerator/policy-sets/community/ocp-best-practices/input/hub-placement.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| apiVersion: cluster.open-cluster-management.io/v1beta1 | ||
| kind: Placement | ||
| metadata: | ||
| name: placement-openshift-plus-hub | ||
| namespace: policies | ||
| spec: | ||
| predicates: | ||
| - requiredClusterSelector: | ||
| labelSelector: | ||
| matchExpressions: | ||
| - {key: "local-cluster", operator: In, values: ["true"]} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: open-cluster-management-io/policy-collection
Length of output: 4129
🏁 Script executed:
Repository: open-cluster-management-io/policy-collection
Length of output: 20965
🌐 Web query:
Policy Generator policySets merge override policyDefaults policySets Open Cluster Management💡 Result:
In the Open Cluster Management (OCM) Policy Generator, the configuration follows a hierarchical structure where defaults can be overridden at more specific levels. PolicyDefaults vs. Overrides The policyDefaults section defines common settings that apply to all policies generated by the PolicyGenerator [1][2]. Most fields defined in policyDefaults can be overridden for individual policies by specifying them within the specific entry in the policies array [1][3]. The only field in policyDefaults that cannot be overridden in this manner is namespace [1][3]. PolicySets and Merging PolicySets are used to group related policies, allowing for unified placement management [1][4]. When a policy is included in a PolicySet, a placement binding is automatically generated for the set rather than for the individual policy [1]. Regarding the interaction between policySets defined in different locations: 1. Merging Behavior: If policySets are specified in multiple places (such as in policyDefaults.policySets and within individual policies[].policySets), the lists of policy sets are merged [1][3]. 2. Overriding: You can define default values for all policy sets using the policySetDefaults section [1]. Any values defined there can be overridden by specific entries within the policySets array [1]. 3. Placement Generation: By default, when a policy is part of a policy set, the generator does not create a separate placement for that policy. You can change this behavior by setting generatePlacementWhenInSet to true in either policyDefaults or at the specific policy level [1]. In summary, the OCM Policy Generator uses a cascading approach where policySetDefaults provide base configurations for all sets, and policyDefaults provides base configurations for all policies, both of which can be selectively overridden by more granular definitions in the policySets or policies arrays, respectively [1][3].
Citations:
policy-placement-tolerationsstill inheritsopenshift-best-practicesPolicyGenerator mergespolicySetsfrompolicyDefaultswith the per-policy entry, so this policy will land in bothopenshift-best-practicesandopenshift-best-practices-hub. MovepolicySetsout of the defaults or split the defaults so this one stays hub-only.🤖 Prompt for AI Agents
Source: Coding guidelines