Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to disable chart located in charts folder in kubernetes?

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 }}
like image 494
avasin Avatar asked Dec 05 '17 13:12

avasin


2 Answers

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

like image 131
Bardiel W. Thirtytwo Avatar answered Sep 17 '22 13:09

Bardiel W. Thirtytwo


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
like image 28
Radek 'Goblin' Pieczonka Avatar answered Sep 17 '22 13:09

Radek 'Goblin' Pieczonka