Is it best practice to include installation of sub-charts in global part of values.yaml
. Example..
Root level values.yaml
global:
foo: bar
subchartA:
enable: true
Or the best practice is to have subcharts out of the global part as shown.
global:
foo: bar
subchartA:
enable: true
Please provide a brief explanation why. Thank you
Subchart configuration settings need to be at the top level, outside a global:
block.
At a style level, each chart should be independently installable, whether or not it's used as a subchart. Something like the stable/mysql chart is a reasonable example: you can manually helm install mysql stable/mysql --set mysqlPassword=...
without mentioning global
. That means when you include it as a dependency its settings need to be under the subchart's key in the values.yaml
file.
At a mechanical level, when the subchart is run, the subchartA
settings are promoted up to be .Values
and then the original global:
is merged with that (see Subcharts and Globals). So the subchart itself needs to be aware of the difference
{{/* Option 1 */}}
{{ .Values.global.subchartA.enabled }}
{{/* Option 2 (within subchartA) */}}
{{ .Values.enabled }}
and at the top level you need to use the form that's compatible with the included chart.
(If you browse through the "stable" Helm chart repository you'll see global
used fairly sparingly; rabbitmq
allows you to declare global.imagePullSecrets
but that's close to it.)