Skip to content

Update the description of PodTopologySpread matchLabelKeys implementation change since v1.34 #51119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: dev-1.34
Choose a base branch
from

Conversation

mochizuki875
Copy link
Member

@k8s-ci-robot k8s-ci-robot added this to the 1.34 milestone May 30, 2025
Copy link

netlify bot commented May 30, 2025

👷 Deploy Preview for kubernetes-io-vnext-staging processing.

Name Link
🔨 Latest commit 8ad8c10
🔍 Latest deploy log https://app.netlify.com/projects/kubernetes-io-vnext-staging/deploys/686cca6142132b00080d41d2

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 30, 2025
@k8s-ci-robot k8s-ci-robot requested a review from drewhagen May 30, 2025 18:03
@k8s-ci-robot k8s-ci-robot added the language/en Issues or PRs related to English language label May 30, 2025
@k8s-ci-robot k8s-ci-robot requested a review from reylejano May 30, 2025 18:03
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label May 30, 2025
Copy link
Contributor

@lmktfy lmktfy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 30, 2025
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 3198ef123f30040fafb95be0d9458712dcd744c0

Copy link

netlify bot commented May 30, 2025

Pull request preview available for checking

Built without sensitive environment variables

Name Link
🔨 Latest commit 8ad8c10
🔍 Latest deploy log https://app.netlify.com/projects/kubernetes-io-main-staging/deploys/686cca61dbfb9b000825a87f
😎 Deploy Preview https://deploy-preview-51119--kubernetes-io-main-staging.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 31, 2025
@k8s-ci-robot k8s-ci-robot requested a review from lmktfy May 31, 2025 16:43
Copy link
Contributor

@lmktfy lmktfy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for docs

@lmktfy
Copy link
Contributor

lmktfy commented Jun 1, 2025

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 1, 2025
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: e0ce9afeec7c3ac1f968ddee7ba4662e2a0e9c81

@divya-mohan0209
Copy link
Contributor

/sig scheduling

@k8s-ci-robot k8s-ci-robot added the sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. label Jun 15, 2025
@github-project-automation github-project-automation bot moved this to Needs Triage in SIG Scheduling Jun 15, 2025
@divya-mohan0209
Copy link
Contributor

@kubernetes/sig-scheduling-leads PTAL and advise on tech accuracy.

Copy link
Member

@sanposhiho sanposhiho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

two nits

fromVersion: "1.34"
---
Enable merging of selectors built from `matchLabelKeys` into `labelSelector` of
[Pod topology spread constraints](/docs/concepts/scheduling-eviction/topology-spread-constraints/).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feature gate can be enabled when matchLabelKeys feature is enabled with the MatchLabelKeysInPodTopologySpread feature flag.

@@ -162,6 +169,11 @@ your cluster. Those fields are:
{{< note >}}
The `matchLabelKeys` field is a beta-level field and enabled by default in 1.27. You can disable it by disabling the
`MatchLabelKeysInPodTopologySpread` [feature gate](/docs/reference/command-line-tools-reference/feature-gates/).

Before v1.34, kube-scheduler just internally handled `matchLabelKeys` before the calculation of scheduling results.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: kube-scheduler didn't handle it before the calculation, it did handle it during the calculation.

Suggested change
Before v1.34, kube-scheduler just internally handled `matchLabelKeys` before the calculation of scheduling results.
Before v1.34, kube-scheduler just internally handled `matchLabelKeys` and calculating scheduling results.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sanposhiho
That's absolutely true.
BTW, is "calculated" more appropriate than "calculating" in terms of grammar?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 20, 2025
@k8s-ci-robot k8s-ci-robot requested a review from lmktfy June 20, 2025 16:14
@k8s-ci-robot
Copy link
Contributor

New changes are detected. LGTM label has been removed.

@@ -170,7 +170,7 @@ your cluster. Those fields are:
The `matchLabelKeys` field is a beta-level field and enabled by default in 1.27. You can disable it by disabling the
`MatchLabelKeysInPodTopologySpread` [feature gate](/docs/reference/command-line-tools-reference/feature-gates/).

Before v1.34, kube-scheduler just internally handled `matchLabelKeys` before the calculation of scheduling results.
Before v1.34, kube-scheduler just internally handled `matchLabelKeys` and calculated scheduling results.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tengqm
It's to align with PodAffinity's matchLabelKeys and described in KEP-3243.
However should we describe it here too?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So .... there used to be a strict order but starting from 1.34, the ordering has been relaxed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In terms of the function of matchLabelKeys, which is a list of pod label keys that pod spreading is calculated based on, the strength of constraints hasn't changed between v1.33 and v1.34.

