How do conditions and globals interact when a subchart is disabled?
AdvancedConceptDependencies, Subcharts & Library Charts
Answer
When the condition is false, the subchart's templates are skipped, but its values still exist in the parent's .Values.<name> (defaults are coalesced). So parent templates that read .Values.postgres.auth.database still get a value. That is useful (you can keep defaults) and dangerous (a parent template may build a connection string to a database that is not deployed). Gate parent logic on the same flag:
{{- if .Values.postgres.enabled }}
host: {{ .Release.Name }}-postgres
{{- else }}
host: {{ required "externalDatabase.host is required when postgres.enabled=false" .Values.externalDatabase.host }}
{{- end }}
More on Dependencies, Subcharts & Library Charts
How do you declare a chart dependency in Helm 3?BeginnerWhat is the difference between `helm dependency update` and `helm dependency build`?IntermediateWhat is `Chart.lock` and why commit it?BeginnerHow does `condition` work on a dependency?BeginnerWhat are `tags` on dependencies?IntermediateWhat does `alias` do on a dependency?Intermediate