<p>I've multiple secrets created from different files. I'd like to store all of them in common directory <code>/var/secrets/</code>. Unfortunately, I'm unable to do that because kubernetes throws <strong>'Invalid value: "/var/secret": must be unique</strong> error during pod validation step. Below is an example of my pod definition.   </p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  labels:
    run: alpine-secret
  name: alpine-secret
spec:
  containers:
  - command:
    - sleep
    - "3600"
    image: alpine
    name: alpine-secret
    volumeMounts:
    - name: xfile
      mountPath: "/var/secrets/"
      readOnly: true
    - name: yfile
      mountPath: "/var/secrets/"
      readOnly: true
  volumes:
  - name: xfile
    secret:
      secretName: my-secret-one
  - name: yfile
    secret:
      secretName: my-secret-two
</code></pre>

<p>How can I store files from multiple secrets in the same directory?</p>

<h2>Projected Volume</h2>

<p>You can use a <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-projected-volume-storage/" rel="noreferrer">projected volume</a> to have two secrets in the same directory</p>

<p><strong>Example</strong></p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  labels:
    run: alpine-secret
  name: alpine-secret
spec:
  containers:
  - command:
    - sleep
    - "3600"
    image: alpine
    name: alpine-secret
    volumeMounts:
    - name: xyfiles
      mountPath: "/var/secrets/"
      readOnly: true
  volumes:
  - name: xyfiles
    projected:
      sources:
      - secret:
          name: my-secret-one
      - secret:
          name: my-secret-two
</code></pre>
