diff --git a/airflow/helm/values.tmpl.yaml b/airflow/helm/values.tmpl.yaml index 6c6f067f..2d6abe31 100644 --- a/airflow/helm/values.tmpl.yaml +++ b/airflow/helm/values.tmpl.yaml @@ -56,10 +56,10 @@ affinity: values: ["on-demand"] - key: "karpenter.k8s.aws/instance-family" operator: "In" - values: ["c6i", "c5"] + values: ["r5"] - key: "karpenter.k8s.aws/instance-cpu" operator: "In" - values: ["2", "4"] + values: ["8"] topologySpreadConstraints: - maxSkew: 1 @@ -248,7 +248,9 @@ workers: keda: enabled: true pollingInterval: 1 - minReplicaCount: 1 + # Minimum node available for celery workers + # Set to 1 to always have a worker node available to run tasks + minReplicaCount: 0 maxReplicaCount: 128 # Specify HPA related options # https://github.com/kubernetes/enhancements/blob/master/keps/sig-autoscaling/853-configurable-hpa-scale-velocity/README.md diff --git a/terraform-unity/main.tf b/terraform-unity/main.tf index 74822380..4b72d525 100644 --- a/terraform-unity/main.tf +++ b/terraform-unity/main.tf @@ -50,6 +50,7 @@ module "unity-sps-database" { venue = var.venue service_area = var.service_area release = var.release + db_instance_class = var.db_instance_class } module "unity-sps-efs" { diff --git a/terraform-unity/modules/terraform-unity-sps-database/main.tf b/terraform-unity/modules/terraform-unity-sps-database/main.tf index e14e2205..f27de316 100644 --- a/terraform-unity/modules/terraform-unity-sps-database/main.tf +++ b/terraform-unity/modules/terraform-unity-sps-database/main.tf @@ -68,7 +68,7 @@ resource "aws_db_instance" "sps_db" { storage_type = "gp3" engine = "postgres" engine_version = "16.8" - instance_class = "db.m5d.2xlarge" + instance_class = var.db_instance_class db_name = "sps_db" username = "db_user" password = aws_secretsmanager_secret_version.db.secret_string diff --git a/terraform-unity/modules/terraform-unity-sps-database/variables.tf b/terraform-unity/modules/terraform-unity-sps-database/variables.tf index 54189e70..e99fb7d0 100644 --- a/terraform-unity/modules/terraform-unity-sps-database/variables.tf +++ b/terraform-unity/modules/terraform-unity-sps-database/variables.tf @@ -17,3 +17,8 @@ variable "release" { description = "The software release version." type = string } + +variable "db_instance_class" { + description = "The SPS RDS database instance class" + type = string +} diff --git a/terraform-unity/modules/terraform-unity-sps-ogc-processes-api/main.tf b/terraform-unity/modules/terraform-unity-sps-ogc-processes-api/main.tf index 9153ba39..d17e7842 100644 --- a/terraform-unity/modules/terraform-unity-sps-ogc-processes-api/main.tf +++ b/terraform-unity/modules/terraform-unity-sps-ogc-processes-api/main.tf @@ -17,6 +17,34 @@ resource "kubernetes_deployment" "redis" { } } spec { + affinity { + node_affinity { + required_during_scheduling_ignored_during_execution { + node_selector_term { + match_expressions { + key = "karpenter.sh/nodepool" + operator = "In" + values = compact([for pool in var.karpenter_node_pools : pool if pool == "airflow-core-components"]) + } + match_expressions { + key = "karpenter.sh/capacity-type" + operator = "In" + values = ["on-demand"] + } + match_expressions { + key = "karpenter.k8s.aws/instance-family" + operator = "In" + values = ["r5"] + } + match_expressions { + key = "karpenter.k8s.aws/instance-cpu" + operator = "In" + values = ["8"] + } + } + } + } + } container { name = "redis" image = "${var.docker_images.redis.name}:${var.docker_images.redis.tag}" @@ -83,12 +111,12 @@ resource "kubernetes_deployment" "ogc_processes_api" { match_expressions { key = "karpenter.k8s.aws/instance-family" operator = "In" - values = ["c6i", "c5"] + values = ["r5"] } match_expressions { key = "karpenter.k8s.aws/instance-cpu" operator = "In" - values = ["4"] + values = ["8"] } } } diff --git a/terraform-unity/variables.tf b/terraform-unity/variables.tf index 9e766054..ca840967 100644 --- a/terraform-unity/variables.tf +++ b/terraform-unity/variables.tf @@ -283,7 +283,7 @@ variable "karpenter_node_pools" { memory = "320Gi" } disruption = { - consolidationPolicy = "WhenEmpty" + consolidationPolicy = "WhenEmptyOrUnderutilized" consolidateAfter = "1m" } }, @@ -367,3 +367,9 @@ variable "installprefix" { type = string default = "" } + +variable "db_instance_class" { + description = "The SPS RDS database instance class" + type = string + default = "db.m5d.xlarge" +}