helm - programmatically override subchart values.yaml

3/29/2019

I'm writing a helm chart that uses the stable/redis chart as a subchart.

I need to override the storage class name used for both microservices within my chart, and within the redis chart.

I'm using helm 2.12.3

I would like to be able to specify redis.master.persistence.storageClass in terms of a template, like so

storage:
  storageClasses:
    name: azurefile

redis:
  usePassword: false
  master:
    persistence:
      storageClass: {{ $.Values.storage.storageClasses.name }}

Except, as I understand, templates aren't supported within values.yaml

As this is a public chart, I'm not able to modify it to depend on a global value as described here in the documentation

I considered using {{ $.Values.redis.master.persistence.storageClass }} elsewhere in my chart rather than {{ $.Values.storage.storageClasses.name }}, but this would:

  • Not hide the complexity of the dependencies of my chart
  • Not scale if I was to add yet another subchart dependency

In my values.yaml file I have:

storage:
  storageClasses:
    name: azurefile

redis:
  master:
    persistence:
      storageClass: azurefile

I would like to specify a single value in values.yaml that can be overwritten at chart deploy time.

e.g. like this

helm install --set storage.storageClasses.name=foo mychart

rather than

helm install --set storage.storageClasses.name=foo --set redis.master.persistence.storageClass mychart
-- Michael F.
kubernetes-helm

1 Answer

4/5/2019

As you correctly mentioned, helm value files are plain yaml files which cannot contain any templates. For your use case, you'd need to use a templating system for your values files also which basically means you are also generating your value files on the go. I'd suggest taking a look at helmfile. This lets you share values file across multiple charts and application environments.

-- mukesh
Source: StackOverflow