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

Reduce apiserver lease duration and GC interval to 20s #125965

Closed

Conversation

carreter
Copy link

@carreter carreter commented Jul 8, 2024

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

Reduces apiserver lease duration and garbage collection interval from 1 hour to 20 seconds (twice the lease renewal interval). This allows for faster detection of whether an apiserver is unhealthy, as its lease will expire much more quickly if it is not being actively renewed.

Allows other services to use apiserver leases as a reliable way of determining the number of available apiservers. Current specific use-case is for konnectivity-network-proxy agents to dynamically determine the number of k8s apiservers (and thus proxy servers assuming a 1:1 apiserver:proxy server mapping, which is usually the case). See this issue and this design doc for more information.

Which issue(s) this PR fixes:

N/A

Special notes for your reviewer:

N/A

Does this PR introduce a user-facing change?

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

- [KNP dynamic proxy server count scaling design doc]: https://docs.google.com/document/d/16G8U-QWR4tNfY2jiOk-ZUEMVwBkq9R9iXZqXrxPsGOE/edit#heading=h.ymlc40jj6ff0

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. cncf-cla: yes Indicates the PR's author has 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 Jul 8, 2024
@k8s-ci-robot
Copy link
Contributor

Welcome @carreter!

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
Copy link
Contributor

Hi @carreter. 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-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. area/test sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/testing Categorizes an issue or PR as relevant to SIG Testing. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jul 8, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: carreter
Once this PR has been reviewed and has the lgtm label, please assign jpbetz for approval. For more information see the Kubernetes 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

@aojea
Copy link
Member

aojea commented Jul 9, 2024

/ok-to-test
/assign @wojtek-t @andrewsykim

any implications for scalability?
do we foresee we'll need to be able to define custom values?

@k8s-ci-robot k8s-ci-robot added the ok-to-test Indicates a non-member PR verified by an org member that is safe to test. label Jul 9, 2024
@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jul 9, 2024
@cici37
Copy link
Contributor

cici37 commented Jul 9, 2024

/assign @jpbetz @deads2k Since it looks like a big change.
/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 Jul 9, 2024
@carreter
Copy link
Author

carreter commented Jul 17, 2024

As a heads up, after some discussion it's been decided that konnectivity-network-proxy will be rolling its own lease controller and not depending on the apiserver leases. I'd imagine that reducing this duration would still be useful for other situations in which an up-to-date count of apiservers is necessary.

EDIT: GKE will still end up going the apiserver lease route, though the plan is still to extend KNP to include the lease controller.

@carreter
Copy link
Author

Giving this a bump. To answer @aojea 's questions to the best of my ability:

any implications for scalability?

This does add a non-trivial number of requests to the k8s apiserver, as leases will have to be renewed every 10secs rather than every hour. I believe this is worth the cost in order to maintain an up-to-date count of the identities and status of the apiservers.

do we foresee we'll need to be able to define custom values?

I don't think so. Assuming the cost incurred of having a relatively short lease duration is acceptable, it seems to me that there would be no need to increase it again.

@deads2k
Copy link
Contributor

deads2k commented Jul 30, 2024

/hold

The choice of a long time for this lease was intentional, not accidental. We chose a long duration because the consequences of apiserver identity being improperly reaped are severe enough to cause malfunctioning of core capability like LISTing CRs, namespace deletion, and garbage collection. See the reasoning here: https://github.com/kubernetes/enhancements/tree/master/keps/sig-api-machinery/1965-kube-apiserver-identity#caveats

While there might be some appetite for making this configurable, a skim of the intent here appears to be to use this lease in a manner similar to an endpoint slice. That sort of usage needs to account for the various readyz, healthz, livez checks. While this may appear to be similar, it is a building block for very different usage related to apiserver coordination on storage versions.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 30, 2024
@carreter
Copy link
Author

Closing this issue as we have opted to use a custom lease controller to manage KNP leases rather than depend on the apiserver leases given the issues raised by @deads2k. Thanks for the feedback everyone!

@carreter carreter closed this Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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/testing Categorizes an issue or PR as relevant to SIG Testing. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants