Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HELM Kubernetes - Multiple subcharts with differents .Values properties

I'm trying to create a chart with multiple subcharts ( 2 instances of ibm-db2oltp-dev). Is there a way to define in the same values.yaml file, different configuration for each instance?

I need two databases:

db2inst.instname: user1
db2inst.password: password1
options.databaseName: dbname1

db2inst.instname: user2
db2inst.password: password2
options.databaseName: dbname2

I saw it could be done via alias but I didn't find an example explaining how to do it. Is it possible?

like image 901
soi Avatar asked Jul 18 '19 11:07

soi


People also ask

Can Helm use multiple values files?

Yes, it's possible to have multiple values files with Helm. Just use the --values flag (or -f ). You can also pass in a single value using --set . --set (and its variants --set-string and --set-file): Specify overrides on the command line.

How do I override values YAML in Helm?

You can use a --set flag in your Helm commands to override the value of a setting in the YAML file. Specify the name of the setting and its new value after the --set flag in the Helm command. The --set flag in the above command overrides the value for the <service>. deployment.

What is Subchart in Helm?

A subchart is considered "stand-alone", which means a subchart can never explicitly depend on its parent chart. For that reason, a subchart cannot access the values of its parent. A parent chart can override values for subcharts. Helm has a concept of global values that can be accessed by all charts.


2 Answers

Yes, it is possible:

In Chart.yaml for Helm 3 or in requirements.yaml for Helm 2:

dependencies:
  - name: ibm-db2oltp-dev                *(full chart name here)*
    repository: http://localhost:10191   *(Actual repository url here)*
    version: 0.1.0                       *(Required version)*
    alias: db1inst                       *(The name of the chart locally)*
  - name: ibm-db2oltp-dev
    repository: http://localhost:10191
    version: 0.1.0
    alias: db2inst

parentChart/values.yaml:

someParentChartValueX: x
someParentChartValueY: y

db1inst:
  instname: user1
  db2inst: password1

db2inst:
  instname: user2
  db2inst: password2
like image 129
cecunami Avatar answered Sep 19 '22 17:09

cecunami


Actually it cannot be achieved in Helm (by aliases too) because values resolving doesn't work for aliased charts. The only way is to define values for chart name:

<chart_name not alias>:
  var1: value
  var2: value

The source issue: https://github.com/helm/helm/issues/7093

like image 45
ITD27M01 Avatar answered Sep 18 '22 17:09

ITD27M01