gpt4 book ai didi

json - 如何使用 --set 为 Prometheus 图表设置值?

转载 作者:行者123 更新时间:2023-12-02 03:01:29 24 4
gpt4 key购买 nike

例如设置alertmanager.ingress.annotations添加两个item,这两种方法都不起作用:

$ 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

那么如何使用呢?

最佳答案

您希望实现以下目标(从 prometheus helm 图表中截取 values.yaml):

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=测试“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"

附:上面的命令失败,因为您还需要为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

关于json - 如何使用 --set 为 Prometheus 图表设置值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48523661/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com