Helm dependency condition

11/12/2020

is there a way to set condition in Chart.yaml file based on variable existency? I want to install dependency just when the variable SERVICE_A_URL is not set. I tried these but helm always try to install dependency.

condition: "not SERVICE_A_URL"
condition: "not defined SERVICE_A_URL"

Thank you!

-- Radim
dependencies
kubernetes
kubernetes-helm

1 Answer

11/13/2020

As written in documentation:

All charts are loaded by default. If tags or condition fields are present, they will be evaluated and used to control loading for the chart(s) they are applied to.

Condition - The condition field holds one or more YAML paths (delimited by commas). If this path exists in the top parent's values and resolves to a boolean value, the chart will be enabled or disabled based on that boolean value. Only the first valid path found in the list is evaluated and if no paths exist then the condition has no effect.

If there is no path specified or there is nothing associated with the path the condition has no effect. You can disable installing the dependency in the values.yaml file.

For example, if you have following Chart.yaml file:

dependencies:
  - name: subchart1
    condition: subchart1.enabled
    tags:
      - front-end
      - subchart1

and you want to disable charts tagged back-end, in values.yaml you have to assign false value to it:

subchart1:
  enabled: true
tags:
  front-end: false
  back-end: true
-- kool
Source: StackOverflow