Is it possible to disable chart located in charts folder in kubernetes?
Before Helm 3 there was no possibility to disable in requirements.yaml "local" unpacked charts, repository field was always required, thus there was no possibility to disable unpacked charts all along. This is also mentioned in this comment Is it possible to disable chart located in charts folder in kubernetes?
In Helm 3 this issue is solved, thanks to https://github.com/helm/helm/issues/3742#issuecomment-574056164
My Chart.yaml looks like this:
dependencies:
- name: mongodb-replicaset
version: ^3.15.1
repository: https://kubernetes-charts.storage.googleapis.com
condition: mongodb.enabled
- name: elasticmq
version: 0.1.0
condition: elasticmq.enabled
- name: jhipster-registry
version: 0.1.0
condition: jhipster-registry.enabled
My helm version is 3.2.1
Now it just displays warning like this, but condition works anyway:
Update Complete. ⎈Happy Helming!⎈
Saving 3 charts
Downloading mongodb-replicaset from repo https://kubernetes-charts.storage.googleapis.com
Dependency elasticmq did not declare a repository. Assuming it exists in the charts directory
Dependency jhipster-registry did not declare a repository. Assuming it exists in the charts directory
Deleting outdated charts
So built-in chart disabling doesn't break anything anymore and can be used.
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