<p>I have a secret:</p>
<pre><code>apiVersion: v1
kind: Secret
metadata:
  name: secret-ssh-auth
type: kubernetes.io/ssh-auth
data:
  ssh-privatekey: |
          SEVMTE9PT09PT09PT09PT09PT09PCg==
</code></pre>
<p>and deployment:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        ports:
        - containerPort: 80
        volumeMounts:
          - name: secret-ssh-auth
            mountPath: /root/.ssh
      volumes:
      - name: secret-ssh-auth
        secret:
          secretName: secret-ssh-auth
          defaultMode: 0400
</code></pre>
<p>It creates a file with this path <code>/root/.ssh/ssh-privatekey</code> while I want to have <code>/root/.ssh/id_rsa</code> name instead.</p>
<p>I know we can solve it by running a kubectl command, but I want to handle it inside the YAML file.
So, how to do that by the YAML file?</p>

mortymacs
<p>Based on the Kubernetes documentation the <code>ssh-privatekey</code> key is mandatory, in this case, you can leave it empty via <code>stringData</code> key, then define another one by <code>data</code> key like this:</p>
<pre><code>apiVersion: v1
kind: Secret
metadata:
  name: secret-ssh-auth
type: kubernetes.io/ssh-auth
stringData:
  ssh-privatekey: |
          -
data:
   id_rsa: |
          SEVMTE9PT09PT09PT09PT09PT09PCg==
</code></pre>
