drone / charts

Helm charts for the Drone platform on Kubernetes
Other
166 stars 116 forks source link

Add extraEnv #88

Closed hobbypunk90 closed 10 months ago

hobbypunk90 commented 2 years ago

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
jimsheldon commented 2 years ago

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?

hobbypunk90 commented 2 years ago

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

jimsheldon commented 1 year ago

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

e3b0c442 commented 1 year ago

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!