<p>I am trying to use the kubectl run command to create a Pod that uses a custom serviceaccount "svcacct1" instead of default serviceaccout. There seems to be no switch for providing a specific serviceaccount within the run command so leveraging  --overrides switch to provide JSON as shown below. </p>

<pre><code>kubectl run ng2 --image=nginx --namespace=test --overrides='{ "apiVersion": "apps/v1", "spec": { "serviceAccount": "svcacct1" , "serviceAccountName": "svcacct1" }  }' -o yaml
</code></pre>

<p>This does create the Pod (and a deployment) successfully but does not leverage the "svcacct1" and instead uses "default" as shown below (only relevant part of the output is shown)</p>

<pre><code>&gt; kubectl get po ng2-569d45c6b5-c9zhp -o yaml -n test

spec:
  containers:
  - image: nginx
    imagePullPolicy: Always
    name: ng2
    resources: {}
    terminationMessagePath: /dev/termination-log
    terminationMessagePolicy: File
    volumeMounts:
    - mountPath: /var/run/secrets/kubernetes.io/serviceaccount
      name: default-token-cpwjr
      readOnly: true
  dnsPolicy: ClusterFirst
  enableServiceLinks: true
  nodeName: minikube
  priority: 0
  restartPolicy: Always
  schedulerName: default-scheduler
  securityContext: {}
  serviceAccount: default
  serviceAccountName: default
  terminationGracePeriodSeconds: 30 
</code></pre>

<p>Also, the account does exist in the correct namespace.</p>

<pre><code>&gt; kubectl get serviceaccount svcacct1 -o yaml -n test

apiVersion: v1
kind: ServiceAccount
metadata:
  creationTimestamp: "2019-05-01T11:56:52Z"
  name: svcacct1
  namespace: test
  resourceVersion: "632061"
  selfLink: /api/v1/namespaces/test/serviceaccounts/svcacct1
  uid: 3573ffc6-6c08-11e9-9c81-0800270172ea
secrets:
- name: svcacct1-token-q9ksc
</code></pre>

<p>It is not clear what is missing for this to work?</p>

<p>The <code>--serviceaccount</code> flag isn't present in current versions (1.21) and got deprecated as mentioned in the <a href="https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG/CHANGELOG-1.21.md" rel="noreferrer">changelog</a>.</p>
<p>But with a slight modification to the command mentioned in the question, it works:</p>
<pre><code>kubectl run -ti debug --image=praqma/network-multitool --overrides='{ &quot;spec&quot;: { &quot;serviceAccount&quot;: &quot;your-sa-here&quot; }  }' sh
</code></pre>
