Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting nested data structures from helm command line?

I'm installing the prometheus-redis-exporter Helm chart. Its Deployment object has a way to inject annotations:

# deployment.yaml
...
  template:
    metadata:
      annotations:
{{ toYaml .Values.annotations | indent 8 }}

Typically if I was providing a values file, I could just do this:

# values.yaml
annotations:
  foo: bar
  bash: baz

And then install the chart with:

helm install --values values.yaml

However, in some cases it is more simple for me to specify these values on the command line with --set instead, I'm just not sure how I would specify a nested set like that.

How can I set the above annotations object when installing a helm chart on the commandline:

helm install --set <what_goes_here>
like image 338
Cory Klein Avatar asked Oct 05 '18 15:10

Cory Klein


People also ask

What is the use of Helm command?

The main function of Helm is Kubernetes app management. Besides the basic operations of installing and uninstalling apps, Helm enables you to perform test installations and customize the installation process.

How do you update helm chart with new values?

To perform a helm release upgrade using the CLI, run the following command provided: helm upgrade <release name> <chart directory> -f my-values. yaml using the configuration specified in the customized values. yaml file. After a successful upgrade, the helm will return the following message.


Video Answer


2 Answers

The helm docu has a section The Format and Limitations of --set, which contains what you are looking for.

--set outer.inner=value results in:

outer:
  inner: value

Therefore your whole helm command looks like this:

helm install --set annotations.foo=bar,annotations.bash=baz stable/prometheus-redis-exporter
like image 135
adebasi Avatar answered Oct 23 '22 14:10

adebasi


Just to add, if you are looking to override a key with a "." in the key name, add a back slash ("\") before the ".".

for example, with values (taken from grafana):

grafana.ini:
  server:
    root_url: https://my.example.com

To edit the root_url value we would pass --set grafana\.ini.server.root_url=https://your.example.com

like image 14
Daniel Reisel Avatar answered Oct 23 '22 14:10

Daniel Reisel