Skip to content

Commit 74642f9

Browse files
committed
fix6
1 parent 688ecc1 commit 74642f9

File tree

1 file changed

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

1 file changed

+20
-14
lines changed

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

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ tags, and then generate with `hack/update-toc.sh`.
8888
- [Notes/Constraints/Caveats (Optional)](#notesconstraintscaveats-optional)
8989
- [Risks and Mitigations](#risks-and-mitigations)
9090
- [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)
9292
- [Design Details](#design-details)
9393
- [[v1.33] design change and a safe upgrade path](#v133-design-change-and-a-safe-upgrade-path)
9494
- [Test Plan](#test-plan)
@@ -184,11 +184,13 @@ which spreading is applied using a LabelSelector. This means the user should
184184
know the exact label key and value when defining the pod spec.
185185

186186
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
190190
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+
192194

193195
The main case that this new way for identifying pods will enable is constraining
194196
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
305307
which pods should be grouped. If so, the user needs to ensure that it is
306308
correct and not duplicated with other unrelated workloads.
307309

308-
#### the update to labels specified at `matchLabelKeys` isn't supported
310+
#### The update to labels specified at `matchLabelKeys` isn't supported
309311

310312
`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
312314
could update the label that is specified at `matchLabelKeys` after a pod's creation.
313315
So, in such cases, the update of the label isn't reflected onto the merged `LabelSelector`,
314316
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.
316318

317319
Also, we assume the risk is acceptably low because:
318320
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:
321323
there's usually only a tiny moment between the pod creation and the pod getting scheduled, which makes this risk further rarer to happen,
322324
unless many pods are often getting stuck being unschedulable for a long time in the cluster (which is not recommended)
323325
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.
327330

328331
## Design Details
329332

@@ -395,7 +398,8 @@ kube-apiserver modifies the `labelSelector` like the following:
395398
- app
396399
```
397400

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).
399403

400404
Finally, the feature will be guarded by a new feature flag. If the feature is
401405
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.
10821086
Technically, we can implement this feature within the PodTopologySpread plugin only;
10831087
merging the key-value labels corresponding to `MatchLabelKeys` into `LabelSelector` internally
10841088
within the plugin before calculating the scheduling results.
1089+
This is the actual implementation up to 1.32.
10851090
But, it may confuse users because this behavior would be different from PodAffinity's `MatchLabelKeys`.
10861091

10871092
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).
10891095

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
10911097
the PodTopologySpread plugin and kube-apiserver.
10921098
Although the final design has a downside requiring us to maintain two implementations handling `MatchLabelKeys`,
10931099
each implementation is simple and we regard the risk of increased maintenance overhead as fairly low.

0 commit comments

Comments
 (0)