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
I have a use case where I want the .Release.Name to be used as a variable in a values.gotmpl file. However, no matter what I do, the values.gotmpl file will not render .Release.Name. Is this expected behavior? Are there suggestions on how to work around this?
My use case is that I have multiple deployments of the same app on the same kubernetes cluster with non-namespaced objects (specifically PVs and filepaths on an NFS server) that need to be given unique names. I am using the release name as a unique identifier to add as a prefix to these non-namespaced objects. So, if you can't use .Release.Name in a gotmpl file, is there any other way to pass a unique value to the gotmpl file and still run a single helmfile -f ... sync command?
Reacted by Brady Mitchell, Sergei Shishov, Flávio Ramalho, Ruslan Lutsenko, Shamil Kashmeri, Kyrylo Lebediev, Igor Kudrin and tejarspl
@mumoshu Thanks for the response, and it's really helpful to know that I wasn't just doing something stupid. If it's not a major change, I think being able to specify some kind of unique value that can be propagated to the values.gotmpl file would be very, very helpful for my use case. The problem is that I (for various reasons) need to specify pathOnNfs multiple places in the values.yaml file, and while I could conceivably set the values a bunch of times in the helmfile, that would clutter things up quickly.
This doesn't necessarily need to be the Release.Name. It could be something in the release like
and then in values.gotmpl you could have something like:
foo: {{ .Environment.Custom.Values.customValue }}
This would be more flexible in that you could always set customValue to Release.Name using double rendering in the helmfile. The big need for me, is that I need someway to specify per release values that need to be repeated several times in the values.gotmpl for a variety of reasons (generally because I'm using an existing chart and I am trying to avoid forking the chart).
There isn't any functionality currently like this in helmfile, right?
I know that I can call helmfile with something like CUSTOM="whatever" helmfile -f helmfile.yaml sync and then I can use the CUSTOM environmental variable, but it keeps me from using a single helmfile call to update all of my releases (and I can't easily version control that command).
Is this use case within scope for helmfile? If not, please don't make changes that aren't within the spirit of the tool.
A short-term solution to your problem would be to leverage sub-helmfile, like @janekbaraniewski has shared in #387 (comment).
In longer-term, the combination of double-rendering and per-release overrides as you've suggested seems like the best way forward!
Fortunately, we have a similar request that can accommodate your use-case as well. See the discussion starting from #745 (comment) - I think we can extend it so that you can rewrite your example as:
releases:
- name: yourappchart: yourchartset:
- valuesFrom:
templateFile:
path: values.gotmplvaluesFrom:
# Instead of implicitly passing helmfile's values to the values.gotmpl# explicitly set this so that it inherits all the helmfile values into the template rendering context of `values.gotmpl`
- valuesInherited: true# Overrides
- inline:
customValue: "whatever"
The syntax seems a bit verbose but the benefits are countless - I believe it does support your use-case, and also (1)it's completely backward-compatible, (2)has extensibility to support other value sources like AWS SSM, Vault, etc.
I too would like the ability to query .Release.Name from within the values files.
In my case I have some large configuration files for various components that make up the application; that are all stored in the values files to produce Kubernetes Secrets from that will be mounted as files in the containers.
These configuration files are supplied to multiple releases, and the content of which are mostly the same with a few values that need to differ across the releases.
Being able to test for .Release.Name from within the values files would let me do some conditional logic there to tailor the configs easily.
I think this should be a matter of adding a Release field to the template data(that is used as a collection of template params while rendering a values.yaml template here
I'd really like this to be available as well. I have taken a look at the code and doesn't seem that trivial as we have potentially numerous releases, but the EnvironmentSpec is more or less a global take on things.
My use-case is trying to use the .Release.Name in conjunction with namespacing ssm values:
I should mention that in the PR above, it also addresses the resolution of the ref+awsssm:// value interpolation (e.g., the Values plugin) as well. Using the double-quote trick it still didn't work originally.
For me, sometimes Relase.Name is interpolated, and sometimes, it does not... while using the same helm chart
Seems like we need to test more this feature.
For example, with jenkins helm chart, controller.ingress.hostName={{ .Release.Name }}.example.com never interpolated even using the other syntax :
Activity
mumoshu commentedon Jul 17, 2019
@albertmichaelj Hey!
Release.Nameis available only while rendering helmfile.yaml, not values file templates.As a work-around, can you extract the part of your
values.gotmplintohelmfile.yamllike:If not, I think this is a valid feature request, as I see no downside of improving helmfile to allow
.Release.Namewithinvalues.gotmpl.albertmichaelj commentedon Jul 17, 2019
@mumoshu Thanks for the response, and it's really helpful to know that I wasn't just doing something stupid. If it's not a major change, I think being able to specify some kind of unique value that can be propagated to the
values.gotmplfile would be very, very helpful for my use case. The problem is that I (for various reasons) need to specifypathOnNfsmultiple places in thevalues.yamlfile, and while I could conceivably set the values a bunch of times in the helmfile, that would clutter things up quickly.This doesn't necessarily need to be the
Release.Name. It could be something in the release likeand then in
values.gotmplyou could have something like:This would be more flexible in that you could always set
customValuetoRelease.Nameusing double rendering in the helmfile. The big need for me, is that I need someway to specify per release values that need to be repeated several times in thevalues.gotmplfor a variety of reasons (generally because I'm using an existing chart and I am trying to avoid forking the chart).There isn't any functionality currently like this in helmfile, right?
I know that I can call helmfile with something like
CUSTOM="whatever" helmfile -f helmfile.yaml syncand then I can use theCUSTOMenvironmental variable, but it keeps me from using a single helmfile call to update all of my releases (and I can't easily version control that command).Is this use case within scope for helmfile? If not, please don't make changes that aren't within the spirit of the tool.
Thanks!
mumoshu commentedon Jul 23, 2019
@albertmichaelj Hey!
A short-term solution to your problem would be to leverage sub-helmfile, like @janekbaraniewski has shared in #387 (comment).
In longer-term, the combination of double-rendering and per-release overrides as you've suggested seems like the best way forward!
Fortunately, we have a similar request that can accommodate your use-case as well. See the discussion starting from #745 (comment) - I think we can extend it so that you can rewrite your example as:
The syntax seems a bit verbose but the benefits are countless - I believe it does support your use-case, and also (1)it's completely backward-compatible, (2)has extensibility to support other value sources like AWS SSM, Vault, etc.
WDYT?
albertmichaelj commentedon Jul 23, 2019
Thanks for your response! I think I understand the new syntax, but I'm not sure exactly how you would access the
customValue. Would it be like:with the idea being that the
overrides anything in the existing environment? If that is the case, then that would absolutely fit my use case.
Do you have a timeline for implementing this feature? No worries if not, I'm just curious. Thanks again!
sshishov commentedon Mar 6, 2020
I am also waiting for the same solution! Need to propagate some variables to values file
jim-barber-he commentedon Apr 6, 2020
I too would like the ability to query
.Release.Namefrom within the values files.In my case I have some large configuration files for various components that make up the application; that are all stored in the values files to produce Kubernetes Secrets from that will be mounted as files in the containers.
These configuration files are supplied to multiple releases, and the content of which are mostly the same with a few values that need to differ across the releases.
Being able to test for
.Release.Namefrom within the values files would let me do some conditional logic there to tailor the configs easily.skashmeri commentedon Apr 25, 2020
@mumoshu is there any chance of seeing this feature getting added to helmfile?
mumoshu commentedon Apr 25, 2020
Could anyone submit a pull request for this?
I think this should be a matter of adding a
Releasefield to the template data(that is used as a collection of template params while rendering a values.yaml template herehelmfile/pkg/state/state.go
Line 1727 in 3a19a39
joshes commentedon Aug 21, 2020
I'd really like this to be available as well. I have taken a look at the code and doesn't seem that trivial as we have potentially numerous releases, but the EnvironmentSpec is more or less a global take on things.
My use-case is trying to use the
.Release.Namein conjunction with namespacingssmvalues:I'll continue to see how this can be added, any additional pointers welcome.
Edit:
I just realized that the
.Release.Namewould indeed render in this location with the double-quote trick:And that my issue with
ssmis order of operations. Seems the template isn't rendered by the time its passed to thevalsservice.joshes commentedon Aug 24, 2020
I should mention that in the PR above, it also addresses the resolution of the
ref+awsssm://value interpolation (e.g., the Values plugin) as well. Using the double-quote trick it still didn't work originally.feat: Allow .Release.Name to be used in gotmpl values templates (#1424)
abdennour commentedon Mar 3, 2021
For me, sometimes Relase.Name is interpolated, and sometimes, it does not... while using the same helm chart
Seems like we need to test more this feature.
For example, with jenkins helm chart,
controller.ingress.hostName={{ .Release.Name }}.example.comnever interpolated even using the other syntax :Does not work