<p>How can I issue a <code>kubectl run</code> that pulls an environment var from a k8s secret configmap?</p>

<p>Currently I have:</p>

<p><code>kubectl run oneoff -i --rm NAME --image=IMAGE --env SECRET=foo
</code></p>

<p>Look into the <code>overrides</code> flag of the <code>run</code> command... it reads as:</p>

<blockquote>
  <p>An inline JSON override for the generated object. If this is non-empty, it is used to override the generated object. Requires that the object supply a valid apiVersion field.</p>
</blockquote>

<p><a href="https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#run" rel="noreferrer">https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#run</a></p>

<p>So in your case I guess it would be something like:</p>

<pre><code>kubectl run oneoff -i --rm --overrides='
{
  "spec": {
    "containers": [
      {
        "name": "oneoff",
        "image": "IMAGE",
        "env": [
          {
            "name": "ENV_NAME"
            "valueFrom": {
              "secretKeyRef": {
                "name": "SECRET_NAME",
                "key": "SECRET_KEY"
              }
            }
          }
        ]
      }
    ]
  }
}
'  --image= IMAGE
</code></pre>
