Kubernetes Helm chart requirements.yaml file dependencies false condition

6/8/2018

I am using the Kubernetes Helm requirements.yaml file for dependencies addition. Based on the values.yaml condition, it will create the dependencies pods.

Here I want to execute required dependencies when apache.enabled == false

values.yaml

external_apache:
  enabled: false

File requirements.yaml

dependencies:
- name:
  version:
  repository:
  condition: external_apache.enabled

How do I add a false condition?

I have tried the below condition, but it's not working:

condition: external_apache.enabled == false
-- Sheshananda Naidu
kubernetes
kubernetes-helm

3 Answers

10/5/2018

Based on the documentation and the answer from @VAS, the answer to your question is it's not possible to use a negation of a condition in requirements.yaml.

-- Philippe
Source: StackOverflow

12/29/2018

Helm version v2.2.2 worked, while v2.10.0 didn't.

-- zzxwill
Source: StackOverflow

6/8/2018

What version of Helm are you using?

There was a similar issue in the Kubernetes repository on GitHub:

Unable to use condition in 'requirements.yaml' #2111

The solution was to upgrade Helm to v2.2.0+. In that version, condition support was added.

In the Helm documentation or repository, there is an explanation of how the condition works: (I've added some comments to make reading easier)

Condition - The condition field holds one or more YAML paths (delimited by commas).
Tags - The tags field is a YAML list of labels to associate with this chart.

# parentchart/requirements.yaml
dependencies:
      - name: subchart1
        repository: http://localhost:10191
        version: 0.1.0
        condition: subchart1.enabled, global.subchart1.enabled
        tags:
          - front-end        #(chart should be disabled because the tags.front-end isfalsein values.yaml file , but ...)
          - subchart1        #(subchart1.enabled condition path is present in values.yaml file and it has "true" value...)
                             #(this condition, so it overrides tag front-end and this chart will be enabled)

      - name: subchart2
        repository: http://localhost:10191
        version: 0.1.0
        condition: subchart2.enabled,global.subchart2.enabled
                  #(as soon as no one from these paths is exists in values.yaml this condition has ho effect)

        tags:
          - back-end        #(chart should be enabled because the tags.back-end istruein values.yaml file)
          - subchart2       #(and there is no condition path found in values.yaml to override it)

If this condition 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.

In the top parent’s values, all charts with tags can be enabled or disabled by specifying the tag and a boolean value.

# parentchart/values.yaml

subchart1:
  enabled: true          #(this could be found from requirements as subchart1.enabled and override tags in this case)
tags:
  front-end: false      #(this disables charts with tag front-end)
  back-end: true        #(this enables charts with tag back-end)

The logic and sequence of conditions and tags are described in Tags and Condition Resolution:

  • Conditions (when set in values) always override tags. The first condition path that exists wins and subsequent ones for that chart are ignored.
  • Tags are evaluated as ‘if any of the chart’s tags are true then enable the chart’.
  • Tags and conditions values must be set in the top parent’s values.
  • The tags: key in values must be a top level key. Globals and nested tags: tables are not currently supported.

You can also set tags and conditions in the command line:

helm install --set tags.front-end=true --set subchart2.enabled=false
-- VAS
Source: StackOverflow