<p>In Kubernetes, how can I expose secrets in a file (in a Kubernetes volume) as environment variables instead?</p>

<p><strong>Background:</strong><br>
I followed the <a href="https://github.com/GoogleCloudPlatform/gke-vault-demo" rel="nofollow noreferrer">Google Cloud Platform GKE Vault Demo</a> and in it, they show how to <em>"continuously fetching a secret's contents onto a local file location. This allows the application to read secrets from a file inside the pod normally without needing to be modified to interact with Vault directly."</em>  </p>

<p>I would like to know how I can expose these secrets as environment variables (instead of a file) for the other application containers to use.</p>

cryanbhu
<p>Thanks @cryanbhu this actually saved me.</p>

<p>It is also possible to export all the variables without having to list them out:</p>

<pre><code>command: ["/bin/bash", "-c"]  # you can also just use sh for other images
args:
  - source /etc/secrets/myproject/config;
    export $(cut -d= -f1 /etc/secrets/myproject/config);
    python3 my_app.py;
</code></pre>

<p>confirmed that works for me :)</p>
