kube-prometheus-stack
kube-prometheus-stack collects Kubernetes manifests, Grafana dashboards, and Prometheus rules combined with documentation and scripts to provide easy to operate end-to-end Kubernetes cluster monitoring with Prometheus using the Prometheus Operator.
About this chart
kube-prometheus-stack
Installs core components of the kube-prometheus stack, a collection of Kubernetes manifests, Grafana dashboards, and Prometheus rules combined with documentation and scripts to provide easy to operate end-to-end Kubernetes cluster monitoring with Prometheus using the Prometheus Operator.
See the kube-prometheus readme for details about components, dashboards, and alerts.
Note: This chart was formerly named prometheus-operator chart, now renamed to more clearly reflect that it installs the kube-prometheus project stack, within which Prometheus Operator is only one component. This chart does not install all components of kube-prometheus, notably excluding the Prometheus Adapter and Prometheus black-box exporter.
Prerequisites
- Kubernetes 1.19+
- Helm 3+
Usage
The chart is distributed as an OCI Artifact as well as via a traditional Helm Repository.
- OCI Artifact:
oci://ghcr.io/prometheus-community/charts/kube-prometheus-stack - Helm Repository:
https://prometheus-community.github.io/helm-chartswith chartkube-prometheus-stack
The installation instructions use the OCI registry. Refer to the [helm repo](helm repo) command documentation for information on installing charts via the traditional repository.
Install Helm Chart
helm install [RELEASE_NAME] oci://ghcr.io/prometheus-community/charts/kube-prometheus-stack
See configuration below.
See helm install for command documentation.
Dependencies
By default this chart installs additional, dependent charts:
- prometheus-community/kube-state-metrics
- prometheus-community/prometheus-node-exporter
- grafana/grafana
To disable dependencies during installation, see multiple releases below.
See helm dependency for command documentation.
Grafana Dashboards
This chart provisions a collection of curated Grafana dashboards that are automatically loaded into Grafana via ConfigMaps. These dashboards are rendered into the Helm chart under templates/grafana/, but this is not their source of truth.
The dashboards originate from various upstream projects and are gathered and processed using scripts in the hack/ directory. For details on how these dashboards are sourced and kept up to date, refer to the hack/README.md.
Note: The dashboards referenced in the
hackscripts are usually not the original source either. Most originate from separate Prometheus mixin repositories (e.g., kubernetes-mixin) and are processed throughjsonnettooling before being included here. To find the original source in case you want to modify it you may have to search even further upstream.
If you wish to contribute or modify dashboards, please follow the guidance in the hack/README.md to ensure consistency and reproducibility.
Uninstall Helm Chart
helm uninstall [RELEASE_NAME]
This removes all the Kubernetes components associated with the chart and deletes the release.
See helm uninstall for command documentation.
CRDs created by this chart are not removed by default and should be manually cleaned up:
kubectl delete crd alertmanagerconfigs.monitoring.coreos.com
kubectl delete crd alertmanagers.monitoring.coreos.com
kubectl delete crd podmonitors.monitoring.coreos.com
kubectl delete crd probes.monitoring.coreos.com
kubectl delete crd prometheusagents.monitoring.coreos.com
kubectl delete crd prometheuses.monitoring.coreos.com
kubectl delete crd prometheusrules.monitoring.coreos.com
kubectl delete crd scrapeconfigs.monitoring.coreos.com
kubectl delete crd servicemonitors.monitoring.coreos.com
kubectl delete crd thanosrulers.monitoring.coreos.com
Upgrading Chart
helm upgrade [RELEASE_NAME] [CHART]
With Helm v3, CRDs created by this chart are not updated by default and should be manually updated. Consult also the Helm Documentation on CRDs.
CRDs update lead to a major version bump.
The Chart's appVersion refers to the prometheus-operator's version with matching CRDs.
See helm upgrade for command documentation.
Upgrading an existing Release to a new major version
A major chart version change (like v1.2.3 -> v2.0.0) indicates that there is an incompatible breaking change needing manual actions.
See UPGRADE.md for breaking changes between versions.
Configuration
See Customizing the Chart Before Installing. To see all configurable options with detailed comments:
helm show values oci://ghcr.io/prometheus-community/charts/kube-prometheus-stack
You may also helm show values on this chart's dependencies for additional options.
For templated Grafana datasource definitions (e.g. when using Helm flow control), use grafana.additionalDataSourcesString, which is rendered via tpl.
HTTPRoute timeouts
Set timeouts on a route to configure request and backend request timeouts for its generated HTTPRoute rule:
prometheus:
route:
main:
enabled: true
parentRefs:
- name: gateway
timeouts:
request: 120s
backendRequest: 60s
The same settings are available under alertmanager.route, thanosRuler.route, and the routePerReplica settings for Prometheus and Alertmanager.
Timeouts are only rendered for kind: HTTPRoute. They do not apply to generated HTTPS redirect rules or propagate to additionalRules; configure timeouts directly on additional rules when needed. Leaving timeouts empty preserves the Gateway controller's defaults.
This requires Gateway API CRDs that support HTTPRoute timeouts (available in the Standard channel since v1.2.0) and a Gateway controller that supports the corresponding timeout features. When both values are set, backendRequest must not exceed request, unless request is "0s". See the Gateway API timeout documentation for duration semantics and controller support requirements.
Authentication of the control-plane ServiceMonitors
The built-in ServiceMonitors for kubelet, kube-apiserver, kube-controller-manager, kube-scheduler, kube-etcd, kube-proxy, coredns and kube-dns authenticate through Kubernetes objects rather than through files on the scraper's filesystem. The bearer token comes from a Secret referenced by authorization, and the CA comes from the kube-root-ca.crt ConfigMap that Kubernetes maintains in every namespace. This keeps the ServiceMonitors valid when prometheus.prometheusSpec.arbitraryFSAccessThroughSMs.deny is true, and when they are scraped by Grafana Alloy's prometheus.operator.servicemonitors component, which rejects filesystem references by default since v1.19.0.
The chart creates the credential itself: prometheus.serviceAccount.createTokenSecret (enabled by default) renders a kubernetes.io/service-account-token Secret named <prometheus service account>-token, which every component references by default:
kubelet:
serviceMonitor:
authorization:
type: Bearer
credentials:
name: '{{ include "kube-prometheus-stack.prometheus.tokenSecretName" . }}'
key: token
tlsConfig:
insecureSkipVerify: true
ca:
configMap:
name: kube-root-ca.crt
key: ca.crt
Both authorization and tlsConfig are rendered as-is, so any field of the Prometheus Operator SafeAuthorization and SafeTLSConfig types can be set. Set authorization to null to scrape a component without authentication. kubeApiServer keeps its TLS settings under kubeApiServer.tlsConfig; coreDns and kubeDns have no tlsConfig, since those endpoints are scraped over HTTP.
That Secret is only rendered alongside the Prometheus service account, so it also requires prometheus.enabled and prometheus.serviceAccount.create. Leaving a component on the default authorization while the Secret is not rendered fails the release with an explanatory message, rather than producing a ServiceMonitor that references a Secret which will never exist. When the control plane is scraped by a Prometheus this chart does not deploy, point each enabled component at the scraper's own credential; ci/08-external-scraper-values.yaml is a complete example.
To use your own credential, disable prometheus.serviceAccount.createTokenSecret and point the components at your Secret. The Secret must live in the namespace of the ServiceMonitor, which is the release namespace unless prometheus.prometheusSpec.ignoreNamespaceSelectors is enabled. Because Helm deep-merges values, replacing the CA reference requires clearing the default explicitly:
kubelet:
serviceMonitor:
tlsConfig:
ca:
configMap: null
secret:
name: kubelet-scrape-auth
key: ca.crt
kubeEtcd is the only component that scrapes with client certificates:
kubeEtcd:
serviceMonitor:
scheme: https
tlsConfig:
insecureSkipVerify: false
ca:
secret:
name: etcd-client-cert
key: etcd-ca
cert:
secret:
name: etcd-client-cert
key: etcd-client
keySecret:
name: etcd-client-cert
key: etcd-client-key
Prometheus High Availability (HA)
For a basic HA setup, run multiple Prometheus replicas:
prometheus:
prometheusSpec:
replicas: 2
podAntiAffinity: "hard"
externalLabels:
cluster: prod-eu1
Important notes:
replicascontrols how many Prometheus pods are deployed for each shard.- Keep anti-affinity enabled (or hardened) to avoid scheduling all replicas on one node.
- Do not clear replica/instance external labels in HA setups (
replicaExternalLabelNameClear/prometheusExternalLabelNameClear), otherwise deduplication and alert/source identification become harder. - Querying replicas through a Kubernetes Service provides availability, but not sample deduplication across replicas by itself. For global/deduplicated querying, use a Thanos Query layer (or another backend that performs deduplication).
See also Prometheus Operator HA guidance:
Multiple releases
The same chart can be used to run multiple Prometheus instances in the same cluster if required. To achieve this, it is necessary to run only one instance of prometheus-operator and a pair of alertmanager pods for an HA configuration, while all other components need to be disabled. To disable a dependency during installation, set kubeStateMetrics.enabled, nodeExporter.enabled and grafana.enabled to false.
Work-Arounds for Known Issues
Running on private GKE clusters
When Google configure the control plane for private clusters, they automatically configure VPC peering between your Kubernetes cluster’s network and a separate Google managed project. In order to restrict what Google are able to access within your cluster, the firewall rules configured restrict access to your Kubernetes pods. This means that in order to use the webhook component with a GKE private cluster, you must configure an additional firewall rule to allow the GKE control plane access to your webhook pod.
You can read more information on how to add firewall rules for the GKE control plane nodes in the GKE docs
Alternatively, you can disable the hooks by setting prometheusOperator.admissionWebhooks.enabled=false.
Argo CD
The operator CRDs are larger than the 262144 byte limit on the kubectl.kubernetes.io/last-applied-configuration annotation — crd-prometheuses.yaml alone is around 840 KiB — so a client-side apply fails with metadata.annotations: Too long. Sync the applicati
Deploy kube-prometheus-stack with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has kube-prometheus-stack on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartkube-prometheus-stack is pinned at v94.2.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below opentenant validate opentenant.yaml terraform init && terraform apply