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

<p>Here I want to execute required dependencies when apache.enabled == false</p>

<pre><code>values.yaml

external_apache:
  enabled: false
</code></pre>

<h3>File requirements.yaml</h3>

<pre><code>dependencies:
- name:
  version:
  repository:
  condition: external_apache.enabled
</code></pre>

<p>How do I add a false condition?</p>

<p>I have tried the below condition, but it's not working:</p>

<pre><code>condition: external_apache.enabled == false
</code></pre>

Sheshananda Naidu
<p>What version of Helm are you using?</p>
<p>There was a similar issue in the Kubernetes repository on GitHub:</p>
<p><a href="https://github.com/kubernetes/helm/issues/2111" rel="nofollow noreferrer">Unable to use condition in 'requirements.yaml' #2111</a></p>
<p>The solution was to upgrade Helm to v2.2.0+. In that version, condition support was added.</p>
<p><a href="https://helm.sh/docs/topics/v2_v3_migration/" rel="nofollow noreferrer"><strong>Helm 2 to Helm 3 upgrade note:</strong></a></p>
<blockquote>
<p>Chart apiVersion bumped to &quot;v2&quot; for following specification changes:</p>
<ul>
<li><strong>Dynamically linked chart dependencies moved to <a href="https://helm.sh/docs/topics/charts/#the-chartyaml-file" rel="nofollow noreferrer">Chart.yaml</a> (requirements.yaml removed and requirements --&gt; dependencies)</strong></li>
<li>Library charts (helper/common charts) can now be added as dynamically linked chart dependencies</li>
<li>Charts have a type metadata field to define the chart to be of an application or library chart. It is application by default which means it is renderable and installable</li>
<li>Helm 2 charts (apiVersion=v1) are still installable</li>
</ul>
</blockquote>
<p>In the <a href="https://docs.helm.sh/developing_charts/#tags-and-condition-fields-in-requirements-yaml" rel="nofollow noreferrer">Helm documentation</a> or <a href="https://github.com/kubernetes/helm/blob/master/docs/charts.md#tags-and-condition-fields-in-requirementsyaml" rel="nofollow noreferrer">repository</a>, there is an explanation of how the condition works:
(I've added some comments to make reading easier)</p>
<p><strong>Condition</strong> - The condition field holds one or more YAML paths (delimited by commas). <br/>
<strong>Tags</strong> - The tags field is a YAML list of labels to associate with this chart.</p>
<pre><code># 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 is “false” in values.yaml file , but ...)
          - subchart1        #(subchart1.enabled condition path is present in values.yaml file and it has &quot;true&quot; 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 is “true” in values.yaml file)
          - subchart2       #(and there is no condition path found in values.yaml to override it)
</code></pre>
<p>If this <strong>condition path</strong> exists in the top parent’s <code>values</code> 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 <strong>if no paths exist then the condition has no effect</strong>.</p>
<p>In the top parent’s values, all charts with <strong>tags</strong> can be enabled or disabled by specifying the tag and a boolean value.</p>
<pre><code># 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)
</code></pre>
<p>The logic and sequence of conditions and tags are described in <a href="https://docs.helm.sh/developing_charts/#tags-and-condition-resolution" rel="nofollow noreferrer">Tags and Condition Resolution</a>:</p>
<ul>
<li><strong>Conditions (when set in values) always override tags</strong>. The first condition path that exists wins and subsequent ones for that chart are ignored.</li>
<li>Tags are evaluated as ‘if any of the chart’s tags are true then enable the chart’.</li>
<li>Tags and conditions values must be set in the top parent’s values.</li>
<li>The tags: key in values must be a top level key. <strong>Globals and nested tags: tables are not currently supported.</strong></li>
</ul>
<p>You can also set tags and conditions in the command line:</p>
<pre><code>helm install --set tags.front-end=true --set subchart2.enabled=false
</code></pre>
