<p>I'm trying to inject my secrets from Google Secret Manager into Kubernetes Pod as environment variable.</p>
<p>I need put it as environment variable to my NodeJS application can read it.</p>
<p>I tried the solution from <a href="https://stackoverflow.com/questions/63923379/how-to-inject-secret-from-google-secret-manager-into-kubernetes-pod-as-environme">How to inject secret from Google Secret Manager into Kubernetes Pod as environment variable?</a> but not work for me.</p>
<p>Also I tried to setup a init container but it put the secrets as files into the pod.</p>
<p>Any idea?</p>
<p>Thanks</p>

Alejandro Sotillo
<p>You can do something like this during cloud build step.</p>
<pre><code>steps:
- name: '&lt;secrets_to_configmap&gt;'
  entrypoint: 'bash'
  args: ['USERNAME=$$USERNAME', 'PASSWORD=$$PASSWORD']
  secretEnv: ['USERNAME', 'PASSWORD']
availableSecrets:
  secretManager:
  - versionName: projects/PROJECT_ID/secrets/SECRET_NAME/versions/SECRET_VERSION
    env: 'PASSWORD'
  - versionName: projects/PROJECT_ID/secrets/SECRET_NAME/versions/SECRET_VERSION
    env: 'USERNAME'
</code></pre>
<p>The docker image <code>secrets_to_configmap</code> will take the secrets from secrets manager and create a configmaps which pods can use.</p>
<p><a href="https://cloud.google.com/build/docs/securing-builds/use-secrets#:%7E:text=Secret%20Manager%20is%20a%20Google,the%20information%20from%20Secret%20Manager." rel="nofollow noreferrer">Reference</a></p>
