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

Proposal: Add kubectx `-a` command to add ctx from kubeconfig file #361

Closed astraw99 closed 1 year ago

astraw99 commented 2 years ago

Currently, we can do ctx list, delete, rename, switch operations, but could not do ctx addition. I make this proposal to add -a command to add ctx from kubeconfig file.

Demo:

kubectl ctx -a -f ./test.config

-f: /path/to/kubeconfig

With this add command, we can do kubeconfig ctx management more efficiently.

ahmetb commented 2 years ago

That doesn't sound intuitive to me mostly because kubeconfig files typically have multiple contexts. I can't imagine what would it do in that case.

astraw99 commented 2 years ago

That doesn't sound intuitive to me mostly because kubeconfig files typically have multiple contexts. I can't imagine what would it do in that case.

For some user cases, there are muitiple clusters (dev/test/prod) to manage, share and copy from one kubeconfig file to another, and the files are just single kubeconfig file. So need to add ctx from different file.

In my case, I use another tool https://github.com/sunny0826/kubecm to do it. Hope this tool could integrate the add feature. PTAL thanks.

ahmetb commented 1 year ago

I think this request goes into full extent of managing kubeconfig files, which kubectx isn't intended for.