Interview Prep/Helm/Dependencies, Subcharts & Library Charts

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 }}
All Helm questions Roadmap: Helm

More on Dependencies, Subcharts & Library Charts