diff --git a/aks/main.tf b/aks/main.tf index fdea314a..7fed6791 100644 --- a/aks/main.tf +++ b/aks/main.tf @@ -72,6 +72,8 @@ module "thanos" { app_autosync = var.app_autosync dependency_ids = var.dependency_ids + resources = var.resources + thanos = var.thanos helm_values = concat(local.helm_values, var.helm_values) diff --git a/eks/main.tf b/eks/main.tf index a4a77213..721e18d3 100644 --- a/eks/main.tf +++ b/eks/main.tf @@ -14,6 +14,8 @@ module "thanos" { app_autosync = var.app_autosync dependency_ids = var.dependency_ids + resources = var.resources + thanos = var.thanos helm_values = concat(local.helm_values, var.helm_values) diff --git a/kind/main.tf b/kind/main.tf index a4a77213..721e18d3 100644 --- a/kind/main.tf +++ b/kind/main.tf @@ -14,6 +14,8 @@ module "thanos" { app_autosync = var.app_autosync dependency_ids = var.dependency_ids + resources = var.resources + thanos = var.thanos helm_values = concat(local.helm_values, var.helm_values) diff --git a/locals.tf b/locals.tf index b66e08f8..098f82a3 100644 --- a/locals.tf +++ b/locals.tf @@ -20,6 +20,10 @@ locals { persistence = { enabled = false } + resources = { + requests = { for k, v in var.resources.redis.requests : k => v if v != null } + limits = { for k, v in var.resources.redis.limits : k => v if v != null } + } } } thanos = { @@ -35,7 +39,10 @@ locals { persistence = { enabled = false } - resources = local.thanos.storegateway_resources + resources = { + requests = { for k, v in var.resources.storegateway.requests : k => v if v != null } + limits = { for k, v in var.resources.storegateway.limits : k => v if v != null } + } networkPolicy = { enabled = false } @@ -72,7 +79,10 @@ locals { stores = [ "thanos-storegateway:10901" ] - resources = local.thanos.query_resources + resources = { + requests = { for k, v in var.resources.query.requests : k => v if v != null } + limits = { for k, v in var.resources.query.limits : k => v if v != null } + } networkPolicy = { enabled = false } @@ -83,7 +93,10 @@ locals { retentionResolutionRaw = "${local.thanos.compactor_retention.raw}" retentionResolution5m = "${local.thanos.compactor_retention.five_min}" retentionResolution1h = "${local.thanos.compactor_retention.one_hour}" - resources = local.thanos.compactor_resources + resources = { + requests = { for k, v in var.resources.compactor.requests : k => v if v != null } + limits = { for k, v in var.resources.compactor.limits : k => v if v != null } + } persistence = { # The Access Mode needs to be set as ReadWriteOnce because AWS Elastic Block storage does not support other # modes (https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes). @@ -101,6 +114,10 @@ locals { bucketweb = { enabled = true + resources = { + requests = { for k, v in var.resources.bucketweb.requests : k => v if v != null } + limits = { for k, v in var.resources.bucketweb.limits : k => v if v != null } + } sidecars = [{ args = concat([ "--http-address=0.0.0.0:9075", @@ -188,6 +205,10 @@ locals { } queryFrontend = { + resources = { + requests = { for k, v in var.resources.query_frontend.requests : k => v if v != null } + limits = { for k, v in var.resources.query_frontend.limits : k => v if v != null } + } extraFlags = [ # Query Frontend response cache config -> https://thanos.io/tip/components/query-frontend.md/#caching <<-EOT diff --git a/sks/main.tf b/sks/main.tf index a4a77213..721e18d3 100644 --- a/sks/main.tf +++ b/sks/main.tf @@ -14,6 +14,8 @@ module "thanos" { app_autosync = var.app_autosync dependency_ids = var.dependency_ids + resources = var.resources + thanos = var.thanos helm_values = concat(local.helm_values, var.helm_values) diff --git a/variables.tf b/variables.tf index c7d639c7..7be8ba95 100644 --- a/variables.tf +++ b/variables.tf @@ -91,6 +91,84 @@ variable "thanos" { default = {} } +variable "resources" { + description = <<-EOT + Resource limits and requests for Thanos' components. Follow the style on https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/[official documentation] to understand the format of the values. + + IMPORTANT: These are not production values. You should always adjust them to your needs. + EOT + type = object({ + + query = optional(object({ + requests = optional(object({ + cpu = optional(string, "250m") + memory = optional(string, "512Mi") + }), {}) + limits = optional(object({ + cpu = optional(string) + memory = optional(string, "512Mi") + }), {}) + }), {}) + + query_frontend = optional(object({ + requests = optional(object({ + cpu = optional(string, "250m") + memory = optional(string, "256Mi") + }), {}) + limits = optional(object({ + cpu = optional(string) + memory = optional(string, "512Mi") + }), {}) + }), {}) + + bucketweb = optional(object({ + requests = optional(object({ + cpu = optional(string, "50m") + memory = optional(string, "128Mi") + }), {}) + limits = optional(object({ + cpu = optional(string) + memory = optional(string, "128Mi") + }), {}) + }), {}) + + compactor = optional(object({ + requests = optional(object({ + cpu = optional(string, "250m") + memory = optional(string, "256Mi") + }), {}) + limits = optional(object({ + cpu = optional(string) + memory = optional(string, "512Mi") + }), {}) + }), {}) + + storegateway = optional(object({ + requests = optional(object({ + cpu = optional(string, "250m") + memory = optional(string, "512Mi") + }), {}) + limits = optional(object({ + cpu = optional(string) + memory = optional(string, "512Mi") + }), {}) + }), {}) + + redis = optional(object({ + requests = optional(object({ + cpu = optional(string, "200m") + memory = optional(string, "256Mi") + }), {}) + limits = optional(object({ + cpu = optional(string) + memory = optional(string, "512Mi") + }), {}) + }), {}) + + }) + default = {} +} + variable "enable_service_monitor" { description = "Boolean to enable the deployment of a service monitor for Prometheus. This also enables the deployment of default Prometheus rules and Grafana dashboards, which are embedded inside the chart templates and are taken from the official Thanos examples, available https://github.com/thanos-io/thanos/blob/main/examples/alerts/alerts.yaml[here]." type = bool