title: How to inject secret from Google Secret Manager into Kubernetes Pod as environment variable with Spring Boot?
body: <p>For the life of Bryan, how do I do this?</p>
  <p><code>Terraform</code> is used to create an SQL Server instance in GCP.
  Root password and user passwords are randomly generated, then put into the Google Secret Manager.
  The DB's IP is exposed via private DNS zone.</p>
  <p>How can I now get the username and password to access the DB into my K8s cluster? Running a Spring Boot app here.</p>
  <p>This was one option I thought of:</p>
  <p>In my deployment I add an <code>initContainer</code>:</p>
  <pre><code>- name: secrets
    image: gcr.io/google.com/cloudsdktool/cloud-sdk
    args: 
    - echo &quot;DB_PASSWORD=$(gcloud secrets versions access latest --secret=\&quot;$NAME_OF_SECRET\&quot;)&quot; &gt;&gt; super_secret.env
  </code></pre>
  <p>Okay, what now? How do I get it into my application container from here?</p>
  <p>There are also options like <code>bitnami/sealed-secrets</code>, which I don't like since the setup is using <code>Terraform</code> already and saving the secrets in GCP. When using <code>sealed-secrets</code> I could skip using the secrets manager. Same with <code>Vault</code> IMO.</p>