@@ -90,7 +90,7 @@ tags, and then generate with `hack/update-toc.sh`.
90
90
- [ Possible misuse] ( #possible-misuse )
91
91
- [ The update to labels specified at <code >matchLabelKeys</code > isn't supported] ( #the-update-to-labels-specified-at-matchlabelkeys-isnt-supported )
92
92
- [ 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 )
94
94
- [ Test Plan] ( #test-plan )
95
95
- [ Prerequisite testing updates] ( #prerequisite-testing-updates )
96
96
- [ Unit tests] ( #unit-tests )
@@ -401,25 +401,29 @@ kube-apiserver modifies the `labelSelector` like the following:
401
401
In addition, kube-scheduler will handle `matchLabelKeys` within the cluster-level default constraints
402
402
in the scheduler configuration in the future (see https://github.com/kubernetes/kubernetes/issues/129198).
403
403
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
405
405
disabled, the field `matchLabelKeys` and corresponding `labelSelector` are preserved
406
406
if it was already set in the persisted Pod object, otherwise new Pod with the field
407
407
creation will be rejected by kube-apiserver.
408
408
Also kube-scheduler will ignore `matchLabelKeys` in the cluster-level default constraints configuration.
409
409
410
- # ## [v1.33 ] design change and a safe upgrade path
410
+ # ## [v1.34 ] design change and a safe upgrade path
411
411
Previously, kube-scheduler just internally handled `matchLabelKeys` before the calculation of scheduling results.
412
412
But, we changed the implementation design to the current form to make the design align with PodAffinity's `matchLabelKeys`.
413
413
(See the detailed discussion in [the alternative section](#implement-matchlabelkeys-in-only-either-the-scheduler-plugin-or-kube-apiserver))
414
414
415
415
However, this implementation change could break `matchLabelKeys` of unscheduled pods created before the upgrade
416
416
because kube-apiserver only handles `matchLabelKeys` at pods creation, that is,
417
417
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,
421
421
assuming kube-apiserver handles `matchLabelKeys` of all incoming pods.
422
422
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
+
423
427
# ## Test Plan
424
428
425
429
<!--
@@ -619,8 +623,8 @@ enhancement:
619
623
620
624
There's no version skew issue.
621
625
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).
624
628
625
629
# # Production Readiness Review Questionnaire
626
630
@@ -652,6 +656,19 @@ you need any help or guidance.
652
656
This section must be completed when targeting alpha to a release.
653
657
-->
654
658
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
+
655
672
# ##### How can this feature be enabled / disabled in a live cluster?
656
673
657
674
<!--
@@ -667,6 +684,9 @@ well as the [existing list] of feature gates.
667
684
- [x] Feature gate (also fill in values in `kep.yaml`)
668
685
- Feature gate name : ` MatchLabelKeysInPodTopologySpread`
669
686
- 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`
670
690
671
691
# ##### Does enabling the feature change any default behavior?
672
692
@@ -877,8 +897,8 @@ Pick one more of these and delete the rest.
877
897
Describe the metrics themselves and the reasons why they weren't added (e.g., cost,
878
898
implementation difficulties, etc.).
879
899
-->
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) .
882
902
883
903
# ## Dependencies
884
904
@@ -1061,6 +1081,7 @@ Major milestones might include:
1061
1081
- 2022-06-08 : KEP merged
1062
1082
- 2023-01-16 : Graduate to Beta
1063
1083
- 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
1064
1085
1065
1086
# # Drawbacks
1066
1087
@@ -1086,7 +1107,7 @@ and scheduler plugin shouldn't have special treatment for any labels/fields.
1086
1107
Technically, we can implement this feature within the PodTopologySpread plugin only;
1087
1108
merging the key-value labels corresponding to `MatchLabelKeys` into `LabelSelector` internally
1088
1109
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 .
1090
1111
But, it may confuse users because this behavior would be different from PodAffinity's `MatchLabelKeys`.
1091
1112
1092
1113
Also, we cannot implement this feature only within kube-apiserver because it'd make it
0 commit comments