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
If this is already possible, please do tell.. And update the docs to show how.
Reacted by Alex Emelyanov, ykfq, boosh, Alexander Zubkov, Hadrien TOMA, jtlz2, Aymeric Beaumet, Ryan Hartje, Cameron Hudson, ichtestemalwieder and 23 more
Reacted by Ilya Sotkov, Denis Krivak, Renault Young, hmacias, Sébastien OUDRY, Pavel Vaysberg, Alex Emelyanov, Jorge Madrid, Rocky Madden, Vadim Eisenberg and 114 more
Reacted by mzyfree, Anton Karmanov, sanjeevSinha and Mirko Stölzel
Reacted by Lam Chan, Cameron, Eduardo Roldan, Paulo Almeida, Darrien Glasser, someunknowndeveloper, Trevor Bortins, Pantelis Karamolegkos, Wouter Reyntjens, CuBiC and 4 more
Reacted by Hong, Ondrej Sika, Vladimir Kozyrev, jtlz2, Paulo Almeida, René Klačan, Adam Noll, Hans-Jörg Wieland, Antoine, Justin Abrahms and 10 more
Reacted by Viacheslav Kim, Vishrant Gupta, Toni Röyhy, Dražen Perić, Manjunath Shivanna, Laurent Debacker, 王贺, Mamoun Saudi, Timo Mühlbach, Martin Kiesel and 11 more
That strategy will simply make it easier to reference them from --set, while also being pretty easy to work with in templates.
As you probably noticed from the documentation, there is no way in the current --set syntax to access an array value by index. So working with arrays is sort of a pain.
Reacted by Vishrant Gupta, Zandeer, Jon Logan, nzolot, Felipe Lambert, Martin Kiesel, Harry Lee, Shane O'Brien, Josh Woodcock, Chris Levi and 30 more
I'm looking for ways to set an array using set, but it's unclear to me what the above statement means? Is it possible to set an array with set, or isn't it? If it's sort of a pain, then I don't mind, but I'd like to find out how to do it.
I know I can convert the array to a map, but that's not really what I'm looking for, as the user experience (for an internal company-wide chart) degrades to work around a technical issue.
I'm not saying this should be possible, but if it's not, we should probably mention this clearly in the documentation. (and if it already is, then I'm sorry, I must have missed it)
Reacted by Josh Reichardt, Dan Farrell, Pantelis Karamolegkos, menya, Iordanis Sapidis and Ritesh Sonawane
Lists can be expressed by enclosing values in { and }. For example, --set name={a, b, c} translates to:
name:
- a
- b
- c
Reacted by Hadrien TOMA, Jeronimo Garcia, Rafael Botelho, Pete Cornish, Elouan Keryell-Even, Cyril Scetbon, xiaooloong, Abilash Rajasekaran, 180254, Ivan Mesic and 1 more
Should I write in
--set=affinity.podAntiAffinity.requiredDuringSchedulingIgnoredDuringExecution.labelSelector.matchExpressions.key=app,affinity.podAntiAffinity.requiredDuringSchedulingIgnoredDuringExecution.labelSelector.matchExpressions.operator=In,affinity.podAntiAffinity.requiredDuringSchedulingIgnoredDuringExecution.labelSelector.matchExpressions.values=mongodb-replicaset,affinity.podAntiAffinity.requiredDuringSchedulingIgnoredDuringExecution.topologyKey=kubernetes.io/hostname
If someone googles how to pass imagePullSecrets via --set flag, here is the command:
For example, helm template with imagePullSecrets like this one:
spec:
{{- with .Values.imagePullSecrets }}imagePullSecrets:
{{- toYaml . | nindent 8 }}{{- end }}
command:
--set 'imagePullSecrets[0].name=regcred'
Reacted by Hasan Turken, Gennady Temnikov, Martin Andersen, Julien Bouquillon, Alejandro Llanes, Manjunath Shivanna, Anton Kvashenkin, Denis Iskandarov, Jaydeep Solanki, Rain Zheng and 13 more
@pkaramol I hope you already figured this out, but since the master.installPlugin value you're passing isn't quoted, it treats your argument to --set as master.installPlugins={kubernetes:1.21.2, , and then attempts to parse workflow-job:2.36} as your next argument. You need to remove the space between list items as that space would be treated literally if the curly braces were properly quoted, but if you remove the space and are using a shell which would attempt to expand {1,2,3} (such as bash), you will also need to quote the outside of the curly braces (which also means you want to remove the single quotes from your array element values, unless the values should be strings which include literal quotes)
@intellix re Gitlab, I also stumbled across the need to pass an arbitrary number of environment variables to our helm chart whilst using set. I ended up with this hacky CSV to array solution but I'd be interested if you or anyone else had a better suggestion:
Reacted by Abhay Garg, Steve Liang, Valentin Bud, Amirhossein Movahedi, Marcelo Andrade, shonge, Hamza, Sam Mingo, Karim Heraud, Rolf Schick and 3 more
set using an array list destroy the values yaml structure
I have powershell script to set a collection of values to a single key in values.yaml
But when I execute the The script result like this.
Actually I want the values like this, But i got this structure only use the set flag like this helm upgrade testing testconfig --set "KeyvautCollection={may0,may1}" I want to pass a dynamic array along with --set flag
In case when a value could be either a single string, or multiple strings, using toStrings in a template makes it much easier to override. In the following setup, it is possible to use --set foo.mylist=bar to override a,b,c list with a single value bar, while still treating it as a list.
values.yaml
foo:
mylist: ["a", "b", "c"]
templates/foo.yaml
{{- range $val := .Values.foo.mylist | toStrings }}
{{- $val }}
{{- end }}
Activity
technosophos commentedon Feb 16, 2017
Array values can be specified using curly braces:
--set foo={a,b,c}. This will translate to the YAML:Maps have to be passed like this:
something.key=value,something.key2=value2, which will translate to the YAML:The full documentation for
--setis buried in this document: https://github.com/kubernetes/helm/blob/master/docs/using_helm.md#the-format-and-limitations-of---setpluttrell commentedon Feb 17, 2017
@technosophos Many thanks for responding.
After reading the referenced doc, I still don't see how to reference the following via
--set:Is there a way to do this?
technosophos commentedon Feb 17, 2017
I believe that the most straightforward way to do that would be to alter the structure of values.yaml into something like this:
That strategy will simply make it easier to reference them from
--set, while also being pretty easy to work with in templates.As you probably noticed from the documentation, there is no way in the current
--setsyntax to access an array value by index. So working with arrays is sort of a pain.JeanMertz commentedon Apr 22, 2017
I'm looking for ways to set an array using
set, but it's unclear to me what the above statement means? Is it possible to set an array withset, or isn't it? If it's sort of a pain, then I don't mind, but I'd like to find out how to do it.I know I can convert the array to a map, but that's not really what I'm looking for, as the user experience (for an internal company-wide chart) degrades to work around a technical issue.
I'm not saying this should be possible, but if it's not, we should probably mention this clearly in the documentation. (and if it already is, then I'm sorry, I must have missed it)
bacongobbler commentedon Apr 22, 2017
From the documentation:
cabrinoob commentedon Aug 23, 2017
@pluttrell : Maybe
--set autoscalingGroups[0].name=my-asg-name --set autoscalingGroups[0].maxSize=50 --set autoscalingGroups[0].minSize=2
yanhongwang commentedon Jun 26, 2018
Hello all,
Do you know how about this structure of 'affinity'.
P.S: The indents unfortunately disappear when shown in Github web page.
###################################################
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- mongodb-replicaset
topologyKey: kubernetes.io/hostname
##################################################
Should I write in
--set=affinity.podAntiAffinity.requiredDuringSchedulingIgnoredDuringExecution.labelSelector.matchExpressions.key=app,affinity.podAntiAffinity.requiredDuringSchedulingIgnoredDuringExecution.labelSelector.matchExpressions.operator=In,affinity.podAntiAffinity.requiredDuringSchedulingIgnoredDuringExecution.labelSelector.matchExpressions.values=mongodb-replicaset,affinity.podAntiAffinity.requiredDuringSchedulingIgnoredDuringExecution.topologyKey=kubernetes.io/hostname
Or some other correct syntax?
Thanks very much.
Hong
cabrinoob commentedon Jun 27, 2018
I think that when you have to apply complexe modifications like these, you'd better have to put them in a file intead of using --set.
yanhongwang commentedon Jun 27, 2018
Hello @cabrinoob
Thanks for your recommendation.
That's true that I used --values=values.yaml to adapt appropriated value.
So there is no syntax to express affinity syntax by --set, right?
Thanks very much.
Hong
cabrinoob commentedon Jun 27, 2018
You do not have to have the same structure in your
values.yamlfile than in yourdeployment.yamlresource.You can have a relatively "flat" structure in values.yaml that makes usage of
--setmore simple.yanhongwang commentedon Jun 27, 2018
Hello @cabrinoob
Thanks for your comments.
But, I saw the most of charts application in https://github.com/kubernetes/charts/tree/master/stable
For example:
#############################################
values.yaml
affinity: {}
deployment.yaml
{{- with .Values.affinity }}
affinity:
{{ toYaml . | indent 8 }}
{{- end }}
############################################
Is that mean that deployment file needed to be patched when desired?
Thanks.
BR
Hong
cabrinoob commentedon Jun 27, 2018
yanhongwang commentedon Jun 28, 2018
@cabrinoob
Thanks for suggestion.
1 remaining item
jugatsu commentedon Jan 6, 2020
If someone googles how to pass
imagePullSecretsvia--setflag, here is the command:For example, helm template with
imagePullSecretslike this one:command:
--set 'imagePullSecrets[0].name=regcred'pkaramol commentedon Jan 21, 2020
According to this suggestion bt @technosophos , I should be able to run the following:
However this fails:
Have tried enclosing the element lists to single, double and no quotes.
Any suggestions?
HartS commentedon Feb 22, 2020
@pkaramol I hope you already figured this out, but since the
master.installPluginvalue you're passing isn't quoted, it treats your argument to--setasmaster.installPlugins={kubernetes:1.21.2,, and then attempts to parseworkflow-job:2.36}as your next argument. You need to remove the space between list items as that space would be treated literally if the curly braces were properly quoted, but if you remove the space and are using a shell which would attempt to expand{1,2,3}(such as bash), you will also need to quote the outside of the curly braces (which also means you want to remove the single quotes from your array element values, unless the values should be strings which include literal quotes)davidwindell commentedon Jun 24, 2020
@intellix re Gitlab, I also stumbled across the need to pass an arbitrary number of environment variables to our helm chart whilst using set. I ended up with this hacky CSV to array solution but I'd be interested if you or anyone else had a better suggestion:
--set app.extraEnv="ENVVAR1=foo\,ENVVAR2=bar\,ENVVAR3=bat"weironz commentedon Aug 28, 2020
values.yaml示例
变量配置方式
gargabhay1999 commentedon Aug 31, 2020
Thanks @willzhang . Your solution made by day <3
hari4147 commentedon Aug 26, 2022
set using an array list destroy the values yaml structure
But when I execute the The script result like this.


Actually I want the values like this, But i got this structure only use the set flag like this helm upgrade testing testconfig --set "KeyvautCollection={may0,may1}"
I want to pass a dynamic array along with --set flag
madrisan commentedon Aug 26, 2022
@hari4147 stackoverflow.com is a way better site for this type of questions.
hari4147 commentedon Aug 26, 2022
Add documentation for needs parameterization. (helm#1987)
nyurik commentedon Apr 28, 2024
In case when a value could be either a single string, or multiple strings, using
toStringsin a template makes it much easier to override. In the following setup, it is possible to use--set foo.mylist=barto overridea,b,clist with a single valuebar, while still treating it as a list.values.yamltemplates/foo.yaml