<p>I'm beginner in Kubernetes, what I would like to achieve is :</p>
<ul>
<li>Pass user's ssh private/public key to the Pod and then to the Docker container (there's a shell script that will be using this key)</li>
</ul>
<p>So I would like to know if it's possible to do that in the Kubectl apply ?</p>
<p>My pod.yaml looks like :</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  generateName: testing
  labels:
    type: testing
  namespace: ns-test
  name: testing-config
spec:
  restartPolicy: OnFailure
  hostNetwork: true
  containers:
    - name: mycontainer
      image: &quot;.../mycontainer:latest&quot;
</code></pre>

Yellow Storm
<p>you have to store the private / public key in a <a href="https://kubernetes.io/docs/concepts/configuration/secret/" rel="nofollow noreferrer">kubernetes secret</a> object</p>
<pre><code>apiVersion: v1
kind: Secret
metadata:
  name: mysshkey
  namespace: ns-test
data:
  id_rsa: {{ value }}
  id_rsa.pub: {{ value }}
</code></pre>
<p>and now you can mount this secret file in your container:</p>
<pre><code>      containers:
      - image: &quot;my-image:latest&quot;
        name: my-app
        ...
        volumeMounts:
          - mountPath: &quot;/var/my-app&quot;
            name: ssh-key
            readOnly: true
      volumes:
        - name: ssh-key
          secret:
            secretName: mysshkey
</code></pre>
<p>The documentation of kuberentes provides also an chapter of <a href="https://kubernetes.io/docs/concepts/configuration/secret/" rel="nofollow noreferrer">Using Secrets as files from a Pod</a></p>
<p>It's not tested but i hope it works.</p>
