<p>We have a namespace in kubernetes where I would like some secrets (files like jks,properties,ts,etc.) to be made available to all the containers in all the pods (we have one JVM per container &amp; one container per pod kind of Deployment).</p>

<p>I have created secrets using kustomization and plan to use it as a volume for spec of each Deployment &amp; then volumeMount it for the container of this Deployment. I would like to have this volume to be mounted on each of the containers deployed in our namespace.</p>

<p>I want to know if kustomize (or anything else) can help me to mount this volume on all the deployments in this namespace?</p>

<p>I have tried the following <code>patchesStrategicMerge</code></p>

<pre><code>---
apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: myNamespace
spec:
  template:
    spec:
      imagePullSecrets:
        - name: pull-secret
      containers:
        - volumeMounts:
          - name: secret-files
            mountPath: "/secrets"
            readOnly: true
      volumes:
      - name: secret-files
        secret:
          secretName: mySecrets
          items:
          - key: key1
            path: ...somePath
          - key: key2
            path: ...somePath
</code></pre>

<p>It requires name in <code>metadata</code> section which does not help me as all my Deployments have different names.</p>

<p><a href="https://kubernetes.io/docs/tasks/inject-data-application/podpreset/" rel="nofollow noreferrer">Inject Information into Pods Using a PodPreset</a></p>
<p>You can use a PodPreset object to inject information like secrets, volume mounts, and environment variables etc into pods at creation time.</p>
<p>Update: Feb 2021. The PodPreset feature only made it to alpha. It was removed in v1.20 of kubernetes. See release note <a href="https://kubernetes.io/docs/setup/release/notes/" rel="nofollow noreferrer">https://kubernetes.io/docs/setup/release/notes/</a></p>
<blockquote>
<p>The v1alpha1 PodPreset API and admission plugin has been removed with
no built-in replacement. Admission webhooks can be used to modify pods
on creation. (#94090, @deads2k) [SIG API Machinery, Apps, CLI, Cloud
Provider, Scalability and Testing]</p>
</blockquote>
