0

I'm using helm 2.16. I have a chart with this structure:

umbrella
  |-charts
      |-subchart1
      |-subchart2

I want to be able to install umbrella chart + subchart1 or umbrella chart + subchart2 by using a single flag (subchart1 or subchart2) and have a default for that flag as subchart1.

As helm chart conditions on requirements cannot be negated, are there any other solutions available other that guarding all the resources from one of the charts with IFs ?

Laurentiu Soica
  • 149
  • 2
  • 15

1 Answers1

2

A workaround that I have found is to place all the subcharts into a subchart folder and have the requirements.yaml configuration file similar to below:

dependencies:
  - name: subchart1
    version: example-version
    repository: "subchart1-directory"
    alias: postgresql
    condition: subchart1.enabled
  - name: subchart2
    version: example-version
    repository: "file://subcharts/subchart2"
    condition: subchart2.enabled

and in values.yaml, add

subchart1:
  enabled: true    
subchart2:
  enabled: false

Then during installation, pass the values to enabled or disable the subchart1 as follows:

$ helm install --set subchart1.enabled=true

or

$ helm install --set subchart1.enabled=false

Take a look here: helm-charts-management, helm-chart-dependences.

Malgorzata
  • 6,409
  • 1
  • 10
  • 27
  • So I need my two subcharts to be mutually exclusive: install one or the other but not both. How can I achieve that with a single flag ? – Laurentiu Soica Jan 16 '20 at 11:46
  • As you asked for, I have found solution to make possibility that you will be able to install umbrella chart + subchart1 or umbrella chart + subchart2. You have to flag as I wrote subchart1 as enabled and then if you want to install subchart2 enable it and disable subchart1. – Malgorzata Jan 16 '20 at 12:28
  • Yes, so two flags are needed, right ? The problem I see with 2 flags is that the user of my chart could leave them both enabled my mistake. If I could configure the mutual exclusion with a single flag, that could not happen. – Laurentiu Soica Jan 16 '20 at 12:45
  • By dafault all subcharts ale flagged enabled as true, if you will change flag enabled on false for specific subchart it will not be installed. – Malgorzata Jan 16 '20 at 12:58