<p>I want to use multiple clusters with my <code>kubectl</code> so I either put everything into one config or add one config file per cluster to the <code>KUBECONFIG</code> env variable. That's all fine.</p>

<p>My problem is now, that I've users with the same user-name for each cluster but they use different <code>client-key-data</code> for each cluster (context) but somehow the context uses that user-name so it's not clear which user belongs to which cluster.</p>

<p>Better give an example:</p>

<p>Cluster 1:</p>

<pre><code>apiVersion: v1
kind: Config
clusters:
- cluster:
    server: https://10.11.12.13:8888
  name: team-cluster
contexts:
- context:
    cluster: team-cluster
    user: kubernetes-admin
  name: kubernetes-admin@team-cluster
users:
- name: kubernetes-admin
  user:
    client-certificate-data: XXYYYZZZ
    client-key-data: XXXYYYZZZ
</code></pre>

<p>Cluster 2:</p>

<pre><code>apiVersion: v1
kind: Config
clusters:
- cluster:
    server: https://10.11.12.14:8888
  name: dev-cluster
contexts:
- context:
    cluster: dev-cluster
    user: kubernetes-admin
  name: kubernetes-admin@dev-cluster
users:
- name: kubernetes-admin
  user:
    client-certificate-data: AABBCC
    client-key-data: AABBCC
</code></pre>

<p>As you see, in both cluster there's a user with name <code>kubernetes-admin</code> but from the context it's not clear which of those. Maybe there's another way to give it a unique identifier that is used by the context.</p>

<p>Maybe the solution is obvious but I've not found any example for such a case. Thanks for any help.</p>

<p>I had same issue with my config and found out that name in users is not username used to log in - its just name used to identify user section in config. In Your case only cert key is used to know who You are. So You can use:</p>
<pre><code>users:
- name: kubernetes-admin-1
  user:
    client-certificate-data: AABBCC
    client-key-data: AABBCC
- name: kubernetes-admin-2
  user:
    client-certificate-data: XXYYYZZZ
    client-key-data: XXXYYYZZZ
</code></pre>
<p>and refer to that in context just by key:</p>
<pre><code>contexts:
- context:
    cluster: dev-cluster
    user: kubernetes-admin-1
</code></pre>
<p>Full config:</p>
<pre><code>apiVersion: v1
kind: Config
clusters:
- cluster:
    server: https://10.11.12.13:8888
  name: team-cluster
- cluster:
    server: https://10.11.12.14:8888
  name: dev-cluster
contexts:
- context:
    cluster: team-cluster
    user: kubernetes-admin-1
  name: kubernetes-admin@team-cluster
- context:
    cluster: dev-cluster
    user: kubernetes-admin-2
  name: kubernetes-admin@dev-cluster
users:
- name: kubernetes-admin-1
  user:
    client-certificate-data: XXYYYZZZ
    client-key-data: XXXYYYZZZ
- name: kubernetes-admin-2
  user:
    client-certificate-data: AABBCC
    client-key-data: AABBCC
</code></pre>
<p>For auth methods that require username it's used something like this:</p>
<pre><code>users:
- name: kubernetes-admin-with-password
  user:
    username: kubernetes-admin
    password: mySecretPass
</code></pre>
<p>Using more than one kubeconfig is not much comfortable - you need to specify them for each command. You can have as much contexts and users if You want in one config and select right context (and save selected context as default).</p>
