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

Add flag to opt out of existence check when switching namespaces #146

Conversation

tomasaschan
Copy link
Contributor

We have a tool that chooses a cluster and namespace based on runtime data, and
by the time we have decided what cluster and namespace to connect to, we already
know that the namespace exists in the cluster.

We want to extend this tool to support multiple switching mechanisms (rather than
just kubectl config use-context and kubectl config set-context), and but the
existence check for the namespace is prohibitively slow on some of our clusters.
To avoid paying that penalty, this change adds a flag to switch ns which allows
the user to opt out of the existence check.

λ switch ns does-not-exist
namespace "does-not-exist" not foundexit status 1

λ switch ns does-not-exist --check-existence=false

@danielfoehrKn
Copy link
Owner

Thank you very much for the PR. Could you try to rebase it on master - golangci-lint is failing for this build. Master contains an updated version of golangci-lint. Thank you!

@tomasaschan tomasaschan force-pushed the make-existence-check-on-namespace-switch-optional branch from 3787809 to 894a1cd Compare October 31, 2024 13:00
We have a tool that chooses a cluster and namespace based on runtime data, and
by the time we have decided what cluster and namespace to connect to, we already
know that the namespace exists in the cluster.

We want to extend this tool to support multiple switching mechanisms (rather than
just `kubectl config use-context` and `kubectl config set-context`), and but the
existence check for the namespace is prohibitively slow on some of our clusters.
To avoid paying that penalty, this change adds a flag to `switch ns` which allows
the user to opt out of the existence check.

```
λ switch ns does-not-exist
namespace "does-not-exist" not foundexit status 1

λ switch ns does-not-exist --check-existence=false
```
@tomasaschan
Copy link
Contributor Author

@danielfoehrKn Thanks for taking a look! Rebased now.

This seems related to #147 in that it solves (or, rather, works around) the same issue, namely namespace switching being slow on some clusters. We also have many CRDs in some of our clusters, so it's possible #147 would be enough for our immediate needs, but we also have some clusters with many namespaces (~thousands) so I worry that even if API discovery is made fast enough, the pure listing of those namespaces will still be noticeable. So I'd love to see both of these PRs merged - then I can experiment and see what seems to work best.

@danielfoehrKn danielfoehrKn merged commit a6f3400 into danielfoehrKn:master Oct 31, 2024
1 check passed
@tomasaschan tomasaschan deleted the make-existence-check-on-namespace-switch-optional branch October 31, 2024 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants