例如,设置alertmanager.ingress.annotations
以添加两个项目,这两种方法都不起作用:
$ 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
那么如何使用呢?
答案 0 :(得分:10)
您希望实现以下目标(从values.yaml
掌舵图中prometheus
切割):
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'
}
根据helm documentation,结构:
alertmanager:
ingress:
annotations:
alb.ingress.kubernetes.io/scheme: internet-facing
是
--set alertmanager.ingress.annotations."alb\.ingress\.kubernetes\.io/scheme"=internet-facing
如果您想再添加一个注释,它将是另外一个--set
语句:
--set alertmanager.ingress.annotations."alb\.ingress\.kubernetes\.io/tags"="Environment=dev\,Team=test"
还有一件事,name: "value1,value2"
是--set name=value1\,value2
,因此Environment=dev,Team=test
是"Environment=dev\,Team=test"
。
最终的helm命令是:
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。上面的命令失败,因为您还需要为alertmanager指定域名。 正确的是:
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