helm values from kubernetes secrets?
Solution 1: Create custom chart
- Delete the
secret.yaml
from chart's template directory. - Create the k8s
secret
on your own, maybe namedcumstom-secret
- Edit the
deployment.yaml
: here
- name: MONGODB_URI
valueFrom:
secretKeyRef:
name: custom-secret ## {{ include "prometheus-mongodb-exporter.fullname" . }}##
key: mongodb-uri
Solution 2: Use original chart
- Set a dummy value for
mongodb.uri
invalue.yaml
. - Use
--set
flag to overwrite the dummy value with original while installing the chart. So, yourgit
won't have the history.
$ helm install prometheus-mongodb-exporter stable/prometheus-mongodb-exporter --set mongodb.uri=******
Comments
-
Asav Patel almost 2 years
I am using this chart : https://github.com/helm/charts/tree/master/stable/prometheus-mongodb-exporter
This chart requires
MONGODB_URI
environment variable ormongodb.uri
populated invalues.yaml
file, Since this is a connection string I don't want to check-in that into git. I was thinking of kubernetes secrets and provide the connection string from kubernetes secrets. I have not been able to successfully find a solution for this one.I also tried creating another helm chart and using this one as a dependency for that chart and provide value for
MONGODB_URI
fromsecrets.yaml
but that also didn't work because inprometheus-mongodb-exporter
chartMONGODB_URI
is defined as a required value which is then passed intosecrets.yaml
file within that chart, so dependency chart never gets installed because of that.What would be the best way of achieving this?
-
Asav Patel about 4 yearsso I have to copy original chart when creating custom chart? it's not possible to create a custom chart with original chart added as dependency?
-
Kamol Hasan about 4 years@AsavPatel no, by custom chart I meant, copy the chart some directory, edit it. And then deploy it from there. Just go to the chart directory and use
helm install <name> <chart-name>
. No need userepo
name likestable
. -
wtrocki over 2 yearsSide note. Set command will store values in config-map instead of secret.