Tool to manage multiple kubeconfig files and swap between clusters easily
If you interact with a lot of kubernetes clusters/contexts, and you dont want to manage it in a big single kubeconfig file (merging kubeconfigs is tedious...), this is the right tool for you!
Just throw your kubeconfig files inside $HOME/.kube/
, and kubeswap will manage it for you.
Basically, you will use 2 commands:
-
kubeswap: scans your
$HOME/.kube
dir and shows you a pretty interactive list to choose the desired kubeconfig -
kubeswap <name>: directly select the kubeconfig with that name from your
$HOME/.kube/
dir -
Extra:
kubeswap none
will remove the current kubeconfig.
Besides the basic usage, kubeswap has a key-value store, so you can:
- Add/delete kubeconfigs to/from the db
- List the kubeconfigs stored
- Select one to use
- Much more... (not really)
I have implemented the store with 2 objectives:
- Portability: you can use this db to store all your kubeconfigs and carry them with you
- Backup/Restore: you can use the db to backup/restore the kubeconfigs
To use the store, check the help :)
kubeswap help
Use some shell/program that shows you your current k8s cluster/context.
Basic (without store):
- Interactive list:
kubeswap
- Select one kubeconfig from your
$HOME/.kube/
directory:
kubeswap <filename>
Advanced (with store):
- add:
kubeswap add --name test --kubeconfig test/kubeconfig.yml --db /tmp/kubeswap.db
- list:
kubeswap list --db /tmp/kubeswap.db
- print:
kubeswap print -n test --db /tmp/kubeswap.db
- printall:
kubeswap printall --db /tmp/kubeswap.db
- use:
kubeswap use -n test --db /tmp/kubeswap.db
- delete:
kubeswap delete -n test --db /tmp/kubeswap.db
- Test in windows & mac