How to use my values.yaml's values in stable/mongo subchart's secrets?

7/3/2019

The stable/mongodb chart has a secrets.yaml that looks like the following.

{{ if and .Values.usePassword (not .Values.existingSecret) -}}
apiVersion: v1
kind: Secret
metadata:
  name: {{ template "mongodb.fullname" . }}
  labels:
    app: {{ template "mongodb.name" . }}
    chart: {{ template "mongodb.chart" . }}
    release: "{{ .Release.Name }}"
    heritage: "{{ .Release.Service }}"
type: Opaque
data:
  {{- if .Values.mongodbRootPassword }}
  mongodb-root-password:  {{ .Values.mongodbRootPassword | b64enc | quote }}
  {{- else }}
  mongodb-root-password: {{ randAlphaNum 10 | b64enc | quote }}
  {{- end }}
  {{- if and .Values.mongodbUsername .Values.mongodbDatabase }}
  {{- if .Values.mongodbPassword }}
  mongodb-password:  {{ .Values.mongodbPassword | b64enc | quote }}
  {{- else }}
  mongodb-password: {{ randAlphaNum 10 | b64enc | quote }}
  {{- end }}
  {{- end }}
  {{- if .Values.replicaSet.enabled }}
  {{- if .Values.replicaSet.key }}
  mongodb-replica-set-key:  {{ .Values.replicaSet.key | b64enc | quote }}
  {{- else }}
  mongodb-replica-set-key: {{ randAlphaNum 10 | b64enc | quote }}
  {{- end }}
  {{- end }}
{{- end }}

I want to provide some of the values using my values.yaml file. Is this possible since stable/mongodb 5.20.0 is a subchart/dependency I am referencing? I've tried naming values the same in my app's values.yaml, but they don't seem to overwrite them when I do a test run using helm template.

Thanks!

-- coreyperkins
kubernetes
kubernetes-helm
mongodb

1 Answer

7/3/2019

you need to put an alias to your requirements.yaml on the mongodb dependency and use it to include the values from mongo on your own values.

https://helm.sh/docs/developing_charts/#alias-field-in-requirements-yaml

-- wolmi
Source: StackOverflow