diff --git a/NEXT_RELEASE_NOTES.md b/NEXT_RELEASE_NOTES.md index 9df11430a..44ba60342 100644 --- a/NEXT_RELEASE_NOTES.md +++ b/NEXT_RELEASE_NOTES.md @@ -51,6 +51,7 @@ The release notes should contain at least the following sections: * [deploy] AWS NLB TLS listeners (DSS gateway and Prometheus, for both Helm and Tanka) now use the `ELBSecurityPolicy-TLS13-1-2-Res-2021-06` SSL negotiation policy, which enforces a minimum of TLS 1.2 (aligning with the Google deployment) and restricts TLS 1.2 to AEAD (GCM/ChaCha20) cipher suites. Previously the AWS Load Balancer Controller default (`ELBSecurityPolicy-2016-08`) applied, which allowed TLS 1.0 and 1.1. Clients limited to TLS 1.0 or 1.1, or to CBC cipher suites, will no longer be able to connect. Unlike the Google deployment, no resources need to be provisioned by Terraform or manually to set up the policy. * [evict] RID cleanup (`db-manager evict`, including the RID cleanup default `CronJob`) now evicts the expired ISAs and subscriptions of all the DSS instances of the pool, instead of only the ones written by the DSS instance identified by `--locality`. The `--locality` flag of `db-manager evict` is deprecated and has no effect. It will be removed in a future release. +* [deploy] CPU and memory requests and limits of the CockroachDB and core-service containers and the CockroachDB `--cache` and `--max-sql-memory` flags can now be configured with Terraform, Tanka and Helm. See [CPU and memory allocation](docs/operations/performance.md#cpu-and-memory-allocation). ## Minimal database schema version diff --git a/deploy/infrastructure/dependencies/terraform-commons-dss/helm.tf b/deploy/infrastructure/dependencies/terraform-commons-dss/helm.tf index 50b801b87..37c8d8bf4 100644 --- a/deploy/infrastructure/dependencies/terraform-commons-dss/helm.tf +++ b/deploy/infrastructure/dependencies/terraform-commons-dss/helm.tf @@ -18,9 +18,11 @@ resource "local_file" "helm_chart_values" { fullnameOverride = local.helm_crdb_statefulset_name conf = { - join = var.crdb_external_nodes - cluster-name = var.crdb_cluster_name - single-node = false # Always false. Even with 1 replica, we would expect to keep the ability to pool it with another cluster. + join = var.crdb_external_nodes + cluster-name = var.crdb_cluster_name + cache = var.crdb_cache + max-sql-memory = var.crdb_max_sql_memory + single-node = false # Always false. Even with 1 replica, we would expect to keep the ability to pool it with another cluster. } statefulset = { @@ -29,6 +31,7 @@ resource "local_file" "helm_chart_values" { "--locality-advertise-addr=zone=${var.locality}@$(hostname -f)", "--advertise-addr=$${HOSTNAME##*-}.${var.db_hostname_suffix}" ] + resources = var.crdb_resources } storage = { @@ -56,7 +59,8 @@ resource "local_file" "helm_chart_values" { } dss = { - image = var.image + image = var.image + resources = var.core_service_resources conf = { pubKeys = [ @@ -271,7 +275,8 @@ resource "local_file" "helm_chart_values" { } dss = { - image = var.image + image = var.image + resources = var.core_service_resources conf = { pubKeys = [ diff --git a/deploy/infrastructure/dependencies/terraform-commons-dss/tanka.tf b/deploy/infrastructure/dependencies/terraform-commons-dss/tanka.tf index 788123feb..f463ab594 100644 --- a/deploy/infrastructure/dependencies/terraform-commons-dss/tanka.tf +++ b/deploy/infrastructure/dependencies/terraform-commons-dss/tanka.tf @@ -20,8 +20,12 @@ resource "local_file" "tanka_config_main" { VAR_CRDB_EXTERNAL_NODES = join(",", [for a in var.crdb_external_nodes : "'${a}'"]) VAR_STORAGE_CLASS = var.kubernetes_storage_class VAR_DOCKER_IMAGE_NAME = var.image + VAR_CORE_SERVICE_RESOURCES = jsonencode(var.core_service_resources) VAR_CRDB_DOCKER_IMAGE_NAME = "cockroachdb/cockroach:${var.crdb_image_tag}" VAR_CRDB_CLUSTER_NAME = var.crdb_cluster_name + VAR_CRDB_CACHE = var.crdb_cache + VAR_CRDB_MAX_SQL_MEMORY = var.crdb_max_sql_memory + VAR_CRDB_RESOURCES = jsonencode(var.crdb_resources) VAR_YUGABYTE_CLOUD = var.yugabyte_cloud VAR_YUGABYTE_REGION = var.yugabyte_region VAR_YUGABYTE_ZONE = var.yugabyte_zone diff --git a/deploy/infrastructure/dependencies/terraform-commons-dss/templates/main.jsonnet.tmp b/deploy/infrastructure/dependencies/terraform-commons-dss/templates/main.jsonnet.tmp index eeca5f9f1..d9b18df7d 100644 --- a/deploy/infrastructure/dependencies/terraform-commons-dss/templates/main.jsonnet.tmp +++ b/deploy/infrastructure/dependencies/terraform-commons-dss/templates/main.jsonnet.tmp @@ -25,6 +25,9 @@ local metadata = metadataBase { JoinExisting: [${VAR_CRDB_EXTERNAL_NODES}], storageClass: '${VAR_STORAGE_CLASS}', clusterName: '${VAR_CRDB_CLUSTER_NAME}', + cache: '${VAR_CRDB_CACHE}', + maxSqlMemory: '${VAR_CRDB_MAX_SQL_MEMORY}', + resources: ${VAR_CRDB_RESOURCES}, }, yugabyte+: { image: '${VAR_YUGABYTE_DOCKER_IMAGE_NAME}', @@ -62,7 +65,8 @@ local metadata = metadataBase { hostname: '${VAR_APP_HOSTNAME}', publicEndpoint: 'https://${VAR_APP_HOSTNAME}', dumpRequests: false, - sslPolicy: '${VAR_SSL_POLICY}' + sslPolicy: '${VAR_SSL_POLICY}', + resources: ${VAR_CORE_SERVICE_RESOURCES}, }, schema_manager+: { enable: true, diff --git a/deploy/infrastructure/dependencies/terraform-commons-dss/variables.gen.tf b/deploy/infrastructure/dependencies/terraform-commons-dss/variables.gen.tf index d4012be3a..a1f000701 100644 --- a/deploy/infrastructure/dependencies/terraform-commons-dss/variables.gen.tf +++ b/deploy/infrastructure/dependencies/terraform-commons-dss/variables.gen.tf @@ -284,6 +284,68 @@ variable "crdb_cluster_name" { } +variable "crdb_cache" { + type = string + description = <<-EOT + Size of the CockroachDB storage engine cache, passed to the `--cache` flag of `cockroach start`. + Either a percentage of the memory available to the container or an absolute size. + + Example: `25%` or `2GiB` + EOT + + default = "25%" +} + + +variable "crdb_max_sql_memory" { + type = string + description = <<-EOT + Maximum memory CockroachDB can use for SQL queries, passed to the `--max-sql-memory` flag of `cockroach start`. + Either a percentage of the memory available to the container or an absolute size. + + Example: `25%` or `2GiB` + EOT + + default = "25%" +} + + +variable "crdb_resources" { + type = map(map(string)) + description = <<-EOT + Kubernetes CPU and memory requests and limits of the CockroachDB containers. + Leave empty to not set any. + + Example: `{ requests = { cpu = "3.5", memory = "14Gi" }, limits = { cpu = "3.5", memory = "14Gi" } }` + EOT + + default = {} + + validation { + condition = alltrue([for k in keys(var.crdb_resources) : contains(["requests", "limits"], k)]) + error_message = "crdb_resources keys must be `requests` or `limits`." + } +} + + +variable "core_service_resources" { + type = map(map(string)) + description = <<-EOT + Kubernetes CPU and memory requests and limits of the core-service containers. + Leave empty to not set any. + + Example: `{ requests = { cpu = "0.5", memory = "2Gi" }, limits = { memory = "2Gi" } }` + EOT + + default = {} + + validation { + condition = alltrue([for k in keys(var.core_service_resources) : contains(["requests", "limits"], k)]) + error_message = "core_service_resources keys must be `requests` or `limits`." + } +} + + variable "locality" { type = string description = <<-EOT diff --git a/deploy/infrastructure/modules/terraform-aws-dss/TFVARS.gen.md b/deploy/infrastructure/modules/terraform-aws-dss/TFVARS.gen.md index 15a42ee72..48c8bb7a0 100644 --- a/deploy/infrastructure/modules/terraform-aws-dss/TFVARS.gen.md +++ b/deploy/infrastructure/modules/terraform-aws-dss/TFVARS.gen.md @@ -119,6 +119,18 @@ Leave empty to disable record creation.

Name of the kubernetes cluster that will host this DSS instance (should generally describe the DSS instance being hosted)

Example: dss-che-1

+ + core_service_resources (map(map(string))) +

Kubernetes CPU and memory requests and limits of the core-service containers. +Leave empty to not set any.

+

Example: { requests = { cpu = "0.5", memory = "2Gi" }, limits = { memory = "2Gi" } }

+
Default value: {} + + crdb_cache (string) +

Size of the CockroachDB storage engine cache, passed to the --cache flag of cockroach start. +Either a percentage of the memory available to the container or an absolute size.

+

Example: 25% or 2GiB

+
Default value: "25%" crdb_cluster_name (string)

A string that specifies a CRDB cluster name. This is used together to ensure that all newly created @@ -148,6 +160,18 @@ From v.17, the recommended CockroachDB version is v24.1.3.

crdb_locality (string)

This variable has been renamed to locality and is left to warn users about migration.


Default value: "" + + crdb_max_sql_memory (string) +

Maximum memory CockroachDB can use for SQL queries, passed to the --max-sql-memory flag of cockroach start. +Either a percentage of the memory available to the container or an absolute size.

+

Example: 25% or 2GiB

+
Default value: "25%" + + crdb_resources (map(map(string))) +

Kubernetes CPU and memory requests and limits of the CockroachDB containers. +Leave empty to not set any.

+

Example: { requests = { cpu = "3.5", memory = "14Gi" }, limits = { cpu = "3.5", memory = "14Gi" } }

+
Default value: {} datastore_max_open_conns (number)

Maximum number of open connections to the datastore.

diff --git a/deploy/infrastructure/modules/terraform-aws-dss/main.tf b/deploy/infrastructure/modules/terraform-aws-dss/main.tf index 23d577b1b..7da8e0d98 100644 --- a/deploy/infrastructure/modules/terraform-aws-dss/main.tf +++ b/deploy/infrastructure/modules/terraform-aws-dss/main.tf @@ -25,6 +25,10 @@ module "terraform-commons-dss" { app_hostname = var.app_hostname crdb_image_tag = var.crdb_image_tag crdb_cluster_name = var.crdb_cluster_name + crdb_cache = var.crdb_cache + crdb_max_sql_memory = var.crdb_max_sql_memory + crdb_resources = var.crdb_resources + core_service_resources = var.core_service_resources db_hostname_suffix = var.db_hostname_suffix datastore_type = var.datastore_type datastore_max_open_conns = var.datastore_max_open_conns diff --git a/deploy/infrastructure/modules/terraform-aws-dss/variables.gen.tf b/deploy/infrastructure/modules/terraform-aws-dss/variables.gen.tf index c20e043de..aab65c002 100644 --- a/deploy/infrastructure/modules/terraform-aws-dss/variables.gen.tf +++ b/deploy/infrastructure/modules/terraform-aws-dss/variables.gen.tf @@ -411,6 +411,68 @@ variable "crdb_cluster_name" { } +variable "crdb_cache" { + type = string + description = <<-EOT + Size of the CockroachDB storage engine cache, passed to the `--cache` flag of `cockroach start`. + Either a percentage of the memory available to the container or an absolute size. + + Example: `25%` or `2GiB` + EOT + + default = "25%" +} + + +variable "crdb_max_sql_memory" { + type = string + description = <<-EOT + Maximum memory CockroachDB can use for SQL queries, passed to the `--max-sql-memory` flag of `cockroach start`. + Either a percentage of the memory available to the container or an absolute size. + + Example: `25%` or `2GiB` + EOT + + default = "25%" +} + + +variable "crdb_resources" { + type = map(map(string)) + description = <<-EOT + Kubernetes CPU and memory requests and limits of the CockroachDB containers. + Leave empty to not set any. + + Example: `{ requests = { cpu = "3.5", memory = "14Gi" }, limits = { cpu = "3.5", memory = "14Gi" } }` + EOT + + default = {} + + validation { + condition = alltrue([for k in keys(var.crdb_resources) : contains(["requests", "limits"], k)]) + error_message = "crdb_resources keys must be `requests` or `limits`." + } +} + + +variable "core_service_resources" { + type = map(map(string)) + description = <<-EOT + Kubernetes CPU and memory requests and limits of the core-service containers. + Leave empty to not set any. + + Example: `{ requests = { cpu = "0.5", memory = "2Gi" }, limits = { memory = "2Gi" } }` + EOT + + default = {} + + validation { + condition = alltrue([for k in keys(var.core_service_resources) : contains(["requests", "limits"], k)]) + error_message = "core_service_resources keys must be `requests` or `limits`." + } +} + + variable "locality" { type = string description = <<-EOT diff --git a/deploy/infrastructure/modules/terraform-google-dss/TFVARS.gen.md b/deploy/infrastructure/modules/terraform-google-dss/TFVARS.gen.md index e757c4e67..de72ba59a 100644 --- a/deploy/infrastructure/modules/terraform-google-dss/TFVARS.gen.md +++ b/deploy/infrastructure/modules/terraform-google-dss/TFVARS.gen.md @@ -76,6 +76,18 @@ Example:

Name of the kubernetes cluster that will host this DSS instance (should generally describe the DSS instance being hosted)

Example: dss-che-1

+ + core_service_resources (map(map(string))) +

Kubernetes CPU and memory requests and limits of the core-service containers. +Leave empty to not set any.

+

Example: { requests = { cpu = "0.5", memory = "2Gi" }, limits = { memory = "2Gi" } }

+
Default value: {} + + crdb_cache (string) +

Size of the CockroachDB storage engine cache, passed to the --cache flag of cockroach start. +Either a percentage of the memory available to the container or an absolute size.

+

Example: 25% or 2GiB

+
Default value: "25%" crdb_cluster_name (string)

A string that specifies a CRDB cluster name. This is used together to ensure that all newly created @@ -105,6 +117,18 @@ From v.17, the recommended CockroachDB version is v24.1.3.

crdb_locality (string)

This variable has been renamed to locality and is left to warn users about migration.


Default value: "" + + crdb_max_sql_memory (string) +

Maximum memory CockroachDB can use for SQL queries, passed to the --max-sql-memory flag of cockroach start. +Either a percentage of the memory available to the container or an absolute size.

+

Example: 25% or 2GiB

+
Default value: "25%" + + crdb_resources (map(map(string))) +

Kubernetes CPU and memory requests and limits of the CockroachDB containers. +Leave empty to not set any.

+

Example: { requests = { cpu = "3.5", memory = "14Gi" }, limits = { cpu = "3.5", memory = "14Gi" } }

+
Default value: {} datastore_max_open_conns (number)

Maximum number of open connections to the datastore.

diff --git a/deploy/infrastructure/modules/terraform-google-dss/main.tf b/deploy/infrastructure/modules/terraform-google-dss/main.tf index 8cf9088db..937581e06 100644 --- a/deploy/infrastructure/modules/terraform-google-dss/main.tf +++ b/deploy/infrastructure/modules/terraform-google-dss/main.tf @@ -25,6 +25,10 @@ module "terraform-commons-dss" { app_hostname = var.app_hostname crdb_image_tag = var.crdb_image_tag crdb_cluster_name = var.crdb_cluster_name + crdb_cache = var.crdb_cache + crdb_max_sql_memory = var.crdb_max_sql_memory + crdb_resources = var.crdb_resources + core_service_resources = var.core_service_resources db_hostname_suffix = var.db_hostname_suffix datastore_type = var.datastore_type datastore_max_open_conns = var.datastore_max_open_conns diff --git a/deploy/infrastructure/modules/terraform-google-dss/variables.gen.tf b/deploy/infrastructure/modules/terraform-google-dss/variables.gen.tf index ad306b72d..e3a46e319 100644 --- a/deploy/infrastructure/modules/terraform-google-dss/variables.gen.tf +++ b/deploy/infrastructure/modules/terraform-google-dss/variables.gen.tf @@ -400,6 +400,68 @@ variable "crdb_cluster_name" { } +variable "crdb_cache" { + type = string + description = <<-EOT + Size of the CockroachDB storage engine cache, passed to the `--cache` flag of `cockroach start`. + Either a percentage of the memory available to the container or an absolute size. + + Example: `25%` or `2GiB` + EOT + + default = "25%" +} + + +variable "crdb_max_sql_memory" { + type = string + description = <<-EOT + Maximum memory CockroachDB can use for SQL queries, passed to the `--max-sql-memory` flag of `cockroach start`. + Either a percentage of the memory available to the container or an absolute size. + + Example: `25%` or `2GiB` + EOT + + default = "25%" +} + + +variable "crdb_resources" { + type = map(map(string)) + description = <<-EOT + Kubernetes CPU and memory requests and limits of the CockroachDB containers. + Leave empty to not set any. + + Example: `{ requests = { cpu = "3.5", memory = "14Gi" }, limits = { cpu = "3.5", memory = "14Gi" } }` + EOT + + default = {} + + validation { + condition = alltrue([for k in keys(var.crdb_resources) : contains(["requests", "limits"], k)]) + error_message = "crdb_resources keys must be `requests` or `limits`." + } +} + + +variable "core_service_resources" { + type = map(map(string)) + description = <<-EOT + Kubernetes CPU and memory requests and limits of the core-service containers. + Leave empty to not set any. + + Example: `{ requests = { cpu = "0.5", memory = "2Gi" }, limits = { memory = "2Gi" } }` + EOT + + default = {} + + validation { + condition = alltrue([for k in keys(var.core_service_resources) : contains(["requests", "limits"], k)]) + error_message = "core_service_resources keys must be `requests` or `limits`." + } +} + + variable "locality" { type = string description = <<-EOT diff --git a/deploy/infrastructure/utils/definitions/core_service_resources.tf b/deploy/infrastructure/utils/definitions/core_service_resources.tf new file mode 100644 index 000000000..ea9679cd8 --- /dev/null +++ b/deploy/infrastructure/utils/definitions/core_service_resources.tf @@ -0,0 +1,16 @@ +variable "core_service_resources" { + type = map(map(string)) + description = <<-EOT + Kubernetes CPU and memory requests and limits of the core-service containers. + Leave empty to not set any. + + Example: `{ requests = { cpu = "0.5", memory = "2Gi" }, limits = { memory = "2Gi" } }` + EOT + + default = {} + + validation { + condition = alltrue([for k in keys(var.core_service_resources) : contains(["requests", "limits"], k)]) + error_message = "core_service_resources keys must be `requests` or `limits`." + } +} diff --git a/deploy/infrastructure/utils/definitions/crdb_cache.tf b/deploy/infrastructure/utils/definitions/crdb_cache.tf new file mode 100644 index 000000000..6a733f8c4 --- /dev/null +++ b/deploy/infrastructure/utils/definitions/crdb_cache.tf @@ -0,0 +1,11 @@ +variable "crdb_cache" { + type = string + description = <<-EOT + Size of the CockroachDB storage engine cache, passed to the `--cache` flag of `cockroach start`. + Either a percentage of the memory available to the container or an absolute size. + + Example: `25%` or `2GiB` + EOT + + default = "25%" +} diff --git a/deploy/infrastructure/utils/definitions/crdb_max_sql_memory.tf b/deploy/infrastructure/utils/definitions/crdb_max_sql_memory.tf new file mode 100644 index 000000000..64f04bc5c --- /dev/null +++ b/deploy/infrastructure/utils/definitions/crdb_max_sql_memory.tf @@ -0,0 +1,11 @@ +variable "crdb_max_sql_memory" { + type = string + description = <<-EOT + Maximum memory CockroachDB can use for SQL queries, passed to the `--max-sql-memory` flag of `cockroach start`. + Either a percentage of the memory available to the container or an absolute size. + + Example: `25%` or `2GiB` + EOT + + default = "25%" +} diff --git a/deploy/infrastructure/utils/definitions/crdb_resources.tf b/deploy/infrastructure/utils/definitions/crdb_resources.tf new file mode 100644 index 000000000..fd2360d02 --- /dev/null +++ b/deploy/infrastructure/utils/definitions/crdb_resources.tf @@ -0,0 +1,16 @@ +variable "crdb_resources" { + type = map(map(string)) + description = <<-EOT + Kubernetes CPU and memory requests and limits of the CockroachDB containers. + Leave empty to not set any. + + Example: `{ requests = { cpu = "3.5", memory = "14Gi" }, limits = { cpu = "3.5", memory = "14Gi" } }` + EOT + + default = {} + + validation { + condition = alltrue([for k in keys(var.crdb_resources) : contains(["requests", "limits"], k)]) + error_message = "crdb_resources keys must be `requests` or `limits`." + } +} diff --git a/deploy/infrastructure/utils/variables.py b/deploy/infrastructure/utils/variables.py index be8457e76..07357048e 100755 --- a/deploy/infrastructure/utils/variables.py +++ b/deploy/infrastructure/utils/variables.py @@ -48,6 +48,10 @@ "desired_aux_db_version", "crdb_image_tag", "crdb_cluster_name", + "crdb_cache", + "crdb_max_sql_memory", + "crdb_resources", + "core_service_resources", "locality", "datastore_max_open_conns", "crdb_external_nodes", diff --git a/deploy/operations/ci/aws-1/variables.gen.tf b/deploy/operations/ci/aws-1/variables.gen.tf index c20e043de..aab65c002 100644 --- a/deploy/operations/ci/aws-1/variables.gen.tf +++ b/deploy/operations/ci/aws-1/variables.gen.tf @@ -411,6 +411,68 @@ variable "crdb_cluster_name" { } +variable "crdb_cache" { + type = string + description = <<-EOT + Size of the CockroachDB storage engine cache, passed to the `--cache` flag of `cockroach start`. + Either a percentage of the memory available to the container or an absolute size. + + Example: `25%` or `2GiB` + EOT + + default = "25%" +} + + +variable "crdb_max_sql_memory" { + type = string + description = <<-EOT + Maximum memory CockroachDB can use for SQL queries, passed to the `--max-sql-memory` flag of `cockroach start`. + Either a percentage of the memory available to the container or an absolute size. + + Example: `25%` or `2GiB` + EOT + + default = "25%" +} + + +variable "crdb_resources" { + type = map(map(string)) + description = <<-EOT + Kubernetes CPU and memory requests and limits of the CockroachDB containers. + Leave empty to not set any. + + Example: `{ requests = { cpu = "3.5", memory = "14Gi" }, limits = { cpu = "3.5", memory = "14Gi" } }` + EOT + + default = {} + + validation { + condition = alltrue([for k in keys(var.crdb_resources) : contains(["requests", "limits"], k)]) + error_message = "crdb_resources keys must be `requests` or `limits`." + } +} + + +variable "core_service_resources" { + type = map(map(string)) + description = <<-EOT + Kubernetes CPU and memory requests and limits of the core-service containers. + Leave empty to not set any. + + Example: `{ requests = { cpu = "0.5", memory = "2Gi" }, limits = { memory = "2Gi" } }` + EOT + + default = {} + + validation { + condition = alltrue([for k in keys(var.core_service_resources) : contains(["requests", "limits"], k)]) + error_message = "core_service_resources keys must be `requests` or `limits`." + } +} + + variable "locality" { type = string description = <<-EOT diff --git a/deploy/services/helm-charts/dss/templates/dss-core-service.yaml b/deploy/services/helm-charts/dss/templates/dss-core-service.yaml index 9902a46ff..78a400908 100644 --- a/deploy/services/helm-charts/dss/templates/dss-core-service.yaml +++ b/deploy/services/helm-charts/dss/templates/dss-core-service.yaml @@ -92,6 +92,10 @@ spec: {{- end }} command: - core-service + {{- with $dss.resources }} + resources: + {{- toYaml . | nindent 12 }} + {{- end }} image: {{ $dss.image }} imagePullPolicy: {{ $dss.imagePullPolicy | default "Always" }} name: core-service diff --git a/deploy/services/helm-charts/dss/values.schema.json b/deploy/services/helm-charts/dss/values.schema.json index 5e9fa6401..9841372d8 100644 --- a/deploy/services/helm-charts/dss/values.schema.json +++ b/deploy/services/helm-charts/dss/values.schema.json @@ -242,6 +242,10 @@ "type": "string", "description": "Image of the DSS. Please note that the usage of the `latest` tag is discouraged to prevent accidental upgrades in case of restart. Example: `docker.io/interuss/dss:v0.15.0`. Official image releases: https://hub.docker.com/r/interuss/dss/tags" }, + "resources": { + "type": "object", + "description": "Kubernetes CPU and memory requests and limits of the core-service containers. Example: `{requests: {cpu: '0.5', memory: 2Gi}, limits: {memory: 2Gi}}`" + }, "conf": { "type": "object", "properties": { diff --git a/deploy/services/helm-charts/dss/values.yaml b/deploy/services/helm-charts/dss/values.yaml index e9f72b9ad..0b2c7f924 100644 --- a/deploy/services/helm-charts/dss/values.yaml +++ b/deploy/services/helm-charts/dss/values.yaml @@ -1,6 +1,7 @@ # Default configuration dss: + resources: {} conf: enableScd: true evict: diff --git a/deploy/services/tanka/cockroachdb.libsonnet b/deploy/services/tanka/cockroachdb.libsonnet index c43f257cb..db87333ca 100644 --- a/deploy/services/tanka/cockroachdb.libsonnet +++ b/deploy/services/tanka/cockroachdb.libsonnet @@ -55,6 +55,7 @@ local volumes = import 'volumes.libsonnet'; value: 'kubernetes-multiregion', }, ], + resources: metadata.cockroach.resources, livenessProbe: { httpGet: { path: '/health', @@ -90,8 +91,8 @@ local volumes = import 'volumes.libsonnet'; locality: 'zone=' + metadata.locality, 'locality-advertise-addr': 'zone=' + metadata.locality + '@$(hostname -f)', 'http-addr': '0.0.0.0', - cache: '25%', - 'max-sql-memory': '25%', + cache: metadata.cockroach.cache, + 'max-sql-memory': metadata.cockroach.maxSqlMemory, } + if metadata.cockroach.clusterName != "" then { 'cluster-name': metadata.cockroach.clusterName, } else {}, diff --git a/deploy/services/tanka/core-service.libsonnet b/deploy/services/tanka/core-service.libsonnet index fd3bf56a5..820e488ad 100644 --- a/deploy/services/tanka/core-service.libsonnet +++ b/deploy/services/tanka/core-service.libsonnet @@ -118,6 +118,7 @@ local awsLoadBalancer(metadata) = base.AWSLoadBalancerWithManagedCert(metadata, }, ] else [], volumeMounts: volumes.all(metadata).backendMounts, + resources: metadata.backend.resources, command: ['core-service'], args_:: { addr: ':' + metadata.backend.port, diff --git a/deploy/services/tanka/metadata_base.libsonnet b/deploy/services/tanka/metadata_base.libsonnet index 4122b2423..775f05d60 100644 --- a/deploy/services/tanka/metadata_base.libsonnet +++ b/deploy/services/tanka/metadata_base.libsonnet @@ -25,6 +25,9 @@ JoinExisting: [], storageClass: 'standard', clusterName: '', + cache: '25%', // Value of the --cache flag of `cockroach start` + maxSqlMemory: '25%', // Value of the --max-sql-memory flag of `cockroach start` + resources: {}, // Kubernetes container resources, e.g. { requests: { cpu: '3.5', memory: '14Gi' }, limits: { cpu: '3.5', memory: '14Gi' } } }, yugabyte: { image: error 'must specify yugabyte db image', @@ -67,6 +70,7 @@ dumpRequests: false, certName: if $.cloud_provider == "aws" then error 'must specify certName for AWS cloud provider', # Only used by AWS sslPolicy: '', # SSL Policy Name. Only used by Google Cloud. + resources: {}, // Kubernetes container resources, e.g. { requests: { cpu: '0.5', memory: '2Gi' }, limits: { memory: '2Gi' } } }, alert: { enable: false, diff --git a/docs/operations/performance.md b/docs/operations/performance.md index 78a58b73c..2c31882b4 100644 --- a/docs/operations/performance.md +++ b/docs/operations/performance.md @@ -6,6 +6,57 @@ Overtime, old entries should be removed to ensure the system is not overloaded p See the detailed [section about cleanup](cleanup.md). +## CPU and memory allocation + +By default, the deployment tooling does not set any Kubernetes CPU or memory requests or limits on the CockroachDB and core-service containers. +Kubernetes may then place them on nodes without enough free memory and kill them when the node runs out of memory (see issue [#1731](https://github.com/interuss/dss/issues/1731)). + +The following settings are available: + +* CPU and memory requests and limits of the CockroachDB and core-service containers. +* CockroachDB `--cache` and `--max-sql-memory` flags (both `25%` by default). See [CockroachDB recommendations](https://www.cockroachlabs.com/docs/stable/recommended-production-settings#cache-and-sql-memory-size) before changing them. + +To set them: + +1. Set the values according to the deployment tool: + + === "Terraform" + Set the following variables (see `TFVARS.gen.md` for details): + + * `crdb_resources`, e.g. `{ requests = { cpu = "3.5", memory = "14Gi" }, limits = { cpu = "3.5", memory = "14Gi" } }` + * `crdb_cache` and `crdb_max_sql_memory`, e.g. `"25%"` + * `core_service_resources`, e.g. `{ requests = { cpu = "0.5", memory = "2Gi" }, limits = { memory = "2Gi" } }` + + Then run `terraform apply` to regenerate the Tanka and Helm configuration. + + === "Tanka" + Set the following fields of the metadata in your `main.jsonnet`: + + ```jsonnet + cockroach+: { + resources: { requests: { cpu: '3.5', memory: '14Gi' }, limits: { cpu: '3.5', memory: '14Gi' } }, + cache: '25%', + maxSqlMemory: '25%', + }, + backend+: { + resources: { requests: { cpu: '0.5', memory: '2Gi' }, limits: { memory: '2Gi' } }, + }, + ``` + + === "Helm" + Set the following values: + + ```yaml + cockroachdb: + conf: + cache: 25% + max-sql-memory: 25% + statefulset: + resources: {requests: {cpu: "3.5", memory: 14Gi}, limits: {cpu: "3.5", memory: 14Gi}} + dss: + resources: {requests: {cpu: "0.5", memory: 2Gi}, limits: {memory: 2Gi}} + ``` + ## The SCD global lock option !!! danger