Vault-helm and annotations in a helm chart

Hi,

When I use the following annotation in a helm chart I receive an error “function “secret” not defined” but it works fine in a regular manifest

  annotations:
    vault.hashicorp.com/agent-inject: "true"
    vault.hashicorp.com/agent-inject-template-helloworld: |
      {{- with secret "kv2/data/secret" -}}
      postgresql://{{ .Data.data.username }}:{{ .Data.data.password }}@postgres:5432/wizard
      {{- end }}

What am I missing here? Thanks in advance!

2 Likes

Hi,

I’ve encountered the same issue, and based on https://github.com/hashicorp/vault-helm/issues/187, I think it can be solved like this

annotations:
    vault.hashicorp.com/agent-inject: "true"
    vault.hashicorp.com/agent-inject-template-helloworld: |
      {{`{{- with secret "kv2/data/secret" -}}
      postgresql://{{ .Data.data.username }}:{{ .Data.data.password }}@postgres:5432/wizard
      {{- end }}`}}

Would be nice to have this in vault documentation and tutorials (learn section)

3 Likes

I tried the exact same way but it didn’t work for me. I just wanted to see if the configuration below is valid, any help would be much appreciated, thank you!

vault.hashicorp.com/agent-inject-template-creds: |
      {{`{{- with secret "secret/data/test" -}}`}}
      {{`{{ range $k, $v := .Data.data }}`}}
        export {{ $k }}={{ $v }}
      {{`{{ end }}`}}
      {{`{{- end }}`}}