Share kube config

10/1/2018

I read this post about how to share kube config.

How to share .kube/config?

It says that kubectl config view --flatten --minify is the way to get kube config file.
But when it comes to use this config file, I am confused.
For example, if the output is saved as config-yuta, do I always specify the config file like this? kubectl --kubeconfig=config-yuta cluster-info

I feel too troublesome to specify --kubeconfig=xxx always. I just want to switch the context and do like kubectl cluster-info without specifying a certain file when I have multiple clusters.

Should I merge ~/.kube/config with the output?
If so, how can I do it correctly?

-- Yuta Fuji
kubernetes

1 Answer

10/1/2018

You can set multiple clusters in the same kubeconfig file, see this doc

Another solution to use multiple kubeconfig files is to set the environment variable KUBECONFIG

export KUBECONFIG=<path to config-yuta>

And finally it's also possible to merge the file config-yuta with the default kubeconfig with this command:

KUBECONFIG=~/.kube/config:<path to config-yuta> kubectl config view --flatten > ~/.kube/config
-- Ignacio Millán
Source: StackOverflow