Reference previously declared value in HELM values.yaml

11/6/2019

I have a HELM Chart with a few requirements (i.e. subcharts).

When deploying that chart, I use a values.yaml containing all the values for both the main chart and the subcharts :

globalFoo: "bar"

subchart1:
  foo: subchart1-{{ globalFoo }}

subchart2:
  localFoo: "bar2"
  foo: subchart2-{{ subchart2.localFoo }}

I'd like to achieve two things :

  • Reference a previously declared global variable (i.e. in the global chart scope) in a subchart value (subchart1.foo in my example)
  • Reference a previously declared local variable in the same subchart scope (subchart2.foo in my example)

The exemple above doesn't work. I tried several syntaxes and none of them worked. I didn't find anything like that in the HELM documentation.

Is it doable ?

-- Neumann
kubernetes-helm

1 Answer

1/20/2020

Currently (as of Helm version 3) this is not supported.

A similar issue is discussed in Proposal: Allow templating in values.yaml

And is rejected for several reasons. One of them stated by the creator of Helm

The bigger constraint is that the values.yaml file MUST always be a valid YAML file.

And also in Support for using {{ values }} within values.yaml

the file that is passed into the template engine as a source of data for templates is itself not passed through the template engine. We almost definitely will not do that because it gets very confusing for users. It also breaks both standard YAML compatibility and backward compatibility with all existing Helm versions.

And last but not least here

The tl;dr At its most simple, the reason behind not wanting to do this is you don’t template the file that provides the values that you template with. Furthermore, this feature will be made obsolete by Helm 3

...

Obsolete by Helm 3 In Helm 3 as part of the eventing/hook system, we will allow Lua-based modification of values in a much easier way than having to template them out. Seeing as we are well underway with development for Helm 3, adding a feature with all of the drawbacks mentioned above would cause more churn than the value added. So we aren’t rejecting this outright, but are implementing it (albeit in a different way) for Helm 3

But as of now mentioned support via Lua seems to be still open.

-- LazerBass
Source: StackOverflow