Skip to content

Commit

Permalink
feat: configure Thanos caching
Browse files Browse the repository at this point in the history
  • Loading branch information
modridi committed Feb 5, 2024
1 parent c8d3ae3 commit 5376da8
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 0 deletions.
5 changes: 5 additions & 0 deletions charts/thanos/Chart.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ dependencies:
version: 12.21.0
digest: sha256:ad7b9683f7aa4aa053b6c4ab8cd3d3cfbdfa77344f1373c609c7c9a8dff5edd8
generated: "2024-01-18T07:03:25.161576564Z"
- name: redis
repository: https://charts.bitnami.com/bitnami
version: 18.4.0
digest: sha256:17f83e8fa5ed4acc963cfb471b3f6a73e5f347903ccf1a533fb6400628222d89
generated: "2023-11-30T17:09:11.837623668+01:00"
3 changes: 3 additions & 0 deletions charts/thanos/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@ dependencies:
- name: thanos
repository: https://charts.bitnami.com/bitnami
version: 12.21.0
- name: "redis"
version: "18.4.0"
repository: "https://charts.bitnami.com/bitnami"
name: thanos
version: "0"
Binary file added charts/thanos/charts/redis-18.4.0.tgz
Binary file not shown.
77 changes: 77 additions & 0 deletions locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ locals {
# values.yaml translated into HCL structures.
# Possible values available here -> https://github.com/bitnami/charts/tree/master/bitnami/thanos/
helm_values = [{
redis = {
architecture = "standalone"
auth = {
enabled = true
password = random_password.redis_password.result
}
master = {
persistence = {
enabled = false
}
}
}
thanos = {

storegateway = {
Expand All @@ -12,6 +24,28 @@ locals {
enabled = false
}
resources = local.thanos.storegateway_resources
extraFlags = [
# Store Gateway index cache config -> https://thanos.io/tip/components/store.md/#index-cache
<<-EOT
--index-cache.config="config":
addr: "thanos-redis-master:6379"
password: ${random_password.redis_password.result}
db: 0
dial_timeout: 5s
read_timeout: 3s
write_timeout: 3s
max_get_multi_concurrency: 1000
get_multi_batch_size: 100
max_set_multi_concurrency: 1000
set_multi_batch_size: 100
tls_enabled: false
cache_size: 0
max_async_buffer_size: 1000000
max_async_concurrency: 200
expiration: 2h
"type": "REDIS"
EOT
]
}

query = {
Expand Down Expand Up @@ -137,6 +171,49 @@ locals {
}

queryFrontend = {
extraFlags = [
# Query Frontend response cache config -> https://thanos.io/tip/components/query-frontend.md/#caching
<<-EOT
--query-range.response-cache-config="config":
addr: "thanos-redis-master:6379"
password: ${random_password.redis_password.result}
db: 1
dial_timeout: 5s
read_timeout: 3s
write_timeout: 3s
max_get_multi_concurrency: 1000
get_multi_batch_size: 100
max_set_multi_concurrency: 1000
set_multi_batch_size: 100
tls_enabled: false
cache_size: 0
max_async_buffer_size: 1000000
max_async_concurrency: 200
expiration: 2h
"type": "REDIS"
EOT
,
<<-EOT
--labels.response-cache-config="config":
addr: "thanos-redis-master:6379"
password: ${random_password.redis_password.result}
db: 2
dial_timeout: 5s
read_timeout: 3s
write_timeout: 3s
max_get_multi_concurrency: 1000
get_multi_batch_size: 100
max_set_multi_concurrency: 1000
set_multi_batch_size: 100
tls_enabled: false
cache_size: 0
max_async_buffer_size: 1000000
max_async_concurrency: 200
expiration: 2h
"type": "REDIS"
EOT
,
]
sidecars = [{
args = concat([
"--http-address=0.0.0.0:9075",
Expand Down
5 changes: 5 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ resource "null_resource" "dependencies" {
triggers = var.dependency_ids
}

resource "random_password" "redis_password" {
length = 16
special = false
}

resource "argocd_project" "this" {
count = var.argocd_project == null ? 1 : 0

Expand Down

0 comments on commit 5376da8

Please sign in to comment.