<p>Docker allows execution of commands as other user with <code>docker exec -u</code>, when <code>USER something</code> in used in Dockerfile.
It is helpful to enter into superuser mode to debug issues, when you are running you <code>CMD</code> as system user in Dockerfile.</p>

<p>How to execute commands on Kubernetes as other user?</p>

<p>My kubectl version output is</p>

<pre><code>Client Version: version.Info{Major:"1", Minor:"0", GitVersion:"v1.0.6", GitCommit:"388061f00f0d9e4d641f9ed4971c775e1654579d", GitTreeState:"clean"}
Server Version: version.Info{Major:"1", Minor:"0", GitVersion:"v1.0.6", GitCommit:"388061f00f0d9e4d641f9ed4971c775e1654579d", GitTreeState:"clean"}
</code></pre>

<p>You can check the spec schema to see what you can add in a pod or replication controller or whatever: <a href="https://cloud.google.com/container-engine/docs/spec-schema" rel="noreferrer">https://cloud.google.com/container-engine/docs/spec-schema</a></p>

<p>You have runAsUser for what you want:</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: nginx
  labels:
    app: nginx
spec:
  containers:
  - name: nginx
    image: nginx
    ports:
    - containerPort: 80
    securityContext:
      runAsUser: 41
</code></pre>