In the case of PodAffinity's matchLabelKeys, key-value labels corresponding to matchLabelKeys are explicitly merged into LabelSelector by apiserver, and scheduler handles them.
On the other hand, in the case of TopologySpreadConstraints prior to v1.34, matchLabelKeys are directly handled by scheduler and key-value labels corresponding to matchLabelKeys are not merged into LabelSelector.

From v1.34, key-value labels are merged into LabelSelector as PodAffinity(as described here), but the function of matchLabelKeys does not change or become stricter.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mochizuki875 Do you mean that the user perceivable behavior has not changed? In other words, users don't need to care about this level of implementation details?

Copy link
Member Author

@mochizuki875 mochizuki875 Jun 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tengqm
Hmm, the behavior itself(scheduling calculation logic of matchLabelKeys) has not change.
So I think users don't need to care about it so much.
It only changes how it appears to the user; whether labelSelectors built from matchLabelKeys are visible in podSpec(e.g. The result of kubectl get pod xxx -o yaml).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the clarification, @mochizuki875. Can we then focus on the user-perceivable changes rather than forcing the users to understand the implementation details?
If users don't need to care about it, maybe we can remove all the relevant texts to avoid confusion?

Copy link
Member

@sanposhiho sanposhiho Jun 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's "users" you are saying? I mean, if it's end users who just uses K8s cluster that whoever provisioned, then they shouldn't have to know about this detail. But, if you mean "users" equals cluster admins, then they might want to know it. Because they might observe some unintended behavior from this change (of course, hopefully not though). Note that we introduced this feature flag for those cases.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. Then I'd suggest that we focus on the user-perceivable (behavior) changes.
Changing from

Before v1.34, kube-scheduler just internally handled matchLabelKeys before the calculation of scheduling results.

to

Before v1.34, kube-scheduler just internally handled matchLabelKeys and calculated scheduling results.

doesn't help clarify what the users need/want to know.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tengqm
If we focus on behavior as perceived by end users, I think we should only refer to whether labelSelectors built from matchLabelKeys are visible in podSpec or not.
So how about this:

Before v1.34, matchLabelKeys was handled implicitly.
Since v1.34, key-value labels corresponding to matchLabelKeys are explicitly merged into labelSelector.

@mochizuki875 mochizuki875 force-pushed the design_change_of_podtopologyspread_matchlablkeys branch from da6f099 to 525fb22 Compare July 8, 2025 07:03
@k8s-ci-robot k8s-ci-robot added area/blog Issues or PRs related to the Kubernetes Blog subproject area/localization General issues or PRs related to localization area/web-development Issues or PRs related to the kubernetes.io's infrastructure, design, or build processes language/bn Issues or PRs related to Bengali language language/fr Issues or PRs related to French language language/id Issues or PRs related to Indonesian language language/ja Issues or PRs related to Japanese language language/pt Issues or PRs related to Portuguese language language/zh Issues or PRs related to Chinese language sig/docs Categorizes an issue or PR as relevant to SIG Docs. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 8, 2025
@mochizuki875 mochizuki875 force-pushed the design_change_of_podtopologyspread_matchlablkeys branch from 525fb22 to 4a09bb7 Compare July 8, 2025 07:04
@mochizuki875 mochizuki875 force-pushed the design_change_of_podtopologyspread_matchlablkeys branch from 2167fb7 to 8ad8c10 Compare July 8, 2025 07:35
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from lmktfy. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jul 8, 2025
@t-inu
Copy link
Member

t-inu commented Jul 13, 2025

/remove-language bn fr id ja pt zh
/remove-area blog localization web-development

@k8s-ci-robot k8s-ci-robot removed language/bn Issues or PRs related to Bengali language language/fr Issues or PRs related to French language language/id Issues or PRs related to Indonesian language language/ja Issues or PRs related to Japanese language language/pt Issues or PRs related to Portuguese language language/zh Issues or PRs related to Chinese language area/blog Issues or PRs related to the Kubernetes Blog subproject area/localization General issues or PRs related to localization area/web-development Issues or PRs related to the kubernetes.io's infrastructure, design, or build processes labels Jul 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. language/en Issues or PRs related to English language sig/docs Categorizes an issue or PR as relevant to SIG Docs. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
Status: Needs Triage
Development

Successfully merging this pull request may close these issues.

7 participants