<p>I am encountering a weird behavior when i try to configure several KUBECONFIG environment entries concatenated with <code>:</code> such in the example here :</p>

<pre class="lang-sh prettyprint-override"><code>export KUBECONFIG=/Users/user/Work/company/project/setup/secrets/dev-qz/users/admin.conf:/Users/user/Work/company/project/setup/secrets/dev-wer/users/admin.conf:/Users/user/Work/company/project/setup/secrets/test-wer/users/admin.conf:/Users/user/Work/company/project/setup/secrets/test/users/admin.conf:/Users/user/Work/company/project/setup/secrets/dev-jg/users/admin.conf:/Users/user/Work/company/project/setup/secrets/preprod/users/admin.conf:/Users/user/Work/company/project/setup/secrets/dev/users/admin.conf:/Users/user/Work/company/project/setup/secrets/dev-fxc/users/admin.conf:/Users/user/Work/company/project/setup/secrets/cluster-setup/users/admin.conf:/Users/user/Work/company/project/setup/secrets/test-fxc/users/admin.conf:/Users/user/Work/company/project/setup/secrets/test-jg/users/admin.conf:/Users/user/Work/company/project/setup/secrets/test-qz/users/admin.conf
</code></pre>

<p>This is what is happening: if i choose with <code>kubectx</code> the cluster (not every cluster from the list, but just any), when i try <code>kubectl get po</code> i receive : <code>error: You must be logged in to the server (Unauthorized)</code> . 
But, if try to reach the same cluster passing it directly to the kubectl command with <code>--kubeconfig=&lt;path to the config&gt;</code> it works.
I am pretty struggling with this and just wanna know if anyone else is facing this kind of issues as well and how have solved it </p>

<p>Eventually i found the problem. The flatten command that suggested to me @mario, helped me to debug better the situation. </p>

<p>Basically, the <code>in memory</code> or <code>in file</code> merge, makes what it supposed to do: create a kubeconfig with all uniq parameters of each kubeconfig files. This works perfectly unless on or more kubeconfig has the same labels that identify the same component. In this case the <code>last</code> in order wins. So if you have the following example: </p>

<pre class="lang-sh prettyprint-override"><code>grep -Rn 'name: kubernetes-admin$' infra/secrets/*/users/admin.conf
infra/secrets/cluster1/users/admin.conf:16:- name: kubernetes-admin
infra/secrets/cluster2/users/admin.conf:17:- name: kubernetes-admin
infra/secrets/cluster3/users/admin.conf:16:- name: kubernetes-admin
</code></pre>

<p><code>cluster1</code> and <code>cluster2</code> won't work, while <code>cluster3</code> will work perfectly, incidentally due to the order.
The solution to this problem is to avoid non uniq fields, by renaming the label that identifies the user (for the example above). Once is done this change, everything will work perfectly. </p>
