Skip to content

Commit 119b531

Browse files
authored
Merge pull request #5205 from mochizuki875/kep-3243-add-MatchLabelKeysInPodTopologySpreadMutation-featuregate
KEP-3243: Update milestone v1.33 to v1.34 and add the new feature gate to control the design change of TopologySpreadConstraint's matchLabelKeys
2 parents a9bb7b3 + d0e225c commit 119b531

File tree

2 files changed

+43
-13
lines changed
  • keps/sig-scheduling/3243-respect-pod-topology-spread-after-rolling-upgrades

2 files changed

+43
-13
lines changed

keps/sig-scheduling/3243-respect-pod-topology-spread-after-rolling-upgrades/README.md

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ tags, and then generate with `hack/update-toc.sh`.
9090
- [Possible misuse](#possible-misuse)
9191
- [The update to labels specified at <code>matchLabelKeys</code> isn't supported](#the-update-to-labels-specified-at-matchlabelkeys-isnt-supported)
9292
- [Design Details](#design-details)
93-
- [[v1.33] design change and a safe upgrade path](#v133-design-change-and-a-safe-upgrade-path)
93+
- [[v1.34] design change and a safe upgrade path](#v134-design-change-and-a-safe-upgrade-path)
9494
- [Test Plan](#test-plan)
9595
- [Prerequisite testing updates](#prerequisite-testing-updates)
9696
- [Unit tests](#unit-tests)
@@ -401,25 +401,29 @@ kube-apiserver modifies the `labelSelector` like the following:
401401
In addition, kube-scheduler will handle `matchLabelKeys` within the cluster-level default constraints
402402
in the scheduler configuration in the future (see https://github.com/kubernetes/kubernetes/issues/129198).
403403

404-
Finally, the feature will be guarded by a new feature flag. If the feature is
404+
Finally, the feature will be guarded by a new feature flag `MatchLabelKeysInPodTopologySpread`. If the feature is
405405
disabled, the field `matchLabelKeys` and corresponding `labelSelector` are preserved
406406
if it was already set in the persisted Pod object, otherwise new Pod with the field
407407
creation will be rejected by kube-apiserver.
408408
Also kube-scheduler will ignore `matchLabelKeys` in the cluster-level default constraints configuration.
409409

410-
### [v1.33] design change and a safe upgrade path
410+
### [v1.34] design change and a safe upgrade path
411411
Previously, kube-scheduler just internally handled `matchLabelKeys` before the calculation of scheduling results.
412412
But, we changed the implementation design to the current form to make the design align with PodAffinity's `matchLabelKeys`.
413413
(See the detailed discussion in [the alternative section](#implement-matchlabelkeys-in-only-either-the-scheduler-plugin-or-kube-apiserver))
414414

415415
However, this implementation change could break `matchLabelKeys` of unscheduled pods created before the upgrade
416416
because kube-apiserver only handles `matchLabelKeys` at pods creation, that is,
417417
it doesn't handle `matchLabelKeys` at existing unscheduled pods.
418-
So, for a safe upgrade path from v1.32 to v1.33, kube-scheduler would handle not only `matchLabelKeys`
419-
from the default constraints, but also all incoming pods during v1.33.
420-
We're going to change kube-scheduler to only concern `matchLabelKeys` from the default constraints at v1.34 for efficiency,
418+
So, for a safe upgrade path from v1.33 to v1.34, kube-scheduler would handle not only `matchLabelKeys`
419+
from the default constraints, but also all incoming pods during v1.34.
420+
We're going to change kube-scheduler to only concern `matchLabelKeys` from the default constraints at v1.35 for efficiency,
421421
assuming kube-apiserver handles `matchLabelKeys` of all incoming pods.
422422

423+
Also, in case of bugs in this new design, users can disable this feature through a new feature flag,
424+
`MatchLabelKeysInPodTopologySpreadSelectorMerge` (enabled by default).
425+
(See more details in [Feature Enablement and Rollback](#feature-enablement-and-rollback))
426+
423427
### Test Plan
424428

425429
<!--
@@ -619,8 +623,8 @@ enhancement:
619623

620624
There's no version skew issue.
621625

622-
We changed the implementation design between v1.33 and v1.34, but we designed the change not to involve any version skew issue
623-
as described at [[v1.33] design change and a safe upgrade path](#v133-design-change-and-a-safe-upgrade-path).
626+
We changed the implementation design between v1.34 and v1.35, but we designed the change not to involve any version skew issue
627+
as described at [[v1.34] design change and a safe upgrade path](#v134-design-change-and-a-safe-upgrade-path).
624628

625629
## Production Readiness Review Questionnaire
626630

@@ -652,6 +656,19 @@ you need any help or guidance.
652656
This section must be completed when targeting alpha to a release.
653657
-->
654658

659+
- `MatchLabelKeysInPodTopologySpread` feature flag enables the `MatchLabelKeys` feature in `TopologySpreadConstraint`.
660+
- `MatchLabelKeysInPodTopologySpreadSelectorMerge` feature flag enables the new design described at
661+
[[v1.34] design change and a safe upgrade path](#v134-design-change-and-a-safe-upgrade-path).
662+
- If `MatchLabelKeysInPodTopologySpreadSelectorMerge` is disabled while `MatchLabelKeysInPodTopologySpread` is enabled,
663+
Kubernetes handles `MatchLabelKeys` with the classic design, kube-scheduler handles it.
664+
However, that's basically not recommended unless you encounter a bug in a new design behavior.
665+
- This flag cannot be enabled on its own, and has to be enabled together with `MatchLabelKeysInPodTopologySpread`.
666+
Enabling `MatchLabelKeysInPodTopologySpreadSelectorMerge` alone has no effect, and `matchLabelKeys` will be ignored.
667+
668+
The `MatchLabelKeysInPodTopologySpreadSelectorMerge` feature flag has been added in v1.34 and enabled by default.
669+
This flag can be disabled to revert [the implementation design change in v1.34](#v134-design-change-and-a-safe-upgrade-path)
670+
and go back to the previous behavior in case of bug.
671+
655672
###### How can this feature be enabled / disabled in a live cluster?
656673

657674
<!--
@@ -667,6 +684,9 @@ well as the [existing list] of feature gates.
667684
- [x] Feature gate (also fill in values in `kep.yaml`)
668685
- Feature gate name: `MatchLabelKeysInPodTopologySpread`
669686
- Components depending on the feature gate: `kube-scheduler`, `kube-apiserver`
687+
- [x] Feature gate (also fill in values in `kep.yaml`)
688+
- Feature gate name: `MatchLabelKeysInPodTopologySpreadSelectorMerge`
689+
- Components depending on the feature gate: `kube-apiserver`
670690

671691
###### Does enabling the feature change any default behavior?
672692

@@ -877,8 +897,8 @@ Pick one more of these and delete the rest.
877897
Describe the metrics themselves and the reasons why they weren't added (e.g., cost,
878898
implementation difficulties, etc.).
879899
-->
880-
Yes. It's helpful if we have the metrics to see which plugins affect to scheduler's decisions in Filter/Score phase.
881-
There is the related issue: https://github.com/kubernetes/kubernetes/issues/110643 . It's very big and still on the way.
900+
Yes, [there were](https://github.com/kubernetes/kubernetes/issues/110643), and it's been implemented in
901+
[#115082](https://github.com/kubernetes/kubernetes/pull/115082) and [#118025](https://github.com/kubernetes/kubernetes/pull/118025).
882902

883903
### Dependencies
884904

@@ -1061,6 +1081,7 @@ Major milestones might include:
10611081
- 2022-06-08: KEP merged
10621082
- 2023-01-16: Graduate to Beta
10631083
- 2025-01-23: Change the implementation design to be aligned with PodAffinity's `matchLabelKeys`
1084+
- 2025-04-07: Add a new feature flag `MatchLabelKeysInPodTopologySpreadSelectorMerge` and update milestone
10641085

10651086
## Drawbacks
10661087

@@ -1086,7 +1107,7 @@ and scheduler plugin shouldn't have special treatment for any labels/fields.
10861107
Technically, we can implement this feature within the PodTopologySpread plugin only;
10871108
merging the key-value labels corresponding to `MatchLabelKeys` into `LabelSelector` internally
10881109
within the plugin before calculating the scheduling results.
1089-
This is the actual implementation up to 1.32.
1110+
This is the actual implementation up to 1.33.
10901111
But, it may confuse users because this behavior would be different from PodAffinity's `MatchLabelKeys`.
10911112

10921113
Also, we cannot implement this feature only within kube-apiserver because it'd make it

keps/sig-scheduling/3243-respect-pod-topology-spread-after-rolling-upgrades/kep.yaml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,14 @@ status: implementable
77
creation-date: 2022-03-17
88
reviewers:
99
- "@ahg-g"
10+
- "@sanposhiho"
11+
- "@macsko"
12+
- "@dom4ha"
1013
approvers:
1114
- "@ahg-g"
15+
- "@sanposhiho"
16+
- "@macsko"
17+
- "@dom4ha"
1218

1319
see-also:
1420
- "/keps/sig-scheduling/895-pod-topology-spread"
@@ -22,13 +28,13 @@ stage: beta
2228
# The most recent milestone for which work toward delivery of this KEP has been
2329
# done. This can be the current (upcoming) milestone, if it is being actively
2430
# worked on.
25-
latest-milestone: "v1.33"
31+
latest-milestone: "v1.34"
2632

2733
# The milestone at which this feature was, or is targeted to be, at each stage.
2834
milestone:
2935
alpha: "v1.25"
3036
beta: "v1.27"
31-
stable: "v1.35"
37+
stable: "v1.36"
3238

3339
# The following PRR answers are required at alpha release
3440
# List the feature gate name and the components for which it must be enabled
@@ -37,6 +43,9 @@ feature-gates:
3743
components:
3844
- kube-apiserver
3945
- kube-scheduler
46+
- name: MatchLabelKeysInPodTopologySpreadSelectorMerge
47+
components:
48+
- kube-apiserver
4049

4150
disable-supported: true
4251

0 commit comments

Comments
 (0)