Helm - using global values by default

12/9/2019

I'm new to Helm.

I have a default value in parent chart. I want to use this value in each subchart by default, but also to have a possibility to override the value for a specific subchart.

Example:

# Parent-chart values.yaml

global:
  schedule: 10m

All the subcharts will use this value by default. But if I run something like this:

helm install --set subchart-A.schedule="20m"

Subchart-A will use value "20m".

I'm thinking about two possibilities:

  1. Maybe I can somehow link subchart-value to global value:
# Subchart values.yaml

schedule: {{ .Values.global.schedule }} # it doesn't work

In that case, it would be possible to override a specific value for the single subchart.

  1. Maybe I can write a function
# Pseudocode:

if subchart.schedule is null
  printf global.schedule
else
  printf subchart.schedule

What would you do and what is generally possible?

-- Dennis Meissel
kubernetes-helm

1 Answer

12/10/2019

Here is the documentation for reference.

You can specify defaults!

Example from the docs:

{{- with .Values.favorite }}
drink: {{ .drink | default "tea" | quote }}
food: {{ .food | upper | quote }}
release: {{ .Release.Name }}
{{- end }}

In your case, it would be something like:

{{ subchart-A.schedule | default .Values.global.schedule }}
-- hmatt1
Source: StackOverflow