charts icon indicating copy to clipboard operation
charts copied to clipboard

Add extraEnv

Open hobbypunk90 opened this issue 1 year ago • 2 comments

The option to add direct environment variables is needed to combine env variables. I use it to combine the DRONE_DATABASE_DATASOURCE from the managed secret of my postgres operator. It looks like this:

- name: DRONE_DATABASE_DATASOURCE
  value: postgres://$(username):$(password)@drone-database/$(username)?sslmode=require

hobbypunk90 avatar Jul 24 '22 14:07 hobbypunk90

Hello @hobbypunk90

I would have thought that extraSecretNamesForEnvFrom would be the best option for this kind of variable, which contains sensitive values? This will pull in a list of secrets, secrets can be added like this:

kubectl --namespace drone create secret generic drone-database-datasource --from-literal= DRONE_DATABASE_DATASOURCE ='postgres://$(username):$(password)@drone-database/$(username)?sslmode=require'

You would then add this to your values yaml:

extraSecretNamesForEnvFrom:
 - drone-database-datasource

Would this work for you?

jimsheldon avatar Jul 25 '22 13:07 jimsheldon

Hey,

that was my first try 😅 And after a bit digging in k8s issues I learned, that this variable interpolation works only in direct env variables, not in env variables from config maps or secrets 🥲 That's why I created this PR 😁

Greets Marcel

hobbypunk90 avatar Jul 26 '22 20:07 hobbypunk90

@hobbypunk90 can you change the version to 0.7.0? That will resolve the conflict. Thanks

jimsheldon avatar Oct 21 '22 17:10 jimsheldon

Anything blocking this? There are some very valid use cases here. One example: secrets generated by another chart/operator that have a different key name and need to be pulled in with a secretRef, such as if using the Percona PostgreSQL Operator, real world e.g.

env:
  - name: DRONE_DATABASE_DATASOURCE
    valueFrom:
      secretKeyRef:
        name: gitea-db-pguser-drone
        key: pgbouncer-uri

Thanks for your attention here and moving this along!

e3b0c442 avatar Jul 29 '23 21:07 e3b0c442