Skip to content

Commit 5fc22ec

Browse files
committed
update the design details
Signed-off-by: kerthcet <[email protected]>
1 parent 72f6764 commit 5fc22ec

File tree

1 file changed

+63
-100
lines changed
  • keps/sig-scheduling/3094-pod-topology-spread-considering-taints

1 file changed

+63
-100
lines changed

keps/sig-scheduling/3094-pod-topology-spread-considering-taints/README.md

Lines changed: 63 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,8 @@ updates.
168168
169169
[documentation style guide]: https://github.com/kubernetes/community/blob/master/contributors/guide/style-guide.md
170170
-->
171-
This KEP introduces a new field as an option for end-users to honor all taints or
172-
only system-generated unschedulable taints when computing pod topology spread skew.
173-
This helps improving the scheduling efficiency by filtering out nodes don't meet the
174-
toleration requirements.
171+
This KEP introduces an option for end-users to specify whether to take taints/tolerations
172+
into consideration when calculating pod topology spread skew.
175173

176174
## Motivation
177175

@@ -183,31 +181,32 @@ demonstrate the interest in a KEP within the wider Kubernetes community.
183181
184182
[experience reports]: https://github.com/golang/go/wiki/ExperienceReports
185183
-->
186-
Currently, when we compute pod topology spread skew, we will ignore the impact of
187-
node taints whatever pod tolerates or not, which may lead to some unexpected results.
188-
E.g. node with pod untolerated taints might be the candidate node after computing,
189-
then the pod would be stuck in Pending state. So toleration/taints should be taken into
190-
consideration when computing pod topology spread skew. For backwards compatibility,
191-
we'd like to define this as an option for end-users to honor all taints or
192-
only system-generated unschedulable taints.
184+
Currently in calculating pod topology spread skew, we will ignore node taints
185+
as node with pod untolerated taints will also be taken into calculation. This
186+
behavior doesn't match user expectations and will lead pod to unexpected Pending
187+
state(See [issue](https://github.com/kubernetes/kubernetes/issues/106127)).
188+
189+
Besides, given that we have already some node inclusion policies(nodeAffinity/nodeSelector)
190+
plumbed into PodTopologySpread implicitly, we'd like to redefine all of them into
191+
a new struct explicitly this time.
193192

194193
### Goals
195194

196195
<!--
197196
List the specific goals of the KEP. What is it trying to achieve? How will we
198197
know that this has succeeded?
199198
-->
200-
- Filtering out pod untolerated nodes when computing pod topology spread skew
201-
- Provide an option for end-users to specify whether to honor all taints or
202-
only system-generated unschedulable taints
199+
200+
- Introduce a new struct to define all node inclusion policies explicitly
201+
- Provide an option for end-users to specify whether to respect taints or not
203202

204203
### Non-Goals
205204

206205
<!--
207206
What is out of scope for this KEP? Listing non-goals helps to focus discussion
208207
and make progress.
209208
-->
210-
- Refactor or introduce any breaking changes to PodTopologySpread plugin
209+
- Support customized taints in array
211210

212211
## Proposal
213212

@@ -219,8 +218,8 @@ implementation. What is the desired outcome and how do we measure success?.
219218
The "Design Details" section below is for the real
220219
nitty-gritty.
221220
-->
222-
A new field `TaintStrategy` defined in `TopologySpreadConstraint` will be available for
223-
end-users to specify different strategies about how to treat taints in computing skew.
221+
Introduce a new field to `TopologySpreadConstraint` to define all node inclusion
222+
policies including nodeAffinity and nodeTaint.
224223

225224
### User Stories (Optional)
226225

@@ -232,23 +231,8 @@ bogged down.
232231
-->
233232

234233
#### Story 1
235-
When computing pod topology spread skew, I want to exclude nodes that don't tolerate
236-
all taints to prevent pods from falling into unexpected Pending state. I can simply
237-
configure this by specifying a taintStrategy:
238-
239-
apiVersion: v1
240-
kind: Pod
241-
metadata:
242-
name: mypod
243-
spec:
244-
topologySpreadConstraints:
245-
- maxSkew: 1
246-
topologyKey: zone
247-
whenUnsatisfiable: DoNotSchedule
248-
labelSelector:
249-
matchLabels:
250-
foo: bar
251-
taintStrategy: "honorAllTaints"
234+
When calculating pod topology spread skew, I want to exclude nodes that don't tolerate
235+
all taints to prevent pods from falling into unexpected Pending state.
252236

253237
### Notes/Constraints/Caveats (Optional)
254238

@@ -275,8 +259,6 @@ Consider including folks who also work outside the SIG or subproject.
275259

276260
- Looping all the toleration/taints to filter out unsatisfied nodes may
277261
lead to performance problem.
278-
- Some usual schedulable nodes may become unschedulable, which might be
279-
confusing for end-users.
280262

281263
## Design Details
282264

@@ -287,40 +269,38 @@ required) or even code snippets. If there's any ambiguity about HOW your
287269
proposal will be implemented, this is the place to discuss them.
288270
-->
289271

290-
A new field named `TaintStrategy` will be introduced to `TopologySpreadConstraint`:
291-
292-
type TopologySpreadConstraint struct {
293-
MaxSkew int32
294-
TopologyKey string
295-
WhenUnsatisfiable UnsatisfiableConstraintAction
296-
LabelSelector *metav1.LabelSelector
297-
TaintStrategy taintStrategy
298-
}
299-
300-
Correspondingly, the internal version for v1.TopologySpreadConstraint named
301-
`topologySpreadConstraint` will also add a `TaintStrategy` field:
302-
303-
type topologySpreadConstraint struct {
304-
MaxSkew int32
305-
TopologyKey string
306-
Selector labels.Selector
307-
TaintStrategy taintStrategy
308-
}
309-
310-
`taintStrategy` is a potential type of `String`, and there are two available options
311-
for users.
312-
313-
One is `honorAllTaints` which means when computing pod topology spread skew,
314-
all kinds of node taints should be taken into consideration, if any of these taints pod
315-
doesn't tolerate, the node is excluded.
272+
A new field named `NodeInclusionPolicies` will be introduced to `TopologySpreadConstraint`:
273+
```golang
274+
type TopologySpreadConstraint struct {
275+
// NodeInclusionPolicies includes several policies
276+
// when calculating pod topology spread skew
277+
NodeInclusionPolicies nodeInclusionPolicies
278+
}
279+
```
316280

317-
The other one is `honorUnschedulableTaint`, which means instead of considering all taints
318-
node carried, we only concern about taint `node.kubernetes.io/unschedulable:NoSchedule`.
281+
There are two policies now regarding to nodeAffinity and nodeTaint:
282+
```golang
283+
type nodeInclusionPolicies struct {
284+
// Respect nodeAffinity/nodeSelector or not in calculating.
285+
// By default we will respect this policy.
286+
nodeAffinityPolicy policyName
287+
// Respect all nodeTaints or not in calculating.
288+
// By default we will ignore this policy to maintain current behavior.
289+
nodeTaintPolicy policyName
290+
}
291+
```
319292

320-
This behavior is controlled by feature gate `TaintStrategy`, if this feature gate is on
321-
and `TaintStrategy` doesn't set, `honorAllTaints` will take effect by default.
293+
We will define two policyNames by default:
294+
```golang
295+
type policyName string
322296

323-
We'd like to implement this part of logic before computing skew for code efficiency.
297+
const (
298+
// Ignore means ignore this policy in calculating.
299+
ignore policyName = "ignore"
300+
// Respect means use this policy in calculating.
301+
respect policyName = "respect"
302+
)
303+
```
324304

325305
### Test Plan
326306

@@ -343,10 +323,11 @@ when drafting this test plan.
343323
-->
344324
- Unit and integration tests:
345325
- Defaulting and validation tests
346-
- Feature gate enable/disable tests.
347-
- `TaintStrategy` works as expected
326+
- Feature gate enable/disable tests
327+
- `nodeAffinityPolicy` works as expected
328+
- `nodeTaintPolicy` works as expected
348329
- Benchmark tests:
349-
- Verify the performance of looping all toleration and taints in computing skew is acceptable
330+
- Verify the performance of looping all toleration and taints in calculating skew is acceptable
350331

351332
### Graduation Criteria
352333

@@ -411,12 +392,12 @@ in back-to-back releases.
411392
-->
412393
#### Alpha
413394
- Feature implemented behind feature gate.
414-
- Test cases mentioned in Test Plan
395+
- Unit and integration tests passed.
415396

416397
#### Beta
417398
- Feature is enabled by default
399+
- Benchmark tests passed, and there is no performance problem.
418400
- Gather feedback from developers and surveys.
419-
- No performance problem.
420401

421402
#### GA
422403
- No negative feedback.
@@ -436,15 +417,12 @@ enhancement:
436417
-->
437418

438419
- Upgrade
439-
- While the feature gate is disabled, field `TaintStrategy` will be ignored.
440-
- While the feature gate is enabled, `TaintStrategy` provides two optional values
441-
for end-users to specify how to treat node taints.
442-
- While the feature gate is enabled, and we don't set this field, `taintStrategy` of
443-
`honorAllTaints` will take effect by default.
420+
- While the feature gate is disabled, field `NodeInclusionPolicies` will be ignored.
421+
- While the feature gate is enabled, `NodeInclusionPolicies` is allowed to use by end-users.
422+
- While the feature gate is enabled, and we don't set this field, default values
423+
will be configured, which will maintain previous behavior.
444424
- Downgrade
445-
- Whatever we enable/disable feature gate, previously configured values will
446-
be ignored.
447-
425+
- Whatever we enable/disable feature gate, previously configured values will be ignored.
448426

449427
### Version Skew Strategy
450428
N/A
@@ -499,30 +477,16 @@ Pick one of these and delete the rest.
499477
-->
500478

501479
- [x] Feature gate (also fill in values in `kep.yaml`)
502-
- Feature gate name: TaintStrategy
480+
- Feature gate name: PodTopologySpreadTaintPolicy
503481
- Components depending on the feature gate: kube-scheduler, kube-apiserver
504-
- [x] Other
505-
- Describe the mechanism:
506-
507-
Specify strategy about how to treat taints.
508-
509-
- Will enabling / disabling the feature require downtime of the control
510-
plane?
511-
512-
Yes.
513-
514-
- Will enabling / disabling the feature require downtime or reprovisioning
515-
of a node? (Do not assume `Dynamic Kubelet Config` feature is enabled).
516-
517-
No.
518482

519483
###### Does enabling the feature change any default behavior?
520484

521485
<!--
522486
Any change of default behavior may be surprising to users or break existing
523487
automations, so be extremely careful here.
524488
-->
525-
Yes, some usual schedulable nodes might be unschedulable.
489+
No.
526490

527491
###### Can the feature be disabled once it has been enabled (i.e. can we roll back the enablement)?
528492

@@ -605,8 +569,8 @@ Ideally, this should be a metric. Operations against the Kubernetes API (e.g.,
605569
checking if there are objects with field X set) may be a last resort. Avoid
606570
logs or events for this purpose.
607571
-->
608-
Operator can query `pod.spec.topologySpreadConstraints[].taintStrategy` field
609-
and identify if this is set.
572+
Operator can query `pod.spec.topologySpreadConstraints[].NodeInclusionPolicies` field
573+
and identify if this is set to non-default values
610574

611575
###### How can someone using this feature know that it is working for their instance?
612576

@@ -626,7 +590,6 @@ Recall that end users cannot usually observe component logs or access metrics.
626590
- Other field:
627591
- [ ] Other (treat as last resort)
628592
- Details: -->
629-
630593
N/A
631594

632595
###### What are the reasonable SLOs (Service Level Objectives) for the enhancement?
@@ -832,7 +795,7 @@ Major milestones might include:
832795
- when the KEP was retired or superseded
833796
-->
834797

835-
- 2021.01.05: KEP proposed for review, including motivation, proposal, risks,
798+
- 2021.01.12: KEP proposed for review, including motivation, proposal, risks,
836799
test plan and graduation criteria.
837800

838801
## Drawbacks

0 commit comments

Comments
 (0)