You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Make values available as .Values in termplates and helmfile.yaml #387
It would really help if values from different places were available as .Values (like in standard Helm), to be referred and used.
Not alle values are Environment values, example:
We have set up Open ID Connect using Dex and loginapp, they need to know about eachothers endpoints, being dex./dex and login./login.
The information is not globally Environment specific, but only local to this "deployment unit". The domain is though Environment specific, so this would be specified in the enviroment values.yaml
It would be nice if it was possible to just define:
I second this.
My use-case is similar - I have multiple app roles from the same monolith repo using the same config template, where vars can be different depending on the environment AND app role.
The only way to support this currently is to put this config template into each helm chart (not DRY) and this is hard to support further once that config is changed.
It would be great to have all previously merged values available in subsequent gotmpl values files.
@nikolajbrinch@Tarick What a coincidence! I just discussed about similar things with my colleague today.
@nikolajbrinch In your example, where in helmfile.yaml do you want to define the values.yaml, which seems not like releases[].values but anywhere else?
@Tarick Makes sense, but it you can still use environment values and a regular values file template, like this:
It would be great to have all previously merged values available in subsequent gotmpl values files.
So you want all the values.yaml files listed under releases[].values to be merged one by one, and the latest merged values to be available in the next values.yaml template, right?
values:
- foo.yaml.gotmpl
- bar.yaml.gotmpl
foo.yaml.gotmpl:
foo: bar
bar.yaml.gotmpl:
bar: {{ .Values.foo }}
Does the above result in the bar set to foo, and there's also foo: bar because it is merged into the second?
If I try to use .Environment.Values.values.appRole1 instead of .Values.externalDnsName this config-file.yaml.gotmpl will be valid only for that role and that breaks DRY.
Does the above result in the bar set to foo, and there's also foo: bar because it is merged into the second?
foo: bar
bar: bar
Yes, I would consider this as correct result.
I may be too spoiled by Ansible, where they merge all values in order and they are available for next file templated vars. If I remember correctly even if there is no value for a tempated var at the moment of merging, Ansible does the second pass on all files with already merged set.
Actually at first I thought that the Default environment could be used for that but it turns out that the Default environment is not loaded if some other environment is specified in the command line.
I would have expected that the default one would always be loaded and the specific environment could override it. But this is not the case.
So may be we could have some global environment that is always loaded before all the other environments and that can also be referenced with Environment.Values from the user created environments (and the default one) and from the helmfile itseft and the releases values files.
I hope I am clear. here is an example
environments:
global: <- always loaded before any chosen env
values:
- global.yaml <- this cannot be templatized (only real values)
default: <- loaded as today and can use .Environment.Values from the global ones
... and override global ones
anyenv: <- same as default but when the cli user selects (like today)
pros: augment an existing mechanism, values are still accessed using .Environment. Also environment values can override global ones.
cons: add 2 new semantics, the global without templates and the overriding mechanism.
Of course global can be change to something else (initial) or even move upward a level and can be even renamed values like this :
values: <- always loaded before any chosen env
- global.yaml <- this cannot be templatized (only real values)
environments:
default: <- loaded as today and can use .Values from the global ones
...
anyenv: <- same as default and when the cli user selects (like today)
pros: decouple the 2 semantics
cons: you need 2 mechanisms for getting access to values, Environment.Values and .Values. And you cannot override the global ones.
I would be in favor of the first solution and hope I understood the initial concern.
Hey! I also could use some way of accessing values from values. My use-case is pretty similar to @Tarick s one - I have a huge monolith project which actually is multiple applications all using same image, all using same configuration, only difference being the run command. I wanted to create a setup with generic release definition and have a list of enabled applications/components for each environment (f.e. on production I want all components deployed but on testenv I might want only few of them, or on my dev cluster I want only component I'm developing, etc.).
So in my environment.yaml file I would have something like this :
componentsEnabled:
- app1
- app2
and then in my helmfile I wanted to use range to generate release for each of those components:
Hey! You're correct on that this can't be achieved today.
Perhaps what we wan't isn't inheriting previous values.yaml contents to next ones, but rather a dedicated way to compose values injected to values.yaml templates.
What if helmfile added a syntax like this?
releases:
- name: {{ . }}`chart: my-chartvaluesFrom:
- inline:
foo: FOO
- file:
path: values/values.yaml
- templateFile:
path: values/values-file.yaml.gotmplvaluesFrom:
- inlineTemplate:
releaseName: `{{.Release.Name}}`#<- you'll need {{` `}} to defer rendering until the evaluation time of inlineTemplate. otherwise this fails due to that .Release.Name isn't available at loading-time of your helmfile.yaml :)
values/values.yaml:
bar: BAR
values/values-file.yaml.gotmpl:
baz: {{.Values.releaseName}}
For app1, this would result in rendering my-chart with the following values:
foo: FOO
bar: BAR
baz: app1
and For app2:
foo: FOO
bar: BAR
baz: app2
Reacted by Jan Baraniewski, Oleg Dianov and Jeffrey Holm
Hey, sorry that I took so long to get back to you. That looks like a nice feature, definitely would help with figuring out how are different values overwritten and where they come from.
I was however able to solve my case! I used helmfile layering for that.
I have my "template" helmfile component.yaml
Since this value is available both in underlying helmfile and in values that releases from it use, this solves my case and allows us to have nice, DRY definition of our environment :)
There is a workaround with using setValueAtPath, readFile, fromYaml, and get.
For your example, you would create something like these to get what you want:
Activity
Tarick commentedon Apr 11, 2019
I second this.
My use-case is similar - I have multiple app roles from the same monolith repo using the same config template, where vars can be different depending on the environment AND app role.
The only way to support this currently is to put this config template into each helm chart (not DRY) and this is hard to support further once that config is changed.
It would be great to have all previously merged values available in subsequent gotmpl values files.
mumoshu commentedon Apr 11, 2019
@nikolajbrinch @Tarick What a coincidence! I just discussed about similar things with my colleague today.
@nikolajbrinch In your example, where in
helmfile.yamldo you want to define thevalues.yaml, which seems not likereleases[].valuesbut anywhere else?@Tarick Makes sense, but it you can still use environment values and a regular values file template, like this:
And in
prod.yamlyou have:role1.values.yaml.gotmpl:So you want all the values.yaml files listed under
releases[].valuesto be merged one by one, and the latest merged values to be available in the next values.yaml template, right?foo.yaml.gotmpl:bar.yaml.gotmpl:Does the above result in the
barset tofoo, and there's alsofoo: barbecause it is merged into the second?Tarick commentedon Apr 11, 2019
@mumoshu
I can't due to the need of config file content to be rendered in the end, it doesn't know anything about role name.
e.g.
config-file.yaml.gotmpl:If I try to use
.Environment.Values.values.appRole1instead of.Values.externalDnsNamethis config-file.yaml.gotmpl will be valid only for that role and that breaks DRY.Yes, I would consider this as correct result.
I may be too spoiled by Ansible, where they merge all values in order and they are available for next file templated vars. If I remember correctly even if there is no value for a tempated var at the moment of merging, Ansible does the second pass on all files with already merged set.
sgandon commentedon Apr 11, 2019
Actually at first I thought that the
Defaultenvironment could be used for that but it turns out that the Default environment is not loaded if some other environment is specified in the command line.I would have expected that the default one would always be loaded and the specific environment could override it. But this is not the case.
So may be we could have some
globalenvironment that is always loaded before all the other environments and that can also be referenced withEnvironment.Valuesfrom the user created environments (and the default one) and from the helmfile itseft and the releases values files.I hope I am clear. here is an example
pros: augment an existing mechanism, values are still accessed using .Environment. Also environment values can override global ones.
cons: add 2 new semantics, the global without templates and the overriding mechanism.
Of course
globalcan be change to something else (initial) or even move upward a level and can be even renamedvalueslike this :pros: decouple the 2 semantics
cons: you need 2 mechanisms for getting access to values, Environment.Values and .Values. And you cannot override the global ones.
I would be in favor of the first solution and hope I understood the initial concern.
janekbaraniewski commentedon Jul 2, 2019
Hey! I also could use some way of accessing values from values. My use-case is pretty similar to @Tarick s one - I have a huge monolith project which actually is multiple applications all using same image, all using same configuration, only difference being the run command. I wanted to create a setup with generic
releasedefinition and have a list of enabled applications/components for each environment (f.e. on production I want all components deployed but on testenv I might want only few of them, or on my dev cluster I want only component I'm developing, etc.).So in my environment.yaml file I would have something like this :
and then in my helmfile I wanted to use range to generate release for each of those components:
But then I need some way of accessing
Release.Nameinside my values. I was thinking about just setting a value in my helmfile like that:But then again - I can't access it from within my values file.
I need the release name to be injected to run command inside my values file. Am I correct that this cannot be achieved ATM or have I missed something?
mumoshu commentedon Jul 3, 2019
Hey! You're correct on that this can't be achieved today.
Perhaps what we wan't isn't inheriting previous values.yaml contents to next ones, but rather a dedicated way to compose values injected to values.yaml templates.
What if helmfile added a syntax like this?
values/values.yaml:values/values-file.yaml.gotmpl:For
app1, this would result in renderingmy-chartwith the following values:and For
app2:janekbaraniewski commentedon Jul 22, 2019
Hey, sorry that I took so long to get back to you. That looks like a nice feature, definitely would help with figuring out how are different values overwritten and where they come from.
I was however able to solve my case! I used helmfile layering for that.
I have my "template" helmfile
component.yamlThen, I have a
helmfile.yamlfile :Since this value is available both in underlying helmfile and in values that releases from it use, this solves my case and allows us to have nice, DRY definition of our environment :)
maxchen-000 commentedon Apr 1, 2021
There is a workaround with using setValueAtPath, readFile, fromYaml, and get.
For your example, you would create something like these to get what you want:
environment.yaml
dev-values.yaml
test-values.yaml
values_level_variables.yaml
values.yaml.gotmpl
For dev environment this would render using the above values.yaml.gotmpl: