ahmetb / kubectx

Faster way to switch between clusters and namespaces in kubectl
https://kubectx.dev
Apache License 2.0
17.66k stars 1.26k forks source link

Feat: add a flag to allow prefixing a query in interactive mode #429

Open Itaykal opened 2 weeks ago

Itaykal commented 2 weeks ago

Behaviour

$ kubectx -q prod

will output:

Screenshot 2024-09-22 at 18 16 59
ahmetb commented 2 weeks ago

I'm failing to understand the use case for this. I never needed something like this and fzf does a good job of filtering the same results without introducing a flag with the same amount of keystrokes, no?

Itaykal commented 2 weeks ago

I'm failing to understand the use case for this. I never needed something like this and fzf does a good job of filtering the same results without introducing a flag with the same amount of keystrokes, no?

Well yes but actually no, I want to be able to create the following aliases:

kx=kubectx -q <staging-context-identifier>
kxp=kubectx -q <production-context-identifier>

And create some "segregation" between context "types", in order to avoid logging in to the wrong cluster

ahmetb commented 2 weeks ago

I think you're trying to solve the problem at the wrong layer. I recommend segregating by different kubeconfig files entirely.

Also, this sort of problem won't solve accidents you're trying to prevent. Speaking from experience, a writable context entry is always a recipe for disaster.

At any rate, I don't think this concern should be addressed at this tool, and if you use separate kubeconfig files it would work with this tool with no modifications.