I don't understand how to apply hashicorp vault to inject secrets in my app.
The following link shows a couple of examples https://www.vaultproject.io/docs/platform/k8s/injector/examples
I used the environment variables example from the same post. But it seems not all the env variables are injected into the app. For instance, ENVs in one of my layouts don't seem to get applied meta property="og:title" content="#{ENV['NAME']}" - shows no value. But the app is running, /vault/secrets/... has files with contents.
Here's a part of the Deployment config of my app.
When there're multiple secrets/templates, the Deployment is going to look ugly.
There's absolutely no description for configmap example but this is probably what I should be using instead of env.
...
annotations:
vault.hashicorp.com/agent-inject: "true"
vault.hashicorp.com/role: "app-role"
vault.hashicorp.com/agent-inject-status: "update"
vault.hashicorp.com/agent-inject-secret-pg.env: "secret/data/pg"
vault.hashicorp.com/agent-inject-template-pg.env: |
{{` {{- with secret "secret/data/pg" -}} `}}
{{` export POSTGRES_HOST={{ .Data.data.host }} `}}
{{` export POSTGRES_PORT={{ .Data.data.port }} `}}
{{` export POSTGRES_USER={{ .Data.data.user }} `}}
{{` export POSTGRES_PASSWORD={{ .Data.data.password }} `}}
{{` {{- end }} `}}
vault.hashicorp.com/agent-inject-secret-meta.env: "secret/data/app/meta"
vault.hashicorp.com/agent-inject-template-meta.env: |
{{` {{- with secret "secret/data/app/meta" -}} `}}
{{` export BASE_URL={{ .Data.data.url }} `}}
{{` export DESCRIPTION={{ .Data.data.description }} `}}
{{` export IMAGE={{ .Data.data.image }} `}}
{{` export NAME={{ .Data.data.name }} `}}
{{` {{- end }} `}}
spec:
serviceAccountName: app
...
args: ["/bin/bash", "-c", "source /vault/secrets/*.env && bundle exec puma -C config/puma.rb"]