<p>I'm reading myself currently into RBAC and am using Docker For Desktop with a local Kubernetes cluster enabled.</p>

<p>If I run <code>kubectl auth can-i get pods</code> which user or group or serviceaccount is used by default?</p>

<p>Is it the same call like:</p>

<p><code>kubectl auth can-i get pods --as docker-for-desktop --as-group system:serviceaccounts</code> ?</p>

<p><code>kubectl config view</code> shows:</p>

<pre><code>contexts:
- context:
    cluster: docker-for-desktop-cluster
    namespace: default
    user: docker-for-desktop
  name: docker-for-desktop
...
users:
- name: docker-for-desktop
  user:
    client-certificate-data: REDACTED
    client-key-data: REDACTED
</code></pre>

<p>But simply calling <code>kubectl auth can-i get pods --as docker-for-desktop</code> returns NO.</p>

<p>Thanks,
Kim</p>

Kim
<p>To answer your question</p>

<blockquote>
  <p>If I run <code>kubectl auth can-i get pods</code> which user or group or serviceaccount is used by default?</p>
</blockquote>

<p>As you can read on <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/" rel="nofollow noreferrer">Configure Service Accounts for Pods</a>:</p>

<blockquote>
  <p>When you (a human) access the cluster (for example, using <code>kubectl</code>), you are authenticated by the apiserver as a particular User Account (currently this is usually <code>admin</code>, unless your cluster administrator has customized your cluster). Processes in containers inside pods can also contact the apiserver. When they do, they are authenticated as a particular Service Account (for example, <code>default</code>).</p>
</blockquote>

<p>You can use <code>kubectl get serviceaccount</code> to see what <code>serviceaccounts</code> are setup in the cluster.
Try checking which contexts you have available and switching into a which ever you need:</p>

<p><code>kubectl config get-contexts</code></p>

<p><code>kubectl config use-context docker-for-desktop</code></p>

<p>If you are experiencing an issue with missing <code>Role</code> please check <a href="https://kubernetes.io/docs/reference/access-authn-authz/rbac/#referring-to-resources" rel="nofollow noreferrer">Referring to Resources</a> to set  they correctly for <code>docker-for-desktop</code></p>
