From 4fdf46ac2dacc3ee2cba5de6a5ed9eed1ac6386d Mon Sep 17 00:00:00 2001 From: kerthcet Date: Wed, 5 Jan 2022 16:15:53 +0800 Subject: [PATCH] KEP: PodTopoplogySpread considering taints Signed-off-by: kerthcet --- keps/prod-readiness/sig-scheduling/3094.yaml | 3 + .../README.md | 861 ++++++++++++++++++ .../kep.yaml | 47 + 3 files changed, 911 insertions(+) create mode 100644 keps/prod-readiness/sig-scheduling/3094.yaml create mode 100644 keps/sig-scheduling/3094-pod-topology-spread-considering-taints/README.md create mode 100644 keps/sig-scheduling/3094-pod-topology-spread-considering-taints/kep.yaml diff --git a/keps/prod-readiness/sig-scheduling/3094.yaml b/keps/prod-readiness/sig-scheduling/3094.yaml new file mode 100644 index 000000000000..2539f0331643 --- /dev/null +++ b/keps/prod-readiness/sig-scheduling/3094.yaml @@ -0,0 +1,3 @@ +kep-number: 3094 +alpha: + approver: "" diff --git a/keps/sig-scheduling/3094-pod-topology-spread-considering-taints/README.md b/keps/sig-scheduling/3094-pod-topology-spread-considering-taints/README.md new file mode 100644 index 000000000000..c3442e746d92 --- /dev/null +++ b/keps/sig-scheduling/3094-pod-topology-spread-considering-taints/README.md @@ -0,0 +1,861 @@ + +# KEP-3094: Take taints/tolerations into consideration when calculating PodTopologySpread skew + + + + + + +- [Release Signoff Checklist](#release-signoff-checklist) +- [Summary](#summary) +- [Motivation](#motivation) + - [Goals](#goals) + - [Non-Goals](#non-goals) +- [Proposal](#proposal) + - [User Stories (Optional)](#user-stories-optional) + - [Story 1](#story-1) + - [Story 2](#story-2) + - [Notes/Constraints/Caveats (Optional)](#notesconstraintscaveats-optional) + - [Risks and Mitigations](#risks-and-mitigations) +- [Design Details](#design-details) + - [Test Plan](#test-plan) + - [Graduation Criteria](#graduation-criteria) + - [Upgrade / Downgrade Strategy](#upgrade--downgrade-strategy) + - [Version Skew Strategy](#version-skew-strategy) +- [Production Readiness Review Questionnaire](#production-readiness-review-questionnaire) + - [Feature Enablement and Rollback](#feature-enablement-and-rollback) + - [Rollout, Upgrade and Rollback Planning](#rollout-upgrade-and-rollback-planning) + - [Monitoring Requirements](#monitoring-requirements) + - [Dependencies](#dependencies) + - [Scalability](#scalability) + - [Troubleshooting](#troubleshooting) +- [Implementation History](#implementation-history) +- [Drawbacks](#drawbacks) +- [Alternatives](#alternatives) +- [Infrastructure Needed (Optional)](#infrastructure-needed-optional) + + +## Release Signoff Checklist + + + +Items marked with (R) are required *prior to targeting to a milestone / release*. + +- [x] (R) Enhancement issue in release milestone, which links to KEP dir in [kubernetes/enhancements] (not the initial KEP PR) +- [ ] (R) KEP approvers have approved the KEP status as `implementable` +- [x] (R) Design details are appropriately documented +- [x] (R) Test plan is in place, giving consideration to SIG Architecture and SIG Testing input (including test refactors) + - [ ] e2e Tests for all Beta API Operations (endpoints) + - [ ] (R) Ensure GA e2e tests for meet requirements for [Conformance Tests](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/conformance-tests.md) + - [ ] (R) Minimum Two Week Window for GA e2e tests to prove flake free +- [x] (R) Graduation criteria is in place + - [ ] (R) [all GA Endpoints](https://github.com/kubernetes/community/pull/1806) must be hit by [Conformance Tests](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/conformance-tests.md) +- [ ] (R) Production readiness review completed +- [ ] (R) Production readiness review approved +- [x] "Implementation History" section is up-to-date for milestone +- [ ] User-facing documentation has been created in [kubernetes/website], for publication to [kubernetes.io] +- [ ] Supporting documentation—e.g., additional design documents, links to mailing list discussions/SIG meetings, relevant PRs/issues, release notes + + + +[kubernetes.io]: https://kubernetes.io/ +[kubernetes/enhancements]: https://git.k8s.io/enhancements +[kubernetes/kubernetes]: https://git.k8s.io/kubernetes +[kubernetes/website]: https://git.k8s.io/website + +## Summary + + +This KEP introduces a new field as an option for end-users to honor all taints or +only system-generated unschedulable taints when computing pod topology spread skew. +This helps improving the scheduling efficiency by filtering out nodes don't meet the +toleration requirements. + +## Motivation + + +Currently, when we compute pod topology spread skew, we will ignore the impact of +node taints whatever pod tolerates or not, which may lead to some unexpected results. +E.g. node with pod untolerated taints might be the candidate node after computing, +then the pod would be stuck in Pending state. So toleration/taints should be taken into +consideration when computing pod topology spread skew. For backwards compatibility, +we'd like to define this as an option for end-users to honor all taints or +only system-generated unschedulable taints. + +### Goals + + +- Filtering out pod untolerated nodes when computing pod topology spread skew +- Provide an option for end-users to specify whether to honor all taints or +only system-generated unschedulable taints + +### Non-Goals + + +- Refactor or introduce any breaking changes to PodTopologySpread plugin + +## Proposal + + +A new field `TaintStrategy` defined in `TopologySpreadConstraint` will be available for +end-users to specify different strategies about how to treat taints in computing skew. + +### User Stories (Optional) + + + +#### Story 1 +When computing pod topology spread skew, I want to exclude nodes that don't tolerate +all taints to prevent pods from falling into unexpected Pending state. I can simply +configure this by specifying a taintStrategy: + + apiVersion: v1 + kind: Pod + metadata: + name: mypod + spec: + topologySpreadConstraints: + - maxSkew: 1 + topologyKey: zone + whenUnsatisfiable: DoNotSchedule + labelSelector: + matchLabels: + foo: bar + taintStrategy: "honorAllTaints" + +### Notes/Constraints/Caveats (Optional) + + + +### Risks and Mitigations + + + +- Looping all the toleration/taints to filter out unsatisfied nodes may +lead to performance problem. +- Some usual schedulable nodes may become unschedulable, which might be +confusing for end-users. + +## Design Details + + + +A new field named `TaintStrategy` will be introduced to `TopologySpreadConstraint`: + + type TopologySpreadConstraint struct { + MaxSkew int32 + TopologyKey string + WhenUnsatisfiable UnsatisfiableConstraintAction + LabelSelector *metav1.LabelSelector + TaintStrategy taintStrategy + } + +Correspondingly, the internal version for v1.TopologySpreadConstraint named +`topologySpreadConstraint` will also add a `TaintStrategy` field: + + type topologySpreadConstraint struct { + MaxSkew int32 + TopologyKey string + Selector labels.Selector + TaintStrategy taintStrategy + } + +`taintStrategy` is a potential type of `String`, and there are two available options +for users. + +One is `honorAllTaints` which means when computing pod topology spread skew, +all kinds of node taints should be taken into consideration, if any of these taints pod +doesn't tolerate, the node is excluded. + +The other one is `honorUnschedulableTaint`, which means instead of considering all taints +node carried, we only concern about taint `node.kubernetes.io/unschedulable:NoSchedule`. + +This behavior is controlled by feature gate `TaintStrategy`, if this feature gate is on +and `TaintStrategy` doesn't set, `honorAllTaints` will take effect by default. + +We'd like to implement this part of logic before computing skew for code efficiency. + +### Test Plan + + +- Unit and integration tests: + - Defaulting and validation tests + - Feature gate enable/disable tests. + - `TaintStrategy` works as expected +- Benchmark tests: + - Verify the performance of looping all toleration and taints in computing skew is acceptable + +### Graduation Criteria + + +#### Alpha +- Feature implemented behind feature gate. +- Test cases mentioned in Test Plan + +#### Beta +- Feature is enabled by default +- Gather feedback from developers and surveys. +- No performance problem. + +#### GA +- No negative feedback. + +### Upgrade / Downgrade Strategy + + + +- Upgrade + - While the feature gate is disabled, field `TaintStrategy` will be ignored. + - While the feature gate is enabled, `TaintStrategy` provides two optional values + for end-users to specify how to treat node taints. + - While the feature gate is enabled, and we don't set this field, `taintStrategy` of + `honorAllTaints` will take effect by default. +- Downgrade + - Whatever we enable/disable feature gate, previously configured values will + be ignored. + + +### Version Skew Strategy +N/A + + + +## Production Readiness Review Questionnaire + + + +### Feature Enablement and Rollback + + + +###### How can this feature be enabled / disabled in a live cluster? + + + +- [x] Feature gate (also fill in values in `kep.yaml`) + - Feature gate name: TaintStrategy + - Components depending on the feature gate: kube-scheduler, kube-apiserver +- [x] Other + - Describe the mechanism: + + Specify strategy about how to treat taints. + + - Will enabling / disabling the feature require downtime of the control + plane? + + Yes. + + - Will enabling / disabling the feature require downtime or reprovisioning + of a node? (Do not assume `Dynamic Kubelet Config` feature is enabled). + + No. + +###### Does enabling the feature change any default behavior? + + +Yes, some usual schedulable nodes might be unschedulable. + +###### Can the feature be disabled once it has been enabled (i.e. can we roll back the enablement)? + + +Yes. + +###### What happens if we reenable the feature if it was previously rolled back? +N/A. + +###### Are there any tests for feature enablement/disablement? +Yes. + + + +### Rollout, Upgrade and Rollback Planning + + + +###### How can a rollout or rollback fail? Can it impact already running workloads? + + +A malformed configuration will cause the scheduler failing to start. Running workloads are not affected. + +###### What specific metrics should inform a rollback? + + +- A spike on metric schedule_attempts_total{result="error|unschedulable"} when pods using this feature are added. +- Metric plugin_execution_duration_seconds{plugin="PodTopologySpread"} larger than 100ms on 90-percentile. +- A spike on failure events with keyword "failed spreadConstraint" in scheduler log. + +###### Were upgrade and rollback tested? Was the upgrade->downgrade->upgrade path tested? +N/A + + + +###### Is the rollout accompanied by any deprecations and/or removals of features, APIs, fields of API types, flags, etc.? +No + + + +### Monitoring Requirements + + + +###### How can an operator determine if the feature is in use by workloads? + + +Operator can query `pod.spec.topologySpreadConstraints[].taintStrategy` field +and identify if this is set. + +###### How can someone using this feature know that it is working for their instance? + + + + + +N/A + +###### What are the reasonable SLOs (Service Level Objectives) for the enhancement? + + + +- Metric plugin_execution_duration_seconds{plugin="PodTopologySpread"} <= 100ms on 90-percentile. +- Frequency of critical error keywords <= 2 times per minute. +- Frequency of regular scheduling failures < 10 times per minute. + +###### What are the SLIs (Service Level Indicators) an operator can use to determine the health of the service? + + + + + +- Metric plugin_execution_duration_seconds{plugin="PodTopologySpread"} to indicate the scheduling latency for a pod using this feature. +- Frequency of critical error keywords in scheduler log: + - "PreFilterPodTopologySpread" + - "convert to podtopologyspread.preFilterState error" + - "hard topology spread constraints" + - "internal error: get paths from key" +- Frequency of regular scheduling failures (with keyword "failed spreadConstraint") in scheduler log. + +###### Are there any missing metrics that would be useful to have to improve observability of this feature? + + +N/A + +### Dependencies + + + +###### Does this feature depend on any specific services running in the cluster? + + +No + +### Scalability + + +No + +###### Will enabling / using this feature result in any new API calls? + + +No + +###### Will enabling / using this feature result in introducing new API types? + + +No + +###### Will enabling / using this feature result in any new calls to the cloud provider? + + +No + +###### Will enabling / using this feature result in increasing size or count of the existing API objects? + + +No + +###### Will enabling / using this feature result in increasing time taken by any operations covered by existing SLIs/SLOs? + + +No + +###### Will enabling / using this feature result in non-negligible increase of resource usage (CPU, RAM, disk, IO, ...) in any components? + + +No + +### Troubleshooting + + + +###### How does this feature react if the API server and/or etcd is unavailable? +N/A + +###### What are other known failure modes? + + + +Configuration errors are logged to stderr. + +###### What steps should be taken if SLOs are not being met to determine the problem? +N/A + +## Implementation History + + + +- 2021.01.05: KEP proposed for review, including motivation, proposal, risks, +test plan and graduation criteria. + +## Drawbacks + + +N/A + +## Alternatives + + +N/A + +## Infrastructure Needed (Optional) + + +N/A diff --git a/keps/sig-scheduling/3094-pod-topology-spread-considering-taints/kep.yaml b/keps/sig-scheduling/3094-pod-topology-spread-considering-taints/kep.yaml new file mode 100644 index 000000000000..00b0efd3487f --- /dev/null +++ b/keps/sig-scheduling/3094-pod-topology-spread-considering-taints/kep.yaml @@ -0,0 +1,47 @@ +title: Take taints/tolerations into consideration when calculating PodTopologySpread skew +kep-number: 3094 +authors: + - "@kerthcet" +owning-sig: sig-scheduling +participating-sigs: +status: implementable +creation-date: 2021-12-30 +reviewers: + - TBD +approvers: + - TBD + +see-also: + - "/keps/sig-scheduling/895-pod-topology-spread" + - "/keps/sig-scheduling/1258-default-pod-topology-spread" + +##### WARNING !!! ###### +# prr-approvers has been moved to its own location +# You should create your own in keps/prod-readiness +# Please make a copy of keps/prod-readiness/template/nnnn.yaml +# to keps/prod-readiness/sig-xxxxx/00000.yaml (replace with kep number) +#prr-approvers: + +# The target maturity stage in the current dev cycle for this KEP. +stage: alpha + +# The most recent milestone for which work toward delivery of this KEP has been +# done. This can be the current (upcoming) milestone, if it is being actively +# worked on. +latest-milestone: "v1.24" + +# The milestone at which this feature was, or is targeted to be, at each stage. +milestone: + alpha: "v1.24" + beta: "v1.25" + stable: "v1.26" + +# The following PRR answers are required at alpha release +# List the feature gate name and the components for which it must be enabled +feature-gates: + - name: TaintStrategy + components: + - kube-apiserver + - kube-scheduler + +disable-supported: false