Read vault secrets as an environment variable inside k8s pod


I’ve a bunch of microservices based on NodeJs. I would like to read the secrets where I injected them via vault-agent as a sidecar as an environment variable.

I can able to access the secrets into vault’s pod but when I deploy my application it throws a below error. Can it be related with helm template somehow ?

kubectl logs -f docuplatform-backend-stage-cdd559c8f-7vs2 -n docu-platform -c vault-agent-init
`2021-04-27T15:25:45.879Z [ERROR] runtime error encountered: error="template server: (dynamic): execute: template: :2:39: executing "" at <>: nil pointer evaluating interface {}.auth_client_id_stage"`


/ $ vault kv get secret/data/docuplatform-backend
============== Data ==============
Key                         Value
---                         -----
auth_client_id_stage        12312313123
auth_client_secret_stage    12314234234


      annotations: "true" "secret/data/docuplatform-backend" |
      {{`{{ with secret "secret/data/docuplatform-backend" -}}
        export auth_client_id_stage="{{ }}",
        export auth_client_secret_stage="{{ }}"
      {{- end }}`}} docuplatform-backend
      serviceAccountName: vault-auth
        - name: docuplatform-backend1"
          command: ["/bin/sh", "-c"]
          args: [" ./vault/secrets/config && printenv"]

Did you ever solve this ? ran into the same issue here

This is the behaviour that results if evaluates to nil because there was no nested data in the response.