konfig helps to merge, split or import kubeconfig files
konfig import --save new-cfgImports the config file new-cfg into the default kubeconfig at ~/.kube/config.
To show the result without changing your kubeconfig, do
konfig import new-cfgCAVEAT: due to how shells work, the following will lose your current ~/.kube/config
# WRONG, don't do this!
konfig import new-cfg > ~/.kube/configkonfig merge config1 config2 > merged-configThis variant creates a self-contained kubeconfig where all credentials are stored inline in the kubeconfig.
If you want to preserve the structure and keep credentials separate, use --preserve-structure.
This will extract a minimal kubeconfig with a single context minikube:
# extract context minikube from the default kubeconfig
konfig export minikube > minikube.config
# extract context minikube and docker-for-desktop from two input configs
konfig export minikube docker-for-desktop -k ~/.kube/other,~/dockercfg > localThere are several ways to install konfig.
The recommended installation method is via krew.
Krew is the kubectl plugin manager. If you have not yet installed krew, get it at
https://github.com/kubernetes-sigs/krew.
Then installation is as simple as
kubectl krew install konfigThe plugin will be available as kubectl konfig, see doc/USAGE for further details. You could also define an alias as well: alias konfig = 'kubectl konfig'
When using the binaries for installation, also have a look at USAGE.
curl -Lo konfig https://github.com/corneliusweig/konfig/raw/v0.2.6/konfig \
&& chmod +x konfig \
&& sudo mv -i konfig /usr/local/binFeel free to change the sudo mv to put konfig in some other location from your $PATH variable.
If you figure out how to run
konfigon Windows, please send a PR with instructions.