@@ -198,7 +198,7 @@ List the specific goals of the KEP. What is it trying to achieve? How will we
198
198
know that this has succeeded?
199
199
-->
200
200
201
- - Introduce a new struct to define all node inclusion policies explicitly
201
+ - Introduce two new fields to define all node inclusion policies explicitly
202
202
- Provide an option for end-users to specify whether to respect taints or not
203
203
204
204
### Non-Goals
@@ -219,7 +219,7 @@ implementation. What is the desired outcome and how do we measure success?.
219
219
The "Design Details" section below is for the real
220
220
nitty-gritty.
221
221
-->
222
- Introduce a new field to ` TopologySpreadConstraint ` to define all node inclusion
222
+ Introduce two new fields to ` TopologySpreadConstraint ` to define all node inclusion
223
223
policies including nodeAffinity and nodeTaint.
224
224
225
225
### User Stories (Optional)
@@ -271,40 +271,42 @@ required) or even code snippets. If there's any ambiguity about HOW your
271
271
proposal will be implemented, this is the place to discuss them.
272
272
-->
273
273
274
- A new field named ` NodeInclusionPolicies ` will be introduced to ` TopologySpreadConstraint ` :
274
+ Two new fields named ` NodeAffinityPolicy ` and ` NodeTaintsPolicy ` will be
275
+ introduced to ` TopologySpreadConstraint ` :
275
276
``` golang
276
277
type TopologySpreadConstraint struct {
277
- // NodeInclusionPolicies includes several policies
278
- // when calculating pod topology spread skew
279
- NodeInclusionPolicies NodeInclusionPolicies
278
+ // NodeAffinityPolicy indicates how we will treat Pod's nodeAffinity/nodeSelector
279
+ // when calculating pod topology spread skew. Options are:
280
+ // - Honor: only nodes matching nodeAffinity/nodeSelector are included in the calculations.
281
+ // - Ignore: nodeAffinity/nodeSelector are ignored. All nodes are included in the calculations.
282
+ //
283
+ // If this value is nil, the behavior is equivalent to the Honor policy.
284
+ // This is a alpha-level feature enabled by the NodeInclusionPolicyInPodTopologySpread feature flag.
285
+ // +optional
286
+ NodeAffinityPolicy *NodeInclusionPolicy
287
+ // NodeTaintsPolicy indicates how we will treat node taints when calculating
288
+ // pod topology spread skew. Options are:
289
+ // - Honor: nodes without taints, along with tainted nodes for which the incoming pod
290
+ // has a toleration, are included.
291
+ // - Ignore: node taints are ignored. All nodes are included.
292
+ //
293
+ // If this value is nil, the behavior is equivalent to the Ignore policy.
294
+ // This is a alpha-level feature enabled by the NodeInclusionPolicyInPodTopologySpread feature flag.
295
+ // +optional
296
+ NodeTaintsPolicy *NodeInclusionPolicy
280
297
}
281
298
```
282
299
283
- There are two policies now regarding to nodeAffinity and nodeTaint :
300
+ We will define two NodeInclusionPolicy :
284
301
``` golang
285
- type NodeInclusionPolicies struct {
286
- // NodeAffinity policy indicates how we will treat nodeAffinity/nodeSelector
287
- // when calculating pod topology spread skew. The semantics vary by PolicyName:
288
- // - Respect (default): nodes matching nodeAffinity/nodeSelector will be included.
289
- // - Ignore: all nodes will be included.
290
- NodeAffinity PolicyName
291
- // NodeTaint policy indicates how we will treat node taints
292
- // when calculating pod topology spread skew. The semantics vary by PolicyName:
293
- // - Respect: tainted nodes that tolerate the incoming pod, along with regular nodes, will be included.
294
- // - Ignore (default): all nodes will be included.
295
- NodeTaint PolicyName
296
- }
297
- ```
298
-
299
- We will define two policyNames by default:
300
- ``` golang
301
- type PolicyName string
302
+ // NodeInclusionPolicy defines the type of node inclusion policy
303
+ type NodeInclusionPolicy string
302
304
303
305
const (
304
- // Ignore means ignore this policy in calculating.
305
- Ignore PolicyName = " Ignore"
306
- // Respect means use this policy in calculating.
307
- Respect PolicyName = " Respect "
306
+ // NodeInclusionPolicyIgnore means ignore this scheduling policy when calculating pod topology spread skew .
307
+ NodeInclusionPolicyIgnore NodeInclusionPolicy = " Ignore"
308
+ // NodeInclusionPolicyHonor means use this scheduling policy when calculating pod topology spread skew .
309
+ NodeInclusionPolicyHonor NodeInclusionPolicy = " Honor "
308
310
)
309
311
```
310
312
@@ -334,7 +336,7 @@ when drafting this test plan.
334
336
- Unit and integration tests:
335
337
- Defaulting and validation tests
336
338
- Feature gate enable/disable tests
337
- - ` NodeInclusionPolicies ` works as expected
339
+ - ` NodeAffinityPolicy ` and ` NodeTaintsPolicy ` work as expected
338
340
- Benchmark tests:
339
341
- Verify the performance of looping all toleration and taints in calculating skew is acceptable
340
342
@@ -426,8 +428,9 @@ enhancement:
426
428
-->
427
429
428
430
- Upgrade
429
- - While the feature gate is enabled, ` NodeInclusionPolicies ` is allowed to use by end-users.
430
- - While the feature gate is enabled, and we don't set this field, default values
431
+ - While the feature gate is enabled, ` NodeAffinityPolicy ` and ` NodeTaintsPolicy ` are
432
+ allowed to use by end-users.
433
+ - While the feature gate is enabled, and we don't set these two fields, default values
431
434
will be configured, which will maintain previous behavior.
432
435
- Downgrade
433
436
- Previously configured values will be ignored.
@@ -485,7 +488,7 @@ Pick one of these and delete the rest.
485
488
-->
486
489
487
490
- [x] Feature gate (also fill in values in ` kep.yaml ` )
488
- - Feature gate name: PodTopologySpreadNodePolicies
491
+ - Feature gate name: NodeInclusionPolicyInPodTopologySpread
489
492
- Components depending on the feature gate: kube-scheduler, kube-apiserver
490
493
491
494
###### Does enabling the feature change any default behavior?
@@ -578,8 +581,9 @@ Ideally, this should be a metric. Operations against the Kubernetes API (e.g.,
578
581
checking if there are objects with field X set) may be a last resort. Avoid
579
582
logs or events for this purpose.
580
583
-->
581
- Operator can query ` pod.spec.topologySpreadConstraints[].NodeInclusionPolicies ` field
582
- and identify if this is set to non-default values
584
+ Operator can query ` pod.spec.topologySpreadConstraints[].NodeAffinityPolicy `
585
+ and ` pod.spec.topologySpreadConstraints[].NodeAffinityPolicy ` to identify whether
586
+ this is set to non-default values
583
587
584
588
###### How can someone using this feature know that it is working for their instance?
585
589
0 commit comments