I have a subchart in charts/
directory. I would like to disable it for some deployments.
Is it possible somehow? Currently i see the only way to add condition to all templates like below:
deployment.yaml
{{- if .Values.isDev }}
deployment code
{{- end }}
service.yaml
{{- if .Values.isDev }}
service code
{{- end }}
Also, for current version of Helm (2.12 at this time), it is also possible to write a requirements.yaml
in which one can specify not only remote charts for Helm to download, but also Charts inside the charts
folder. In this requirements.yaml
one can specify a condition
field for each dependency. This field is the path for a parent's Value.
So, for instance, given this requirements.yaml
:
dependencies:
- name: one-dep
version: 0.1.0
condition: one-dep.enabled
- name: another-dep
version: 0.1.0
condition: another-dep.enabled
Your values.yaml
could have:
one-dep:
enabled: true
another-dep:
enabled: false
This will result in Helm only including one-dep
chart.
It's worth noting that if the path specified in the condition
does not exist, it defaults to true
.
Here's the link to the doc
As a general rule of thumb I always have
{{- if .Values.enabled }}
...
{{- end }}
in every file in every subchart. Depending on situation the default value will be either true
for regular components or false
for dev related, or simply false
for everything if I want to enable these in completely selective manner. A typical values for deployment for this approach looks like ie.:
api:
enabled: true
database:
host: mysql-dev
mysql:
enabled: false
mysql-dev:
enabled: true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With