Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set multiple values with helm?

Use helm install can set value when install a chart like:

helm install --set favoriteDrink=slurm ./mychart

Now want to set value like:

helm install --set aws.subnets="subnet-123456, subnet-654321" ./mychart

But failed:

Error: failed parsing --set data: key " subnet-654321" has no value

It seems that helm's --set know comma , and check the next string as a key. So can't use in this case when set such string?


Tested this way

helm install charts/mychart \
    --set aws.subnets={subnet-123456,subnet-654321}

Got error:

Error: This command needs 1 argument: chart name

This way works

helm install charts/mychart \
    --set aws.subnets="subnet-123456\,subnet-654321"

Reference

https://helm.sh/docs/intro/using_helm/#the-format-and-limitations-of---set

like image 900
online Avatar asked Jan 18 '18 07:01

online


People also ask

Can Helm use multiple values files?

Yes, it's possible to have multiple values files with Helm. Just use the --values flag (or -f ). You can also pass in a single value using --set . --set (and its variants --set-string and --set-file): Specify overrides on the command line.

How do I set Helm value?

You can use a --set flag in your Helm commands to override the value of a setting in the YAML file. Specify the name of the setting and its new value after the --set flag in the Helm command. The --set flag in the above command overrides the value for the <service>. deployment.

How do I set the values of a helm chart?

A chart’s values.yaml file A values file supplied by helm install -f or helm upgrade -f The values passed to a --set or --set-string flag on helm install or helm upgrade When designing the structure of your values, keep in mind that users of your chart may want to override them via either the -f flag or with the --set option.

Is it possible to have multiple values files with Helm?

Yes, it's possible to have multiple values files with Helm. Just use the --valuesflag (or -f).

How to install helm chart with multiple values in YAML?

Here the command for installing the helm chart using multiple values.yaml How to understand the command? -f my-first-value.yaml -f my-second-value.yaml - This is how we pass multiple value.yaml inside helm install command

How do I create dynamic values in helm using a shell script?

A shell script can provide a dynamic value capability. In this example, the shell script prompts the user for input and then injects the user’s input into the Helm chart via the --set argument. The previous example is not possible using a values.yaml file. Helm offers two methods of defining array values on the command line.


Video Answer


3 Answers

According to https://github.com/kubernetes/helm/issues/1987#issuecomment-280497496, you set multiple values using curly braces, for example:

--set foo={a,b,c}

So, in your case it would be like this

--set aws.subnets={subnet-123456,subnet-654321}
like image 197
Javier Salmeron Avatar answered Oct 19 '22 18:10

Javier Salmeron


The CLI format and limitations can vary depending on what would be expected in a YAML version. For example, if the YAML manifest requires fields to be populated with a list of values the YAML would look like this:

field:
  - value1
  - value2
  - value3 

This would be expressed in the helm CLI like so

--set field[0]=value1 --set field[1]=value2 --set field[2]=value3

The documentation also refers to --set field={value1,value2,value3} working. In some cases that results in Error: This command needs 1 argument: chart name which is why I provide the above suggestion

There are also limitations to what characters may be used per the documentation:

You can use a backslash to escape the characters; --set name="value1\,value2" will become:

name: "value1,value2"
like image 12
Marc Avatar answered Oct 19 '22 20:10

Marc


With this change being merged, Helm now supports using multiple --set command with helm install command.

Taking from the link mentioned above:

Manually tested, and looks awesome!

⇒  helm install --dry-run --debug docs/examples/alpine \
  --set foo=bar \
  --set bar=baz,baz=lurman \
  --set foo=banana

SERVER: "localhost:44134"
CHART PATH: /Users/mattbutcher/Code/Go/src/k8s.io/helm/docs/examples/alpine
NAME:   masked-monkey
REVISION: 1
RELEASED: Thu Jan 12 17:09:07 2017
CHART: alpine-0.1.0
USER-SUPPLIED VALUES:
bar: baz
baz: lurman
foo: banana

COMPUTED VALUES:
Name: my-alpine
bar: baz
baz: lurman
foo: banana
...

As expected, the last --set overrode the first --set.

P.S: Upgrade your Helm version in case this doesn't work for you. It worked perfectly for me with Helm-v3.0.1.

like image 9
Amit Yadav Avatar answered Oct 19 '22 18:10

Amit Yadav