helm3安装prometheus-stack
作者:互联网
条件:
helm3+
k8s1.16+
需要更新几个crd对象,不然安装时会报错,提示认不到相关的字段:
[root@master prometheus]# helm install prom-stack prometheus-community/kube-prometheus-stack -n middleware Error: unable to build kubernetes objects from release manifest: error validating "": error validating data: [ValidationError(Alertmanager.spec): unknown field "alertmanagerConfigNamespaceSelector" in com.coreos.monitoring.v1.Alertmanager.spec, ValidationError(Alertmanager.spec): unknown field "alertmanagerConfigSelector" in com.coreos.monitoring.v1.Alertmanager.spec]
开始
1、下载并安装相关的yaml文件
kubectl apply -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.45.0/example/prometheus-operator-crd/monitoring.coreos.com_alertmanagers.yaml && \ kubectl apply -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.45.0/example/prometheus-operator-crd/monitoring.coreos.com_podmonitors.yaml && \ kubectl apply -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.45.0/example/prometheus-operator-crd/monitoring.coreos.com_probes.yaml && \ kubectl apply -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.45.0/example/prometheus-operator-crd/monitoring.coreos.com_prometheuses.yaml && \ kubectl apply -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.45.0/example/prometheus-operator-crd/monitoring.coreos.com_prometheusrules.yaml && \ kubectl apply -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.45.0/example/prometheus-operator-crd/monitoring.coreos.com_servicemonitors.yaml && \ kubectl apply -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.45.0/example/prometheus-operator-crd/monitoring.coreos.com_thanosrulers.yaml
此处如果不能直接执行,需要分别将yaml文件下载到本地再使用kubectl apply -f $file
2、使用helm安装
helm install prom-stack prometheus-community/kube-prometheus-stack -n middleware
3、pod运行时会有个别从k8s.gcr.io镜像仓库拉取的pod会拉取不到
prom-stack-kube-state-metrics-6b64fdd9d9-7fwgf 0/1 ImagePullBackOff 0 6m12s
使用
kubectl -n middleware describe pod prom-stack-kube-state-metrics-6b64fdd9d9-7fwgf
发现它是从k8s.gcr.io拉取的,国内是无法拉取的,所以需要拉取地址,这里我更换成如下地址:
quay.io/coreos/kube-state-metrics:v1.9.8
4、更换后使用kubectl -n middleware get pod 查看,都是Running:
prom-stack-grafana-7d584fc9f8-wwjqt 2/2 Running 0 23m prom-stack-kube-prometheus-operator-8b659f59f-9pg62 1/1 Running 0 23m prom-stack-kube-state-metrics-5f5f594b45-q285l 1/1 Running 0 15m prom-stack-prometheus-node-exporter-7p4xt 1/1 Running 0 23m prom-stack-prometheus-node-exporter-8g6v6 1/1 Running 0 23m prom-stack-prometheus-node-exporter-vdxvc 1/1 Running 0 23m prometheus-prom-stack-kube-prometheus-prometheus-0 2/2 Running 4 21m
标签:helm3,prometheus,prom,coreos,operator,com,stack 来源: https://blog.51cto.com/riverxyz/2704831