thanos

by Helm

Helm chartv0.4.9App 0.28.1

Thanos is a set of components that can be composed into a highly available metric system with unlimited storage capacity, which can be added seamlessly on top of existing Prometheus deployments.

About this chart

Thanos Helm chart

This is a Helm Chart for Thanos. It does not include the required Prometheus and sidecar installation.

Thanos

Thanos is a set of components that can be composed into a highly available metric system with unlimited storage capacity, which can be added seamlessly on top of existing Prometheus deployments.

Thanos leverages the Prometheus 2.0 storage format to cost-efficiently store historical metric data in any object storage while retaining fast query latencies. Additionally, it provides a global query view across all Prometheus installations and can merge data from Prometheus HA pairs on the fly.

Concretely the aims of the project are:

  • Global query view of metrics.
  • Unlimited retention of metrics.
  • High availability of components, including Prometheus.

Helm Chart

This chart is in Beta state to provide easy installation via Helm chart. Things that we are improving in near future:

  • [ ] Automatic TLS generation for communicating between in-cluster components
  • [ ] Support for tracing configuration
  • [ ] Grafana dashboards
  • [ ] Informative NOTES.txt

Architecture

This Chart will install a complete Thanos solution. To understand how Thanos works please read it's official Architecture design.

Installing the Chart

Add Banzai Cloud repository:

$ helm repo add banzaicloud-stable https://kubernetes-charts.banzaicloud.com

Storage examples

Example GCS configuration for object-store.yaml

type: GCS
config:
  bucket: "thanos"
  service_account: |-
    {
      "type": "service_account",
      "project_id": "project",
      "private_key_id": "abcdefghijklmnopqrstuvwxyz12345678906666",
      "private_key": "-----BEGIN PRIVATE KEY-----\...\n-----END PRIVATE KEY-----\n",
      "client_email": "[email protected]",
      "client_id": "123456789012345678901",
      "auth_uri": "https://accounts.google.com/o/oauth2/auth",
      "token_uri": "https://oauth2.googleapis.com/token",
      "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
      "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/thanos%40gitpods.iam.gserviceaccount.com"
    }

Example S3 configuration for object-store.yaml

This is an example configuration using thanos with S3. Check endpoints here: https://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region

type: S3
config:
  bucket: ""
  endpoint: ""
  region: ""
  access_key: ""
  insecure: false
  signature_version2: false
  secret_key: ""
  put_user_metadata: {}
  http_config:
    idle_conn_timeout: 0s
    response_header_timeout: 0s
    insecure_skip_verify: false
  trace:
    enable: false
  part_size: 0

Example Azure configuration for object-store.yaml

type: AZURE
config:
  storage_account: ""
  storage_account_key: ""
  container: ""
  endpoint: ""
  max_retries: 0

Create the Service Account and Bucket at Google cloud.

Install the chart:

helm install banzaicloud-stable/thanos --name thanos -f my-values.yaml --set-file objstoreFile=object-store.yaml

Visit the Bucket browser

kubectl port-forward svc/thanos-bucket 8080 &
open http://localhost:8080

Install prometheus-operator

Extra configuration for prometheus operator.

Note: Prometheus-operator and Thanos MUST be in the same namespace.

prometheus:
  prometheusSpec:
    thanos:
      image: quay.io/thanos/thanos:v0.9.0
      version: v0.9.0
      objectStorageConfig:
        name: thanos
        key: object-store.yaml

Install prometheus-operator

helm install stable/prometheus-operator -f thanos-sidecar.yaml

Configuration

This section describes the values available

General

NameDescriptionDefault Value
image.repositoryThanos image repository and name'quay.io/thanos/thanos' For Thanos version 0.6.0 or older change this to 'improbable/thanos'
image.tagThanos image tagv0.9.0
image.pullPolicyImage Kubernetes pull policyIfNotPresent
objstore Configuration for the backend object storage in yaml format. Mutually exclusive with other objstore options.{}
objstoreFile Configuration for the backend object storage in string format. Mutually exclusive with other objstore options.""
objstoreSecretOverride Configuration for the backend object storage in an existing secret. Mutually exclusive with other objstore options.""

