Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use --set to set values with Prometheus chart?

For example, set alertmanager.ingress.annotations to add two items, both of these two methods not work:

$ helm install stable/prometheus \
  --set alertmanager.ingress.enabled=true \
  --set "alertmanager.ingress.annotations={alb.ingress.kubernetes.io/scheme: internet-facing, alb.ingress.kubernetes.io/tags: Environment=dev,Team=test}"

Error: YAML parse error on prometheus/templates/alertmanager-ingress.yaml: error unmarshaling JSON: json: cannot unmarshal array into Go struct field .annotations of type map[string]string
$ helm install stable/prometheus \
  --set alertmanager.ingress.enabled=true \
  --set "alertmanager.ingress.annotations={'alb.ingress.kubernetes.io/scheme': 'internet-facing', 'alb.ingress.kubernetes.io/tags': 'Environment=dev,Team=test'}"

Error: YAML parse error on prometheus/templates/alertmanager-ingress.yaml: error unmarshaling JSON: json: cannot unmarshal array into Go struct field .annotations of type map[string]string

So how to use it?

like image 385
online Avatar asked Jan 30 '18 14:01

online


1 Answers

You want to achieve the following (cut from values.yaml from prometheus helm chart):

alertmanager:
  ingress:
    ## If true, alertmanager Ingress will be created
    ##
    enabled: true

    ## alertmanager Ingress annotations
    ##
    annotations: {
      alb.ingress.kubernetes.io/scheme: internet-facing, 
      alb.ingress.kubernetes.io/tags: 'Environment=dev,Team=test'
    }

According to helm documentation, the structure:

alertmanager:
  ingress:
    annotations:
      alb.ingress.kubernetes.io/scheme: internet-facing

is

--set alertmanager.ingress.annotations."alb\.ingress\.kubernetes\.io/scheme"=internet-facing

If you want to add one more annotation, it will be one more --set statement:

--set alertmanager.ingress.annotations."alb\.ingress\.kubernetes\.io/tags"="Environment=dev\,Team=test"

And one more thing, name: "value1,value2" is --set name=value1\,value2, so Environment=dev,Team=test is "Environment=dev\,Team=test".

The final helm command is:

helm install stable/prometheus --set alertmanager.ingress.enabled=true --set alertmanager.ingress.annotations."alb\.ingress\.kubernetes\.io/scheme"=internet-facing --set alertmanager.ingress.annotations."alb\.ingress\.kubernetes\.io/tags"="Environment=dev\,Team=test"

p.s. Above command fails, because you need to specify domain name for alertmanager as well. The correct one is:

helm install stable/prometheus --set alertmanager.ingress.enabled=true --set alertmanager.ingress.annotations."alb\.ingress\.kubernetes\.io/scheme"=internet-facing --set alertmanager.ingress.annotations."alb\.ingress\.kubernetes\.io/tags"="Environment=dev\,Team=test" --set alertmanager.ingress.hosts[0]=alertmanager.domain.com
like image 63
nickgryg Avatar answered Oct 20 '22 17:10

nickgryg