使用https://github.com/helm/charts/tree/master/stable/elasticsearch-exporter并尝试通过--set参数传递下面的部分,但到目前为止还没有运气。
podAnnotations:
prometheus.io/scrape: "true"
prometheus.io/port: "9108"
Run Code Online (Sandbox Code Playgroud)
到目前为止,我试过helm install --name prometheus-elasticsearch-exporter stable/elasticsearch-exporter用
--set podAnnotations."prometheus.io/scrape"=true,podAnnotations."prometheus.io/port"=9108
--set podAnnotations[0]."prometheus.io/scrape"=true,podAnnotations[0]."prometheus.io/port"=9108
--set podAnnotations."prometheus\.io\/scrape"=true,podAnnotations."prometheus\.io\/port"=9108
--set podAnnotations={"prometheus.io/scrape":true,"prometheus.io/port":9108}
--set podAnnotations={"prometheus.io/scrape"=true\,"prometheus.io/port"=9108}
Run Code Online (Sandbox Code Playgroud)
不幸的是,这些都没有奏效。
更多细节可以在这里找到
请尝试以下操作:
--set-string podAnnotations."prometheus\.io/scrape"=true \
--set-string podAnnotations."prometheus\.io/port"=9108
Run Code Online (Sandbox Code Playgroud)
您需要正确转义注释键字符串,如您链接的文档中所述:
同样,您也可以转义点序列,这在图表使用该
toYaml函数解析注释、标签和节点选择器时可能会派上用场。的语法--set nodeSelector."kubernetes\.io/role"=master变为Run Code Online (Sandbox Code Playgroud)nodeSelector: kubernetes.io/role: master
您应该使用set-string而不是set因为您希望注释值是字符串而不是 booleantrue和 number 9018。
这是我使用这些标志的结果:
$ helm template . \
--set-string podAnnotations."prometheus\.io/scrape"=true \
--set-string podAnnotations."prometheus\.io/port"=9108 \
| grep -C 5 annotations
template:
metadata:
labels:
app: elasticsearch-exporter
release: "release-name"
annotations:
prometheus.io/port: "9108"
prometheus.io/scrape: "true"
spec:
restartPolicy: Always
Run Code Online (Sandbox Code Playgroud)