https://github.com/prometheus-community/helm-charts

prometheus operator源码:https://github.com/prometheus-operator/prometheus-operator

kube prometheus yaml部署文件:https://github.com/prometheus-operator/kube-prometheus/tree/main/manifests,prometheus-operator的相关yaml文件在`manifests/setup`中。

基于Kube-Prometheus的manifests yaml文件,自己做的chart包:http://www.mydlq.club/article/10/

Kube-Prometheus与k8s的版本对应关系,在哪确认?

kube-prometheus stack 1.14 1.15 1.16 1.17 1.18 1.19 1.20 1.21 1.22 1.23 Kubernetes 1.24
release-0.3
release-0.4 × × √(v1.16.5+)
release-0.5 × × ×
release-0.6 × × ×
release-0.7 × × ×
release-0.8 × × ×
release-0.9 × × ×
release-0.10 × × ×
release-0.11
main

prometheus operator 使用 CRD 机制对 Kubernetes API 进行扩展。

一、安装

参考链接:https://bbs.huaweicloud.com/blogs/303137

yaml文件归类后,记得调整下prometheus和alertmanager的副本数,默认是3。

镜像可能会下载超时,可以用quay.mirrors.ustc.edu.cn/coreos/prometheus-operator:v0.40.0来代替。

1
2
3
4
5
6
7
8
sed -i 's/quay.io/quay.mirrors.ustc.edu.cn/g' setup/prometheus-operator-deployment.yaml
sed -i 's/quay.io/quay.mirrors.ustc.edu.cn/g' prometheus-prometheus.yaml
sed -i 's/quay.io/quay.mirrors.ustc.edu.cn/g' alertmanager-alertmanager.yaml
sed -i 's/quay.io/quay.mirrors.ustc.edu.cn/g' kube-state-metrics-deployment.yaml
sed -i 's/quay.io/quay.mirrors.ustc.edu.cn/g' node-exporter-daemonset.yaml
sed -i 's/quay.io/quay.mirrors.ustc.edu.cn/g' prometheus-adapter-deployment.yaml
sed -i 's/quay.io/quay.mirrors.ustc.edu.cn/g' blackbox-exporter-deployment.yaml
sed -i 's#k8s.gcr.io/kube-state-metrics/kube-state-metrics#bitnami/kube-state-metrics#g' kube-state-metrics-deployment.yaml

二、部署后问题

prometheus target

1、Prometheus 日志报:kubelete Error on ingesting samples that are too old or are too far into the future