@@ -88,7 +88,7 @@ tags, and then generate with `hack/update-toc.sh`.
88
88
- [ Notes/Constraints/Caveats (Optional)] ( #notesconstraintscaveats-optional )
89
89
- [ Risks and Mitigations] ( #risks-and-mitigations )
90
90
- [ Possible misuse] ( #possible-misuse )
91
- - [ the update to labels specified at <code >matchLabelKeys</code > isn't supported] ( #the-update-to-labels-specified-at-matchlabelkeys-isnt-supported )
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
93
- [[ v1.33] design change and a safe upgrade path] ( #v133-design-change-and-a-safe-upgrade-path )
94
94
- [ Test Plan] ( #test-plan )
@@ -184,11 +184,13 @@ which spreading is applied using a LabelSelector. This means the user should
184
184
know the exact label key and value when defining the pod spec.
185
185
186
186
This KEP proposes a complementary field to LabelSelector named ` MatchLabelKeys ` in
187
- ` TopologySpreadConstraint ` which represent a set of label keys only.
188
- kube-apiserver will use those keys to look up label values from the incoming pod
189
- and those key-value labels are ANDed with ` LabelSelector ` to identify the group of existing pods over
187
+ ` TopologySpreadConstraint ` which represents a set of label keys only.
188
+ At a pod creation, kube-apiserver will use those keys to look up label values from the incoming pod
189
+ and those key-value labels will be merged with existing ` LabelSelector ` to identify the group of existing pods over
190
190
which the spreading skew will be calculated.
191
- kube-scheduler will also handle it if the cluster-level default constraints have the one with ` MatchLabelKeys ` .
191
+ Note that in case ` MatchLabelKeys ` is supported in the cluster-level default constraints
192
+ (see https://github.com/kubernetes/kubernetes/issues/129198 ), kube-scheduler will also handle it separately.
193
+
192
194
193
195
The main case that this new way for identifying pods will enable is constraining
194
196
skew spreading calculation to happen at the revision level in Deployments during
@@ -305,14 +307,14 @@ users can also provide the customized key in `MatchLabelKeys` to identify
305
307
which pods should be grouped. If so, the user needs to ensure that it is
306
308
correct and not duplicated with other unrelated workloads.
307
309
308
- #### the update to labels specified at ` matchLabelKeys ` isn't supported
310
+ #### The update to labels specified at ` matchLabelKeys ` isn't supported
309
311
310
312
` MatchLabelKeys ` is handled and merged into ` LabelSelector ` at _ a pod's creation_ .
311
- It means this feature doesn't support the label's update even though users, of course,
313
+ It means this feature doesn't support the label's update even though a user
312
314
could update the label that is specified at ` matchLabelKeys ` after a pod's creation.
313
315
So, in such cases, the update of the label isn't reflected onto the merged ` LabelSelector ` ,
314
316
even though users might expect it to be.
315
- On the documentation, we'll declare it's not recommended using ` matchLabelKeys ` with labels that is frequently updated.
317
+ On the documentation, we'll declare it's not recommended to use ` matchLabelKeys ` with labels that might be updated.
316
318
317
319
Also, we assume the risk is acceptably low because:
318
320
1 . It's a fairly low probability to happen because pods are usually managed by another resource (e.g., deployment),
@@ -321,9 +323,10 @@ Also, we assume the risk is acceptably low because:
321
323
there's usually only a tiny moment between the pod creation and the pod getting scheduled, which makes this risk further rarer to happen,
322
324
unless many pods are often getting stuck being unschedulable for a long time in the cluster (which is not recommended)
323
325
or the labels specified at ` matchLabelKeys ` are frequently updated (which we'll declare as not recommended).
324
- 2 . Even if it happens, the topology spread on the pod is just ignored (since ` labelSelector ` no longer matches the pod itself)
325
- and the pod could still be schedulable.
326
- It's not that the unfortunate pods would be unschedulable forever.
326
+ 2 . If it happens, ` selfMatchNum ` will be 0 and both ` matchNum ` and ` minMatchNum ` will be retained.
327
+ Consequently, depending on the current number of matching pods in the domain, ` matchNum ` - ` minMatchNum ` might be bigger than ` maxSkew ` ,
328
+ and the node(s) could be unschedulable.
329
+ But, it does not mean that the unfortunate pods would be unschedulable forever.
327
330
328
331
## Design Details
329
332
@@ -395,7 +398,8 @@ kube-apiserver modifies the `labelSelector` like the following:
395
398
- app
396
399
` ` `
397
400
398
- In addition, kube-scheduler handles `matchLabelKeys` if the cluster-level default constraints is configured with `matchLabelKeys`.
401
+ In addition, kube-scheduler handles `matchLabelKeys` within the cluster-level default constraints
402
+ in the scheduler configuration in the future (see https://github.com/kubernetes/kubernetes/issues/129198).
399
403
400
404
Finally, the feature will be guarded by a new feature flag. If the feature is
401
405
disabled, the field `matchLabelKeys` and corresponding `labelSelector` are preserved
@@ -1082,12 +1086,14 @@ and scheduler plugin shouldn't have special treatment for any labels/fields.
1082
1086
Technically, we can implement this feature within the PodTopologySpread plugin only;
1083
1087
merging the key-value labels corresponding to `MatchLabelKeys` into `LabelSelector` internally
1084
1088
within the plugin before calculating the scheduling results.
1089
+ This is the actual implementation up to 1.32.
1085
1090
But, it may confuse users because this behavior would be different from PodAffinity's `MatchLabelKeys`.
1086
1091
1087
1092
Also, we cannot implement this feature only within kube-apiserver because it'd make it
1088
- impossible to handle `MatchLabelKeys` within the cluster-level default constraints in the scheduler configuration.
1093
+ impossible to handle `MatchLabelKeys` within the cluster-level default constraints
1094
+ in the scheduler configuration in the future (see https://github.com/kubernetes/kubernetes/issues/129198).
1089
1095
1090
- So we decided to go with the current design that implements this feature within both
1096
+ So we decided to go with the design that implements this feature within both
1091
1097
the PodTopologySpread plugin and kube-apiserver.
1092
1098
Although the final design has a downside requiring us to maintain two implementations handling `MatchLabelKeys`,
1093
1099
each implementation is simple and we regard the risk of increased maintenance overhead as fairly low.
0 commit comments