Can Helm conditionally install main chart based on parameter in values.yaml

3/30/2020

I am not clear if dependencies in Helm3 is just for subcharts.

I have license: false in values.yaml And I need to install my chart only if license is set to true.

I went through https://helm.sh/docs/topics/charts/#tags-and-condition-fields-in-dependencies

but I couldnt get a way to block the main chart installation.

-- ambikanair
kubernetes-helm

2 Answers

4/16/2020

This answer helped me. How to fail a helm release based on inputs in values.yaml I just have to add this condition at one template file and the helm chart wouldn't be rendered.

Problem with {{- if .Values.license -}} condition is, helm release would still be provisioned with K8 resources being empty.Also it should be added in all template files.

-- ambikanair
Source: StackOverflow

3/31/2020

That's correct, dependencies is being used for sub-charts of your main chart. In case you need to deploy your main chart in certain conditions I would suggest following the same steps of the default chart template. For example, you will find a file called serviceaccount.yaml which have the following condition:

{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
...
{{- end -}}

This means the whole block will not be evaluated unless it met the condition specified. In your case, you need to set a condition in all the chart's templates regardless the kind

{{- if .Values.license -}}
...
{{- end -}}
-- Mostafa Hussein
Source: StackOverflow