prometheus-operator默认部署2个prometheus POD,并且被优先调度到master节点。

2个prometheus实例

查看prometheus CRD对象的定义,可以看出,部署了2个实例:

# vi prometheus-prometheus.yaml

  ......
  image: "178.104.162.39:443/dev/huayun/amd64/prometheus:v2.20.0"
  ......
  replicas: 2
  ......

在kubernetes集群中,prometheus以statefulset方式部署:

# kubectl get all -n monitoring |grep prometheus-k8s
pod/prometheus-k8s-0                       3/3     Running   1          19d
pod/prometheus-k8s-1                       3/3     Running   1          19d
service/prometheus-k8s          NodePort    10.233.50.253   <none>        9090:32500/TCP               20d
statefulset.apps/prometheus-k8s      2/2     20d

2个prometheus实例的关系

两个prometheus实例是独立、对等的关系,相互之间并不感知。

  • scrape对象相同:prometheus.yaml内容一致;
  • alertmanager的配置相同:当有告警时,2个prometheus实例同时发送到alertmanager,alertmanager集群会进行告警的去重

若两个实例都配置了remote_write到influxdb,则每份指标会存入influxdb两次,但是会用prometheus_replica区分是来自哪个实例:


a朋
63 声望38 粉丝