thanos
A helm chart to setup Thanos on Kubernetes, a highly available Prometheus setup with long term storage capabilities.
About this chart
Thanos Helm Chart
A helm chart to setup Thanos on Kubernetes, a highly available Prometheus setup with long term storage capabilities.
TL;DR
helm install thanos oci://ghcr.io/thanos-community/helm-charts/thanos \
--namespace monitoring \
--create-namespace
Architecture
Thanos extends Prometheus with global query view, long-term storage, and high availability. It is composed of several independently deployable components that each serve a specific role.
Refer to the Thanos component docs for an in-depth explanation.
Maintainers
| Name | Url | |
|---|---|---|
| hamdikh | [email protected] |
Source Code
Prerequisites
- Kubernetes
>= 1.30.0-0 - Helm >= 3.8 (OCI registry support)
- An object store bucket — GCS, S3, Azure Blob, or any S3-compatible store
Requirements
Kubernetes: >= 1.30.0-0
| Repository | Name | Version |
|---|---|---|
| https://charts.rustfs.com/ | rustfs | 0.12.0 |
| https://prometheus-community.github.io/helm-charts | kube-prometheus-stack(kube-prometheus-stack) | 88.6.0 |
Component Overview
The chart deploys each Thanos component as an independent workload. Enable only what you need.
| Component | Enabled by Default | Workload | Purpose |
|---|---|---|---|
| query | Yes | Deployment | Fan-out query engine. Queries multiple Store API endpoints and deduplicates results. This is the Prometheus-compatible query entrypoint. |
| receive | Yes | StatefulSet | Remote-write endpoint. Accepts Prometheus remote_write traffic, stores samples locally, and ships blocks to the object store. |
| storegateway | Yes | StatefulSet | Serves historical blocks from the object store over the Store API. Required for querying data older than what Prometheus/Receive holds locally. |
| compactor | Yes | StatefulSet | Compacts and downsamples blocks in the object store. Runs as a singleton — do not scale above 1 replica. |
| query-frontend | No | Deployment | Optional caching and query-splitting layer in front of Query. Reduces load for repeated or heavy queries. |
| ruler | No | StatefulSet | Evaluates alerting and recording rules by querying the Query component. Sends alerts to Alertmanager. |
| bucket (bucketweb) | No | Deployment | Read-only web UI for inspecting blocks in the object store. Useful for debugging, not needed in production. |
| bucketReplicate | No | Deployment | Copies blocks from the object store into a second one, for disaster-recovery copies or migrations between providers. |
Installation
1. Add the Helm repository (optional, for non-OCI installs)
helm repo add thanos-community https://thanos-community.github.io/helm-charts
helm repo update
2. Configure object store credentials
All stateful Thanos components (Receive, Store Gateway, Compactor, Ruler) need access to an object store.
Create a values.yaml file with your object store configuration:
global:
objstore:
# Set createSecret: true to let the chart create the Secret from the inline config below.
# Set createSecret: false (default) if you manage the Secret externally.
createSecret: true
secretName: thanos-objstore
secretKey: objstore.yml
config: |
type: S3
config:
bucket: my-thanos-bucket
endpoint: s3.eu-west-1.amazonaws.com
region: eu-west-1
access_key: <ACCESS_KEY>
secret_key: <SECRET_KEY>
3. Install the chart
helm install thanos oci://ghcr.io/thanos-community/helm-charts/thanos \
--namespace monitoring \
--create-namespace \
-f values.yaml
4. Verify the installation
kubectl get pods -n monitoring -l app.kubernetes.io/instance=thanos
Object Store Configuration
The object store config is shared by all components that write to or read from the object store. It follows the Thanos object store YAML format.
Providing credentials
Option A — let the chart create the Secret (suitable for development):
global:
objstore:
createSecret: true
config: |
type: GCS
config:
bucket: my-bucket
Option B — bring your own Secret (recommended for production):
Create the Secret externally (e.g. via Vault, External Secrets Operator, or kubectl):
kubectl create secret generic thanos-objstore \
--from-file=objstore.yml=./objstore.yml \
-n monitoring
Then reference it in values:
global:
objstore:
createSecret: false
secretName: thanos-objstore
secretKey: objstore.yml
Provider examples
type: GCS
config:
bucket: my-thanos-bucket
service_account: |-
{
"type": "service_account",
...
}
type: S3
config:
bucket: my-thanos-bucket
endpoint: s3.eu-west-1.amazonaws.com
region: eu-west-1
access_key: AKIAIOSFODNN7EXAMPLE
secret_key: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
type: AZURE
config:
storage_account: mystorageaccount
storage_account_key: <BASE64_ENCODED_KEY>
container: thanos
endpoint_suffix: core.windows.net
Key Configuration Sections
Global defaults
Settings under global apply to all components unless overridden at the component level. This avoids repeating common values (image, security context, node selectors, etc.).
global:
image:
registry: quay.io
repository: thanos/thanos
tag: v0.39.2
pullPolicy: IfNotPresent
# Applied to every pod
containerSecurityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop: [ALL]
runAsNonRoot: true
# Shared resource defaults (override per component as needed)
resources: {}
nodeSelector: {}
tolerations: []
# Fallback StorageClass for every PVC the chart creates. A component's own
# persistence.storageClass wins; empty on both means the cluster default.
storageClass: ""
Query
The Query component is the main entrypoint for PromQL queries. It fans out to all registered Store API endpoints and deduplicates results using replica labels.
query:
enabled: true
replicaCount: 2
# Labels that identify replica identity — used for deduplication
replicaLabels:
- prometheus_replica
- receive_replica
- ruler_replica
# gRPC --endpoint arguments. The in-chart components (Receive, Store Gateway, Ruler) are auto-wired
# when autogen.enabled is true. Endpoints defined in static[] are always appended; set
# autogen.enabled to false to take full control of what endpoint arguments are passed.
endpoints:
autogen:
enabled: true
static: []
# Example:
# static:
# - thanos-storegateway.cluster1.internal:443
# - thanos-receive.cluster1.internal:443
# Deprecated. Use query.endpoints.static[] instead.
stores: []
ingress:
http:
enabled: false
className: nginx
hosts:
- host: thanos-query.example.com
paths:
- path: /
pathType: Prefix
File-based endpoint discovery
autogen and static bake their endpoints into the pod spec, so every change to the store topology is a helm upgrade and a restart. query.endpoints.sdConfig instead passes --endpoint.sd-config-file, which Thanos re-reads at runtime — the right fit when the set of Store API servers changes without the chart knowing, for example sidecars appearing next to new Prometheus instances.
Point it at a ConfigMap somebody else maintains:
query:
endpoints:
sdConfig:
existingConfigMap: thanos-endpoints
key: endpoints.yml
reloadInterval: 30s
Or let the chart render one from an inline config. The file is Thanos' own EndpointConfig, documented under Per-Endpoint TLS Configuration — not the Prometheus target-group format, which belongs to the deprecated --store.sd-files flag:
query:
endpoints:
sdConfig:
config: |
endpoints:
- address: thanos-sidecar-0.prometheus:10901
- address: thanos-sidecar-1.prometheus:10901
Three things to keep in mind:
- The ConfigMap is mounted as a directory rather than with
subPath, because the kubelet only keeps the projected file current without one. WithsubPaththe file would freeze at its first version and re-reading it would find nothing new. - File SD is additive:
autogenandstaticendpoints are still passed as--endpointarguments alongside it, and Thanos merges them into the file's list on every reload. - gRPC client TLS belongs in this file too, as
default_client_configor per endpoint asclient_config. The--grpc-client-tls-*flags are deprecated after v0.43.0, and Query already logs a warning pointing here.
Receive
The Receive component accepts Prometheus remote_write traffic and stores samples locally in a TSDB WAL before shipping blocks to the object store.
receive:
enabled: true
replicaCount: 3 # Minimum 3 for a replication factor of 2
tsdb:
retention: 24h # How long to keep data locally before it is uploaded
walCompression: true # Reduces IO and disk usage
persistence:
enabled: true
size: 10Gi
# Hashring topology — defaults to auto-generating a single ring
hashrings:
autogen:
enabled: true
name: default
# static: [] # Set to override autogen with a custom hashring config
Configure Prometheus to remote-write to the Receive service:
# In your Prometheus / kube-prometheus-stack values
prometheus:
prometheusSpec:
remoteWrite:
- url: http://thanos-receive.monitoring.svc.cluster.local:10908/api/v1/receive
Split mode (separate Router and Ingester)
For high-availability and horizontal scalability, Receive can be deployed as two separate workloads following the receive split proposal:
- Router — stateless
Deploymentthat terminates clientremote_writetraffic and forwards each request to the correct Ingester(s) according to the hashring config (with optional replication). - Ingester — stateful
StatefulSetthat stores samples in a local TSDB WAL and ships blocks to the object store, just like standalone Receive.
Set receive.mode: split to opt in. In split mode the top-level receive.*
fields are ignored: configure the Ingester StatefulSet (renamed to
<release>-thanos-receive-ingester) via receive.ingester.*, and the Router
Deployment (<release>-thanos-receive-router) via receive.router.*. The
schema enforces that both ingester and router are populated when
mode: split.
receive:
enabled: true
mode: split # standalone (default) | split
ingester:
replicaCount: 3 # Minimum 3 for replication factor 2
tsdb:
retention: 24h
walCompression: true
service:
grpcPort: 10901
httpPort: 10902
remoteWritePort: 10908
persistence:
enabled: true
size: 10Gi
hashrings:
autogen:
enabled: true
router:
replicaCount: 2
replicationFactor: 2 # Each write fans out to N ingesters
In standalone mode (default), leave receive.ingester and receive.router
empty — all configuration lives directly under receive.*.
In split mode clients should remote-write to the Router service:
http://<release>-thanos-receive-router.<namespace>.svc.cluster.local:10908/api/v1/receive
Externally managed hashrings
receive.hashrings.external points the chart at a hashring ConfigMap owned by something else — typically thanos-receive-controller, which watches the Receive pods and rewrites the ring as they come and go, so that scaling needs no redeploy:
receive:
hashrings:
refreshInterval: 30s # re-read the file the controller rewrites
external:
enabled: true
configMapName: thanos-receive-controller-generated
key: hashrings.json # this is the default
In split mode the whole hashrings block moves to receive.ingester.hashrings, because both workloads resolve the ring from the Ingester config — the Router reads it to route, the Ingester to know its own place in it. A hashring under receive.router is rejected at render time rather than silently ignored.
Three things to keep in mind:
- The chart renders no hashring ConfigMap of its own while this is enabled, and
autogenandstaticare ignored. Without that, Helm and the controller would fight over the same object. - The ring is entirely the owner's responsibility, including any per-endpoint fields beyond the address that the hashring format supports. The chart contributes nothing to a ring it does not render.
- The
checksum/hashringspod annotation is dropped, since the ring content is unknown at render
Deploy thanos with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has thanos 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 chartthanos is pinned at v0.50.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