Merge kubernetes configs
Managing multiple config contexts properly
Sometimes managing k8s cluster could be a pain in the ass, but it should be so. Lets see how we can work this around.
Adding new config
- Put your new config into
$HOME/.kube/config-new
. - Backup your current config
cp ~/.kube/config ~/.kube/config-bu
Merge 2 configs together
KUBECONFIG=$HOME/.kube/config:$HOME/.kube/config-new kubectl config view --merge --flatten > ~/.kube/config
Managing multiple cluster and environemtns
I recommend using kubectx You can now switch between your cluster within a single command
$ kubectx
minikube
prod-cluster
$ kubectx minikube
And environments as well
$ kubens
default
staging
production
development
$ kubens development