prometheus-operator部署模式为deployment,其应用operator框架开发,operator实质上是CRD+controller:
- CRD: prometheus/prometheusurle/alertmanager/serviceMonitor/podMonitor等;
- controller: 监听CRD的变动,批改相应的资源配置;
prometheus-operator蕴含的CRD:
- prometheus: 对prometheus-server的形象;
- serviceMonitor: 对service监控对象的形象;
- podMonitor: 对pod监控对象的形象;
- prometheusrule: 对prometheus报警规定的形象;
prometheus-operator的应用,根本是如何操作上述的CRD对象。
查看CRD类型:
# kubectl get crd |grep coreosalertmanagers.monitoring.coreos.com 2021-05-28T08:02:20Zpodmonitors.monitoring.coreos.com 2021-05-28T08:02:21Zprometheuses.monitoring.coreos.com 2021-05-28T08:02:22Zprometheusrules.monitoring.coreos.com 2021-05-28T08:02:23Zservicemonitors.monitoring.coreos.com 2021-05-28T08:02:24Zthanosrulers.monitoring.coreos.com 2021-05-28T08:02:25Z
查看特定CRD类型下的实例:
# kubectl get prometheuses -n monitoringNAME VERSION REPLICAS AGEk8s v2.20.0 2 46h
# kubectl get servicemonitors -n monitoringNAME AGEalertmanager 46hcoredns 46hetcd-k8s 19hkube-apiserver 46hkube-controller-manager 46hkube-scheduler 46hkube-state-metrics 46hkubelet 46hnode-exporter 46hprometheus 46hprometheus-adapter 46hprometheus-operator 46h
参考:
1.operator开发/部署:https://www.qikqiak.com/post/k8s-operator-101/