Prometheus Operator — Kubernetes-Native Monitoring Stack Management
Prometheus Operator simplifies deploying and managing Prometheus, Alertmanager, and related monitoring components on Kubernetes using custom resources and reconciliation loops.
Agent 可直接安装
这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。
npx -y tokrepo@latest install 064a2633-3943-11f1-9bc6-00163e2b0d79 --target codex先 dry-run 确认安装计划,再运行此命令。
What it is
Prometheus Operator is a Kubernetes operator that automates the deployment and management of Prometheus, Alertmanager, and related monitoring components. Instead of writing raw Kubernetes manifests for monitoring infrastructure, you define custom resources like Prometheus, ServiceMonitor, and AlertmanagerConfig. The operator watches these resources and reconciles the actual state to match your declarations.
Prometheus Operator targets SREs, DevOps engineers, and platform teams who run Kubernetes and need a production-grade monitoring stack that scales with their cluster without manual configuration management.
How it saves time or tokens
Without the operator, deploying Prometheus on Kubernetes requires managing StatefulSets, ConfigMaps with scrape configs, RBAC rules, and persistent volumes manually. The operator handles all of this through custom resources. Adding a new scrape target is as simple as creating a ServiceMonitor resource; the operator automatically updates the Prometheus configuration.
For teams managing multiple clusters, the operator provides a consistent, declarative approach to monitoring that can be versioned and replicated through GitOps workflows.
How to use
- Install the Prometheus Operator using Helm:
helm install prometheus prometheus-community/kube-prometheus-stack. This deploys Prometheus, Alertmanager, Grafana, and the operator. - Create a
ServiceMonitorcustom resource to scrape metrics from your application. The operator detects the resource and configures Prometheus automatically. - Define alerting rules with
PrometheusRuleresources. The operator loads them into Prometheus without manual config reloads.
Example
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: my-app-monitor
labels:
release: prometheus
spec:
selector:
matchLabels:
app: my-app
endpoints:
- port: metrics
interval: 30s
path: /metrics
This ServiceMonitor tells Prometheus to scrape the /metrics endpoint of any service labeled app: my-app every 30 seconds. No manual Prometheus config editing required.
Related on TokRepo
- DevOps tools — Infrastructure and operations tooling
- Monitoring tools — Observability and alerting solutions
Common pitfalls
- ServiceMonitor labels must match the Prometheus resource's
serviceMonitorSelector. If your monitors are not being picked up, check the label matching between Prometheus and ServiceMonitor resources. - The kube-prometheus-stack Helm chart deploys many components by default (Grafana, node-exporter, kube-state-metrics). Disable components you do not need to reduce resource usage.
- Prometheus stores metrics locally by default. For long-term retention, configure a remote write destination like Thanos, Cortex, or Mimir.
常见问题
Prometheus is the monitoring system that scrapes and stores metrics. Prometheus Operator is a Kubernetes operator that automates deploying and configuring Prometheus using custom resources. The operator manages the lifecycle of Prometheus instances on Kubernetes.
Yes. You can configure multiple Prometheus replicas through the Prometheus custom resource. The operator handles replica management, and tools like Thanos can deduplicate data across replicas for HA queries.
Yes. You can deploy the operator using raw Kubernetes manifests or kustomize. The Helm chart (kube-prometheus-stack) is the most common installation method because it bundles everything, but it is not required.
Create a PrometheusRule custom resource with your alerting rules in the standard Prometheus alerting format. The operator detects the resource and loads the rules into Prometheus. No restart or config reload is needed.
Yes. It works on EKS, GKE, AKS, and any conformant Kubernetes cluster. The operator uses standard Kubernetes APIs and does not depend on cloud-provider-specific features.
引用来源 (3)
- Prometheus Operator GitHub— Prometheus Operator manages Prometheus on Kubernetes via custom resources
- kube-prometheus-stack— kube-prometheus-stack Helm chart
- Prometheus Documentation— Prometheus monitoring system
讨论
相关资产
kube-prometheus — Production-Ready Kubernetes Monitoring Stack
kube-prometheus provides a complete Kubernetes monitoring stack combining Prometheus, Grafana, Alertmanager, and node-exporter with opinionated defaults and pre-built dashboards.
Operator SDK — Build Kubernetes Operators the Easy Way
The Operator SDK provides scaffolding, code generation, and lifecycle management tools for building Kubernetes operators in Go, Ansible, or Helm with best-practice patterns built in.
Prometheus — Open Source Monitoring & Alerting Toolkit
Prometheus is the CNCF-graduated monitoring system and time series database. Pull-based metrics collection, powerful PromQL queries, and built-in alerting for cloud-native infrastructure.
Flagger — Progressive Delivery Operator for Kubernetes
Flagger is a FluxCD progressive delivery operator that automates canary, A/B, and blue/green rollouts on Kubernetes, using service-mesh traffic shifting and metric-based analysis to promote or abort releases.