Common settings for all components

These setting applicable to nearly all components.

NameDescriptionDefault Value
$component.labelsAdditional labels to the Pod{}
$component.annotationsAdditional annotations to the Pod{}
$component.deploymentLabelsAdditional labels to the deployment{}
$component.deploymentAnnotationsAdditional annotations to the deployment{}
$component.extraEnvAdd extra environment variables[]
$component.strategyKubernetes deployment update strategy object{}
$component.updateStrategyKubernetes statefulset update strategy object{}
$component.metrics.annotations.enabledPrometheus annotation for componentfalse
$component.metrics.serviceMonitor.enabledPrometheus ServiceMonitor definition for componentfalse
$component.securityContextSecurityContext for Pod{}
$component.resourcesResource definition for container{}
$component.tolerationsNode tolerations for server scheduling to nodes with taints{}
$component.nodeSelectorNode labels for compact pod assignment{}
$component.affinityPod affinity{}
$component.grpc.portgrpc listen port number 10901
$component.grpc.service.annotationsService definition for grpc service{}
$component.grpc.service.matchLabelsPod label selector to match grpc service on.{}
$component.grpc.ingress.enabledSet up ingress for the grpc servicefalse
$component.grpc.ingress.defaultBackendSet up default backend for ingressfalse
$component.grpc.ingress.annotationsAdd annotations to ingress{}
$component.grpc.ingress.labelsAdd labels to ingress{}
$component.grpc.ingress.pathIngress path"/"
$component.grpc.ingress.hostsIngress hosts[]
$component.grpc.ingress.tlsIngress TLS configuration[]
$component.http.porthttp listen port number 10902
$component.http.service.annotationsService definition for http service{}
$component.http.service.matchLabelsPod label selector to match http service on.{}
$component.http.ingress.enabledSet up ingress for the http servicefalse
$component.http.ingress.apiVersionSet API version for ingressextensions/v1beta1
$component.http.ingress.defaultBackendSet up default backend for ingressfalse
$component.http.ingress.annotationsAdd annotations to ingress{}
$component.http.ingress.labelsAdd labels to ingress{}
$component.http.ingress.pathIngress path"/"
$component.http.ingress.hostsIngress hosts[]
$component.http.ingress.tlsIngress TLS configuration[]

Store

These values are just samples, for more fine-tuning please check the values.yaml.

NameDescriptionDefault Value
store.enabledEnable componenttrue
store.replicaCountPod replica count1
store.logLevelLog levelinfo
store.logFormatLog format to use. Possible options: logfmt or json.logfmt
store.indexCacheSizeMaximum size of items held in the index cache.250MB
store.chunkPoolSizeMaximum size of concurrently allocatable bytes for chunks.2GB
store.grpcSeriesSampleLimitMaximum amount of samples returned via a single series call. 0 means no limit. NOTE: for efficiency we take 120 as the number of samples in chunk (it cannot be bigger than that), so the actual number of samples might be lower, even though the maximum could be hit.0
store.grpcSeriesMaxConcurrencyMaximum number of concurrent Series calls.20
store.syncBlockDurationRepeat interval for syncing the blocks between local and remote view.3m
store.blockSyncConcurrencyNumber of goroutines to use when syncing blocks from object storage.20
store.extraEnvAdd extra environment variables[]
store.extraArgsAdd extra arguments[]
store.serviceAccountName of the Kubernetes service account to use""
store.livenessProbeSet up liveness probe for store available for Thanos v0.8.0+){}
store.readinessProbeSet up readinessProbe for store (available for Thanos v0.8.0+){}
timePartioninglist of min/max time for store partitions. See more details below. Setting this will create mutlipale thanos store deployments based on the number of items in the list[{min: "", max: ""}]
hashPartioning.shardsThe number of shared used to partition the blocks based on the hashmod of the blocks. Can not be used with time partitioning""
initContainersInitContainers allows injecting specialized containers that run before app containers. This is meant to pre-configure and tune mounted volume permissions.[]

