<p>Best practice for managing 3 or 4 secrets for a single Kubernetes deployment. </p>

<p>We have a deployment with some secrets repeated in all namespaces, and others that are environment specific. </p>

<p>We are trying to decide between one secret file and changing only the ones that need to be, OR running 2+ secrets where one is foo-dev-secrets and the other is foo-universal-secrets.</p>

<p>We can't find any examples of what to do in these cases, more specifically how to manage these secrets, we know you can only have "one secret per volume", but in all honesty we aren't sure what that means. </p>

<p>Feel free to respond as if we are dumb children. ^_^</p>

<blockquote>
  <p>running 2+ secrets where one is foo-dev-secrets and the other is foo-universal-secrets</p>
</blockquote>

<p>As a for-your-consideration, a well-constructed RBAC policy would ensure that only accounts with the correct permissions would be able to read secrets if they are decomposed, which would (of course) be much harder if they were all lumped into one "all-the-secrets" bucket</p>

<blockquote>
  <p>we know you can only have "one secret per volume", but in all honesty we aren't sure what that means.</p>
</blockquote>

<p>Then you're in good company, because I don't know what that means, either :-D If you mean there are global secrets, but the dev secrets are named the same but more specific, I <em>think</em> <code>docker -v</code> will tolerate that:</p>

<pre><code>containers:
- name: foo
  volumeMounts:
  - name: global-secrets
    mountPoint: /run/secrets/global
    readOnly: true
  - name: foo-secret-override
    mountPoint: /run/secrets/global/no-really
    readOnly: true
</code></pre>

<p>... with the disadvantage being that your <code>volumes:</code> and <code>volumeMounts:</code> will become quite chatty</p>

<p>That said, I would bet the more general, and less mind-bend-y solution is to mount them as peers and then do the application equivalent of <code>find /run/secrets/ -not -type d</code> to slurp them all up:</p>

<pre><code>  volumeMounts:
  - name: global-secrets
    mountPoint: /run/secrets/0-global
    readOnly: true
  - name: foo-secrets
    mountPoint: /run/secrets/1-foo
    readOnly: true
</code></pre>

<p>Or, if possible, have the application read the path from an environment variable or <code>ConfigMap</code>-ed situation, meaning one could project them as peers (still) but point-out to the application which of the two values it should use.</p>

<p>Of course, the devil's in the details, so feel free to chime in if you are able to share more specifics about the hurdles you are encountering</p>
