<p>I have a following pod yaml to run a pod with security context where <code>runAsUser</code> and <code>runAsGroup</code> are set.</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: test
spec:
  containers:
  - name: test
    image: ubuntu:18.04
    command: [&quot;sleep&quot;, &quot;10d&quot;]
    securityContext:
      runAsUser: 1002
      runAsGroup: 2002
</code></pre>
<p>When I exec into the container, it says:</p>
<pre><code>$ k exec -it test -- bash
groups: cannot find name for group ID 2002
I have no name!@test:/$
</code></pre>
<p>whoami command is also not working:</p>
<pre><code>I have no name!@test:/$ whoami
whoami: cannot find name for user ID 1002
</code></pre>
<p>Here I need to set username for given uid(uid is not fixed so can't create image with a specific username).</p>
<p>Does kubernetes provide any option to set username?</p>

shabbir
<p>No.  The username (if any) is determined by looking up the numeric user ID in the container's <code>/etc/passwd</code> file (if any), and Kubernetes doesn't try to modify that file.</p>
<p>There aren't really any consequences to the user ID not existing in <code>/etc/passwd</code>, beyond getting this cosmetic error message in the unusual case of a debugging shell.  Filesystem permissions are set and enforced only based on the numeric user and group IDs.  So, for example, if you mount a PersistentVolumeClaim with an additional <code>fsGroup:</code> setting, that's based only on a <em>numeric</em> group ID, and again, it's irrelevant whether or not that actually exists in the container's <code>/etc/groups</code> file.</p>
