我嘗試使用 using 部署 prometheushttps://prometheus-community.github.io/helm-charts
但我想要一個自定義prometheus.yml因此我使用的方法是通過復制自定義 prometheus.yml 檔案來構建 prometheus docker 映像。(通過一個簡單的管道)
我使用的 Dockerfile
FROM quay.io/prometheus/prometheus:v2.26.0
ADD config /etc/config/
它成功構建了映像,當我嘗試通過 helm 部署此映像時,容器失敗并顯示以下錯誤。
level=error ts=2021-10-14T15:26:02.525Z caller=main.go:347 msg="Error loading config (--config.file=/etc/config/prometheus.yml)" err="open /etc/config/prometheus.yml: no such file or directory"
我不確定這是否是理想的方法。我該怎么做才能prometheus.yml在 prometheus pod 中進行自定義。(我可以在 helm 的 values.yaml 中設定配置,但我更喜歡有一個單獨的檔案。這樣我就可以輕松管理它)
uj5u.com熱心網友回復:
僅僅為了更改配置而構建映像并不是配置應用程式的便捷方式。考慮一下,每次需要更改配置時都必須更新映像(構建、推送、拉取)。此外,這個社區 Prometheus 堆疊有一種prometheus.yml通過values.yml進行自定義的簡單方法:
serverFiles:
prometheus.yml:
rule_files:
- /etc/config/recording_rules.yml
- /etc/config/alerting_rules.yml
- /etc/config/rules
- /etc/config/alerts
scrape_configs:
- job_name: prometheus
static_configs:
- targets:
- localhost:9090
您可以在serverFiles."prometheus.yml"key下添加所需的更改,然后只需重新部署堆疊。
uj5u.com熱心網友回復:
挑戰是將 prometheus.yml 作為單獨的檔案進行管理。我extraConfigmapMounts在社區 Prometheus 堆疊中找到了選項。
因此,使用 來創建 configMap 并將其prometheus.yml掛載到應用程式似乎是實作它的好方法。只需使用該值server.extraConfigmapMounts即可添加配置。
extraConfigmapMounts:
- name: prometheus-configmap
mountPath: /prometheus/config/
subPath: ""
configMap: <configMap name>
readOnly: true
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/323715.html
標籤:Kubernetes 文件 普罗米修斯 kubernetes-helm
