<p>I'm currently running two Kubernetes clusters one on Google cloud and one on IBM cloud. To manage them I use kubectl. I've made a script that executes some commands on one of the clusters then switches to the other and does some other work there.
This works fine as long as the script only runs in one process, however when run in parallel the credentials are sometimes overwritten by one process when in use by another and this obviously causes issues.</p>

<p>I therefore want to know if I can supply kubectl with a credentials file for every call, instead of storing it in a environmental variable with <code>kubectl config set-credentials</code>.</p>

<p>Any help/solution is much appreciated.</p>

limeeattack
<p>If I need to work with multiple clusters using <code>kubectl</code> I am splitting my terminal and setting <code>KUBECONFIG</code> for each split:
For my first split:</p>

<pre class="lang-sh prettyprint-override"><code>export KUBECONFIG=~/.kube/cluster1
</code></pre>

<p>For the second split</p>

<pre class="lang-sh prettyprint-override"><code>export KUBECONFIG=~/.kube/cluster2
</code></pre>

<p>It is working pretty well, but this approach has one issue:
If you are using some kind of prompt with the current Kubernetes context it will give you different output and it might be missing leading.</p>

<p>For scripts, I am just changing value of <code>KUBECONFIG</code> in for loop, to loop over each cluster.</p>