Store time partions

Thanos store supports partition based on time. Setting time partitions will create n number of store deployment based on the number of items in the list. Each item must contain min and max time for querying in the supported format (see details here See details at https://thanos.io/components/store.md/#time-based-partioning ). Leaving this empty list ([]) will create a single store for all data. Example - This will create 3 stores:

timePartioning:
  # One store for data older than 6 weeks
  - min: ""
    max: -6w
  # One store for data newer than 6 weeks and older than 2 weeks
  - min: -6w
    max: -2w
  # One store for data newer than 2 weeks
  - min: -2w
    max: ""

Query

NameDescriptionDefault Value
query.enabledEnable componenttrue
query.replicaCountPod replica count1
query.logLevelLog levelinfo
query.logFormatLog format to use. Possible options: logfmt or json.logfmt
query.replicaLabelsLabels to treat as a replica indicator along which data is deduplicated. Still you will be able to query without deduplication using 'dedup=false' parameter.[]
query.autoDownsamplingEnable --query.auto-downsampling option for query.true
query.webRoutePrefixPrefix for API and UI endpoints. This allows thanos UI to be served on a sub-path. This option is analogous to --web.route-prefix of Promethus.""
query.webExternalPrefixStatic prefix for all HTML links and redirect URLs in the UI query web interface. Actual endpoints are still served on / or the web.route-prefix. This allows thanos UI to be served behind a reverse proxy that strips a URL sub-path""
query.webPrefixHeaderName of HTTP request header used for dynamic prefixing of UI links and redirects. This option is ignored if web.external-prefix argument is set. Security risk: enable this option only if a reverse proxy in front of thanos is resetting the header. The --web.prefix-header=X-Forwarded-Prefix option can be useful, for example, if Thanos UI is served via Traefik reverse proxy with PathPrefixStrip option enabled, which sends the stripped prefix value in X-Forwarded-Prefix header. This allows thanos UI to be served on a sub-path""
query.storeDNSResolverCustome DNS resolver because of issuemiekgdns
query.storeDNSDiscoveryEnable DNS discovery for storestrue
query.sidecarDNSDiscoveryEnable DNS discovery for sidecars (this is for the chart built-in sidecar service)true
query.storesAddresses of statically configured store API servers (repeatable). The scheme may be prefixed with 'dns+' or 'dnssrv+' to detect store API servers through respective DNS lookups.[]
query.serviceDiscoveryFilesPath to files that contains addresses of store API servers. The path can be a glob pattern (repeatable).[]
query.serviceDiscoveryFileConfigMapsNames of configmaps that contain addresses of store API servers, used for file service discovery.[]
query.serviceDiscoveryIntervalRefresh interval to re-read file SD files. It is used as a resync fallback.5m
query.extraEnvAdd extra environment variables[]
query.extraArgsAdd extra arguments[]
query.podDisruptionBudget.enabledEnabled and config podDisruptionBudget resource for this componentfalse
query.podDisruptionBudget.minAvailableMinimum number of available query pods for PodDisruptionBudget1
query.podDisruptionBudget.maxUnavailableMaximum number of unavailable query pods for PodDisruptionBudget[]
query.autoscaling.enabledEnabled and config horizontalPodAutoscaling resource for this componentfalse
query.autoscaling.minReplicasIf autoscaling enabled, this field sets minimum replica count2
query.autoscaling.maxReplicasIf autoscaling enabled, this field sets maximum replica count3
query.autoscaling.targetCPUUtilizationPercentageTarget CPU utilization percentage to scale50
query.autoscaling.targetMemoryUtilizationPercentageTarget memory utilization percentage to sca

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.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartthanos is pinned at v0.4.9 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. 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