Skip to content
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

support namespace indexer for namespaced resources like pods #121906

Merged
merged 1 commit into from Dec 13, 2023

Conversation

ahutsunshine
Copy link
Contributor

@ahutsunshine ahutsunshine commented Nov 15, 2023

What type of PR is this?

/kind feature

What this PR does / why we need it:

In our cluster, the number of some resources like pods are very large(10w+). When listing a namespace resources like pods from apiserver cache, the apiserver process will firstly get all the resources in all the namespaces and then filter the resources by namespace predicate even it's a very small request. It's heavy for filtering namespaced resource even the resource number in the namespace is very small with many client requests. It consumes lots of cpu & memory that's not expected.

Which issue(s) this PR fixes:

feature support and discussion: #120778

NONE

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. kind/feature Categorizes issue or PR as related to a new feature. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Nov 15, 2023
Copy link

linux-foundation-easycla bot commented Nov 15, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: ahutsunshine / name: ahutsunshine (d8bd150)

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Nov 15, 2023
@k8s-ci-robot
Copy link
Contributor

Welcome @ahutsunshine!

It looks like this is your first PR to kubernetes/kubernetes 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/kubernetes has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Nov 15, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @ahutsunshine. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added needs-priority Indicates a PR lacks a `priority/foo` label and requires one. area/apiserver sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/node Categorizes an issue or PR as relevant to SIG Node. sig/storage Categorizes an issue or PR as relevant to SIG Storage. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Nov 15, 2023
@HirazawaUi
Copy link
Contributor

If we need to add a feature gate, kep is a good place to start, but before we do that, I want to know if we really need it

@ahutsunshine
Copy link
Contributor Author

@HirazawaUi We do a benchmark and see perfect performance to improve latency&cpu&memory. I proposal this because listing the pods across various namespaces significantly impacts CPU and memory resources and causes the incidents in our production. You can check more #120778 and we can discuss the feature/enhancements.

@bart0sh
Copy link
Contributor

bart0sh commented Nov 24, 2023

Thank you for your PR. Please sign the CLA to proceed further, thanks.

@bart0sh bart0sh moved this from Triage to Waiting on Author in SIG Node PR Triage Nov 24, 2023
@halfcrazy
Copy link
Contributor

The namespace indexer only adds to some in-tree resources. Could this work for custom resources as well?

@wojtek-t wojtek-t self-assigned this Nov 28, 2023
@jiahuif
Copy link
Member

jiahuif commented Nov 28, 2023

Also, pinging for CLA.
/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Nov 28, 2023
@ahutsunshine
Copy link
Contributor Author

@wojtek-t @halfcrazy pls go ahead to review

@ahutsunshine ahutsunshine force-pushed the namespace-indexer branch 3 times, most recently from 0eacdd6 to 421519d Compare November 30, 2023 09:00
Copy link
Member

@wojtek-t wojtek-t left a comment

Choose a reason for hiding this comment

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

Just one minor nit - other than that LGTM.

@wojtek-t
Copy link
Member

LGTM - please squash the commits and I will approve.

fix comments

optimize code

small optimization for the namespace scope check
@ahutsunshine
Copy link
Contributor Author

ahutsunshine commented Nov 30, 2023

LGTM - please squash the commits and I will approve.

Really appreciate your review and recommendations. Squash the commits and commit.

@wojtek-t
Copy link
Member

/lgtm
/approve

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

LGTM label has been added.

Git tree hash: 11fb4d30b8ef149f79fa967d27afae67d3d92284

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ahutsunshine, wojtek-t

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

The pull request process is described 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 the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 30, 2023
@ahutsunshine
Copy link
Contributor Author

@halfcrazy @caesarxuchao @deads2k Feel free to review the PR if necessary. @wojtek-t gives LGTM and approval.

@halfcrazy
Copy link
Contributor

/lgtm

@k8s-ci-robot
Copy link
Contributor

@halfcrazy: changing LGTM is restricted to collaborators

In response to this:

/lgtm

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@ahutsunshine
Copy link
Contributor Author

/milestone v1.29

@k8s-ci-robot
Copy link
Contributor

@ahutsunshine: You must be a member of the kubernetes/milestone-maintainers GitHub team to set the milestone. If you believe you should be able to issue the /milestone command, please contact your Milestone Maintainers Team and have them propose you as an additional delegate for this responsibility.

In response to this:

/milestone v1.29

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@wojtek-t
Copy link
Member

No - we're very deep in code freeze (right before release) and this shouldn't go to 1.29.
This will merge once the branch opens after release.

@bart0sh
Copy link
Contributor

bart0sh commented Dec 4, 2023

/priority important-longterm

@k8s-ci-robot k8s-ci-robot added priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. and removed needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Dec 4, 2023
@bart0sh bart0sh moved this from Triage to Needs Approver in SIG Node PR Triage Dec 4, 2023
@k8s-ci-robot k8s-ci-robot merged commit 2eb2a62 into kubernetes:master Dec 13, 2023
15 checks passed
SIG Node PR Triage automation moved this from Needs Approver to Done Dec 13, 2023
@k8s-ci-robot k8s-ci-robot added this to the v1.30 milestone Dec 13, 2023
@MadhavJivrajani
Copy link
Contributor

MadhavJivrajani commented Jan 9, 2024

Considering this adds in a feature gate to control the behaviour, its probably worth adding a release note since we aren't going down the KEP route.

@@ -975,6 +975,12 @@ const (
// will not graduate or be enabled by default in future Kubernetes
// releases.
UserNamespacesPodSecurityStandards featuregate.Feature = "UserNamespacesPodSecurityStandards"

// owner: @ahutsunshine
// beta: v1.29
Copy link
Contributor

Choose a reason for hiding this comment

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

This is probably a mistake since the PR ended up going in after code freeze for 1.29 was lifted (i.e. in the 1.30 release)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@MadhavJivrajani Thanks for your reminding. Yeah, it's a mistake. Shall we file a PR to fix it?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes please do! Thank you!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

PR: #122732 to fix version typo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/apiserver cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. release-note-none Denotes a PR that doesn't merit a release note. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/node Categorizes an issue or PR as relevant to SIG Node. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
Archived in project
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

8 participants