How prometheus-operator/kube-prometheus works
Main Components
• Prometheus Operator – This is core to managing the lifecycle of Prometheus instances, Alertmanager, ServiceMonitors, and PrometheusRules via Custom Resource Definitions (CRDs).
• Prometheus – The highly available monitoring server that scrapes metrics from endpoints.
• Alertmanager – Responsible for processing and sending alerts generated from Prometheus.
• Exporters – Include components such as:
• Node Exporter (collects node-level metrics)
• Blackbox Exporter (for endpoint monitoring)
• kube-state-metrics (exposes Kubernetes state metrics)
• Grafana – For dashboards and visualization of monitoring data.
• Prometheus Adapter – For exposing metrics to the Kubernetes Metrics API.
• jsonnet Library/Templates – Represent the customization and templating engine that generates manifests and dashboards.
• Supporting tooling & scripts – CI/CD workflows, configurations, and developer workspaces that help test and deploy the system.
Component Relationships and Interactions
• The Prometheus Operator is the central manager that deploys and configures Prometheus, Alertmanager, and related CRDs inside a Kubernetes cluster.
• Prometheus instances are set up and managed via the Operator and then scrape metrics from the node exporters, blackbox exporter, kube-state-metrics, and other configured targets.
• Alertmanager receives alerts (triggered by Prometheus rules configured via jsonnet) and processes them based on the defined routing.
• Grafana consumes data from Prometheus to display dashboards. The project also provides pre-configured dashboards stored in manifests and jsonnet.
• Prometheus Adapter serves as a bridge to expose resource metrics through the Kubernetes metrics API.
• The jsonnet directories, along with build scripts and configuration files (like Makefile, build.sh, etc.), orchestrate how the overall manifests are generated and updated. They act as a “library” that can be customized by downstream users.
Architectural Patterns
• Declarative Infrastructure: The manifest and CRD files underscore a declarative style where Kubernetes is the single source of truth.
• Library/Package Pattern: The use of jsonnet and the structure of the repository indicate that this monitoring stack can be imported and custom-tailored much like a library.
• Separation of Concerns: The system distinguishes between “control” (Prometheus Operator and CRDs) and “data collection/visualization” (Prometheus, Alertmanager, exporters, Grafana).