<p>I read this post about how to share kube config.</p>

<p><a href="https://stackoverflow.com/questions/34270076/how-to-share-kube-config/34271748#34271748">How to share .kube/config?</a></p>

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

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

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

Yuta Fuji
<p>You can set multiple clusters in the same kubeconfig file, see <a href="https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/" rel="nofollow noreferrer">this doc</a></p>

<p>Another solution to use multiple kubeconfig files is to set the environment variable KUBECONFIG</p>

<pre><code>export KUBECONFIG=&lt;path to config-yuta&gt;
</code></pre>

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

<pre><code>KUBECONFIG=~/.kube/config:&lt;path to config-yuta&gt; kubectl config view --flatten &gt; ~/.kube/config
</code></pre>
