Skip to content

Commit 58d0263

Browse files
JustinKuliopenshift-merge-robot
authored andcommitted
Second try implementation of policy ordering
What was `orderViaDependencies` has been moved into `policyDefaults` as `orderPolicies`. A similar `orderManifests` option will automatically generate manifest-level `extraDependencies` to order ConfigPolicies within a Policy. In both cases, instead of *merging* dependency lists, it is only allowed to define dependencies one way. If `dependencies` or `extraDependencies` are defined at multiple levels, the more "specific" level will override previous definitions, which is more consistent with other settings. Refs: - stolostron/backlog#26183 Signed-off-by: Justin Kulikauskas <[email protected]>
1 parent 5bc8261 commit 58d0263

File tree

6 files changed

+270
-300
lines changed

6 files changed

+270
-300
lines changed

docs/policygenerator-reference.yaml

Lines changed: 41 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ placementBindingDefaults:
1010
# Set an explicit placement binding name to use rather than rely on the default.
1111
name: ""
1212

13-
# Optional. Determines whether to define dependencies on the policies so they are applied in the
14-
# order they are defined in the manifests list. This defaults to false, and all the policies
15-
# can be applied at the same time.
16-
orderViaDependencies: false
17-
1813
# Required. Any default value listed here can be overridden under an entry in the policies array
1914
# except for "namespace".
2015
policyDefaults:
@@ -38,7 +33,7 @@ policyDefaults:
3833
# be generated. This defaults to true.
3934
consolidateManifests: true
4035
# Optional. A list of objects that should be in specific compliance states before this policy is
41-
# applied.
36+
# applied. Cannot be specified when policyDefaults.orderPolicies is set to true.
4237
dependencies:
4338
# Required. The name of the object being depended on.
4439
- name: ""
@@ -63,6 +58,20 @@ policyDefaults:
6358
# avoid evaluating the policy after it has become a particular compliance state.
6459
compliant: 30m
6560
noncompliant: 45s
61+
# Optional. A list of objects that should be in specific compliance states before this policy is
62+
# applied. These are added to each policy template (eg ConfigurationPolicy) separately from the
63+
# dependencies list. Cannot be specified when policyDefaults.orderManifests is set to true.
64+
extraDependencies:
65+
# Required. (See policyDefaults.dependencies.name for description.)
66+
- name: ""
67+
# Optional. (See policyDefaults.dependencies.namespace for description.)
68+
namespace: ""
69+
# Optional. (See policyDefaults.dependencies.compliance for description.)
70+
compliance: "Compliant"
71+
# Optional. (See policyDefaults.dependencies.kind for description.)
72+
kind: "Policy"
73+
# Optional. (See policyDefaults.dependencies.apiVersion for description.)
74+
apiVersion: "policy.open-cluster-management.io/v1"
6675
# Optional. Determines whether objects created or monitored by the policy should be deleted when the policy is
6776
# deleted. Pruning only takes place if the remediation action of the policy has been set to "enforce". Example values
6877
# are "DeleteIfCreated", "DeleteAll", or "None". This defaults to unset, which is equivalent to "None".
@@ -91,6 +100,14 @@ policyDefaults:
91100
exclude: []
92101
matchLabels: {}
93102
matchExpressions: []
103+
# Optional. Determines whether to define extraDependencies on policy templates so that they are
104+
# applied in the order they are defined in the manifests list for that policy. Cannot be specified
105+
# when consolidateManifests is set to true. Cannot be specified at the same time as extraDependencies.
106+
orderManifests: false
107+
# Optional. Determines whether to define dependencies on the policies so they are applied in the
108+
# order they are defined in the policies list. This defaults to false, and all the policies
109+
# can be applied at the same time. Cannot be specified at the same time as dependencies.
110+
orderPolicies: false
94111
# Optional. The placement configuration for the policies. This defaults to a placement
95112
# configuration that matches all clusters.
96113
placement:
@@ -170,12 +187,18 @@ policies:
170187
# Optional. (See policyDefaults.namespaceSelector for description.)
171188
# Cannot be specified when policyDefaults.consolidateManifests is set to true.
172189
namespaceSelector: {}
173-
# Optional. (See policyDefaults.evaluationInterval for description.)
190+
# Optional. (See policyDefaults.evaluationInterval for description.)
174191
# Cannot be specified when policyDefaults.consolidateManifests is set to true.
175192
evaluationInterval: {}
193+
# Optional. (See policyDefaults.extraDependencies for description)
194+
# Cannot be specified when policyDefaults.consolidateManifests is set to true.
195+
extraDependencies: []
176196
# Optional. (See policyDefaults.pruneObjectBehavior for description.)
177197
# Cannot be specified when policyDefaults.consolidateManifests is set to true.
178198
pruneObjectBehavior: ""
199+
# Optional. (See policyDefaults.ignorePending for description.)
200+
# Cannot be specified when policyDefaults.consolidateManifests is set to true.
201+
ignorePending: false
179202
# Optional. (See policyDefaults.remediationAction for description.)
180203
# Cannot be specified when policyDefaults.consolidateManifests is set to true.
181204
remediationAction: ""
@@ -214,23 +237,16 @@ policies:
214237
# Optional. (See policyDefaults.controls for description.)
215238
controls:
216239
- "CM-2 Baseline Configuration"
217-
# Optional. (See policyDefaults.dependencies for description.) Note: the list defined here will
218-
# be merged with the default list.
219-
dependencies:
220-
# Required. (See policyDefaults.dependencies.name for description.)
221-
- name: ""
222-
# Optional. (See policyDefaults.dependencies.namespace for description.)
223-
namespace: ""
224-
# Optional. (See policyDefaults.dependencies.compliance for description.)
225-
compliance: "Compliant"
226-
# Optional. (See policyDefaults.dependencies.kind for description.)
227-
kind: "Policy"
228-
# Optional. (See policyDefaults.dependencies.apiVersion for description.)
229-
apiVersion: "policy.open-cluster-management.io/v1"
240+
# Optional. (See policyDefaults.dependencies for description.)
241+
# Cannot be specified when policyDefaults.orderPolicies is set to true.
242+
dependencies: []
230243
# Optional. (See policyDefaults.disabled for description.)
231244
disabled: false
232245
# Optional. (See policyDefaults.evaluationInterval for description.)
233246
evaluationInterval: {}
247+
# Optional. (See policyDefaults.extraDependencies for description.)
248+
# Cannot be specified when orderManifests is set to true.
249+
extraDependencies: []
234250
# Optional. (See policyDefaults.pruneObjectBehavior for description.)
235251
pruneObjectBehavior: ""
236252
# Optional. (See policyDefaults.ignorePending for description.)
@@ -241,8 +257,12 @@ policies:
241257
informKyvernoPolicies: true
242258
# Optional. (See policyDefaults.consolidateManifests for description.)
243259
consolidateManifests: true
244-
# Optional.(See policyDefaults.namespaceSelector for description.)
260+
# Optional. (See policyDefaults.namespaceSelector for description.)
245261
namespaceSelector: {}
262+
# Optional. (See policyDefaults.orderManifests for description.)
263+
# Cannot be specified when consolidateManifests is set to true.
264+
# If set true here, the default extraDependencies will be overwritten.
265+
orderManifests: false
246266
# Optional. (See policyDefaults.placement for description.)
247267
placement: {}
248268
# Optional. (See policyDefaults.remediationAction for description.)

0 commit comments

Comments
 (0)