prometheus.yml each time you add a scrape target quickly becomes tedious.
Example of separate Deployments you might maintain:
prometheus.yml you would normally edit manually:
- Repository: https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack

- Prometheus Operator: manages Prometheus instances and dynamic configuration via Kubernetes CRDs.
- Prometheus: a production-ready server configured to store and query metrics.
- Grafana: pre-configured with a Prometheus data source and optional dashboards.
- kube-state-metrics: exports Kubernetes object-level metrics (Deployments, Pods, Services, PVCs, Namespaces, etc.).
- Alertmanager and example alerting rules (configurable via values).

- kubelet and node-exporter (node-level CPU, memory, network)
- kube-apiserver (request rates and latencies)
- kube-state-metrics (object state such as pod_count, deployment_replicas, pvc_capacity)
- Prometheus self-metrics

prometheus.yml directly. The Prometheus Operator configures Prometheus dynamically using Kubernetes Custom Resources such as ServiceMonitor and PodMonitor.
What is a ServiceMonitor?
A ServiceMonitor is a Kubernetes manifest that tells Prometheus (via the Operator) what Service to scrape, which port/path to use, and the scrape interval. You can create ServiceMonitor resources alongside your application manifests so that Prometheus automatically discovers and scrapes your app.
Example ServiceMonitor:
Make sure Prometheus is configured to discover ServiceMonitors via its
serviceMonitorSelector (controlled by chart values). Using labels such as release: prometheus-stack is common so Prometheus only selects ServiceMonitors created for that chart release.- Grafana will be deployed with a Prometheus data source already configured.
- Prometheus and Alertmanager will be deployed and managing their configs via CRDs.
- kube-state-metrics and node exporters will be scraping cluster-level metrics.
Apply your application and ServiceMonitor:
- kube-prometheus-stack Helm chart: https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack
- Prometheus Operator and CRDs: https://github.com/prometheus-operator/prometheus-operator
- ServiceMonitor documentation: https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api.md