Helm 快速部署 Prometheus
获取 Chart
prometheus 2.5.x LTS 是长期支持稳定版。
本案例选择 Promtheus v2.54.1 这个版本,对应 Chart 版本是 25.27.0
添加仓库:
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
查看 prometheus-community/prometheus
仓库历史版本的 Charts,选择一个版本
本实例选择最新的 Chart 25.27.0
,对应的 prometheus 版本为 v3.2.1,获取 Chart
# 获取离线 Chart
helm pull prometheus-community/prometheus --version 25.27.0
# 获取默认 values.yaml
helm show values prometheus-25.27.0.tgz > values-prometheus.yaml
默认依赖
默认情况下,此 Chart 会安装额外的依赖 Chart:
要在安装期间禁用依赖关系,请按需设置 false
alertmanager.enabled
kube-state-metrics.enabled
prometheus-node-exporter.enabled
prometheus-pushgateway.enabled
配置 values
prometheus
server:
# 数据持久化 CSI 云盘
persistentVolume:
size: 100Gi
storageClass: "cbs"
# 监控数据保存时长
retention: "30d"
# 使用 Ingress 暴露
ingress:
enabled: true
ingressClassName: ingressClassName
annotations:
prometheus.io/http-probe: "true"
prometheus.io/http-probe-path: /
hosts:
- prom.example.com
path: /
pathType: Prefix
tls:
- secretName: cert-star-example-com
hosts:
- prom.example.com
alertmanager
alertmanager
对数据库的持久化没有性能要求,这里使用 cfs
动态供给的存储类来实现。同样也改用 NodePort 暴露服务。
alertmanager:
enabled: true
persistence:
size: 10Gi # 10G 起步,实际按量付费
storageClass: "cfs"
# 使用 Ingress 暴露
ingress:
enabled: true
className: ingressClassName
annotations:
prometheus.io/http-probe: "true"
prometheus.io/http-probe-path: /
hosts:
- host: alert.example.com
paths:
- path: /
pathType: ImplementationSpecific
tls:
- secretName: cert-star-example-com
hosts:
- prom.example.com
提示
请将 ingress.className
, ingress.hosts
, ingress.tls
替换成你实际的配置。
安装 Chart
创建名称空间
kubectl create namespace prometheus
从 values.yaml 与本地 .tgz 离线安装包中安装 Chart
helm -n prometheus install prometheus prometheus-27.9.0.tgz -f values-prometheus.yaml