From a1affe852cd433cbd7a1e494f97307595e20314b Mon Sep 17 00:00:00 2001 From: Jake Heath <76011913+jakeyheath@users.noreply.github.com> Date: Fri, 20 Oct 2023 04:17:05 -0700 Subject: [PATCH] feat: allow stacks to change cpu/mem requests (#2614) --- terraform/modules/happy-stack-eks/README.md | 2 +- terraform/modules/happy-stack-eks/main.tf | 2 ++ terraform/modules/happy-stack-eks/variables.tf | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/terraform/modules/happy-stack-eks/README.md b/terraform/modules/happy-stack-eks/README.md index 6b45ca92d7..485583c965 100644 --- a/terraform/modules/happy-stack-eks/README.md +++ b/terraform/modules/happy-stack-eks/README.md @@ -59,7 +59,7 @@ | [image\_tags](#input\_image\_tags) | Override image tag for each docker image | `map(string)` | `{}` | no | | [k8s\_namespace](#input\_k8s\_namespace) | K8S namespace for this stack | `string` | n/a | yes | | [routing\_method](#input\_routing\_method) | Traffic routing method for this stack. Valid options are 'DOMAIN', when every service gets a unique domain name, or a 'CONTEXT' when all services share the same domain name, and routing is done by request path. | `string` | `"DOMAIN"` | no | -| [services](#input\_services) | The services you want to deploy as part of this stack. |
map(object({| n/a | yes | +| [services](#input\_services) | The services you want to deploy as part of this stack. |
name : string,
service_type : optional(string, "INTERNAL"),
allow_mesh_services : optional(list(object({
service : optional(string, null),
stack : optional(string, null),
service_account_name : optional(string, null)
})), null),
ingress_security_groups : optional(list(string), []), // Only used for VPC service_type
alb : optional(object({
name : string,
listener_port : number,
}), null), // Only used for TARGET_GROUP_ONLY
desired_count : optional(number, 2),
max_count : optional(number, 2),
scaling_cpu_threshold_percentage : optional(number, 80),
port : optional(number, 80),
scheme : optional(string, "HTTP"),
cmd : optional(list(string), []),
args : optional(list(string), []),
image_pull_policy : optional(string, "IfNotPresent"), // Supported values: IfNotPresent, Always, Never
tag_mutability : optional(bool, true),
scan_on_push : optional(bool, false),
service_port : optional(number, null),
service_scheme : optional(string, "HTTP"),
memory : optional(string, "100Mi"),
cpu : optional(string, "100m"),
gpu : optional(number, null), // Whole number of GPUs to request, 0 will schedule all available GPUs. Requires GPU-enabled nodes in the cluster, `k8s-device-plugin` installed, platform_architecture = "amd64", and additional_node_selectors = { "nvidia.com/gpu.present" = "true" } present.
health_check_path : optional(string, "/"),
aws_iam : optional(object({
policy_json : optional(string, ""),
service_account_name : optional(string, null),
}), {}),
path : optional(string, "/*"), // Only used for CONTEXT and TARGET_GROUP_ONLY routing
priority : optional(number, 0), // Only used for CONTEXT and TARGET_GROUP_ONLY routing
success_codes : optional(string, "200-499"),
synthetics : optional(bool, false),
initial_delay_seconds : optional(number, 30),
alb_idle_timeout : optional(number, 60) // in seconds
period_seconds : optional(number, 3),
platform_architecture : optional(string, "amd64"), // Supported values: amd64, arm64; GPU nodes are amd64 only.
additional_node_selectors : optional(map(string), {}), // For GPU use: { "nvidia.com/gpu.present" = "true" }
bypasses : optional(map(object({ // Only used for INTERNAL service_type
paths = optional(set(string), [])
methods = optional(set(string), [])
})), {})
sidecars : optional(map(object({
image : string
tag : string
port : optional(number, 80),
scheme : optional(string, "HTTP"),
memory : optional(string, "100Mi")
cpu : optional(string, "100m")
image_pull_policy : optional(string, "IfNotPresent") // Supported values: IfNotPresent, Always, Never
health_check_path : optional(string, "/")
initial_delay_seconds : optional(number, 30),
period_seconds : optional(number, 3),
})), {})
}))
map(object({| n/a | yes | | [skip\_config\_injection](#input\_skip\_config\_injection) | Skip injecting app configs into the services / tasks | `bool` | `false` | no | | [stack\_name](#input\_stack\_name) | Happy Path stack name | `string` | n/a | yes | | [stack\_prefix](#input\_stack\_prefix) | Do bucket storage paths and db schemas need to be prefixed with the stack name? (Usually '/{stack\_name}' for dev stacks, and '' for staging/prod stacks) | `string` | `""` | no | diff --git a/terraform/modules/happy-stack-eks/main.tf b/terraform/modules/happy-stack-eks/main.tf index 9ef5d8fa0c..93fa1e60ee 100644 --- a/terraform/modules/happy-stack-eks/main.tf +++ b/terraform/modules/happy-stack-eks/main.tf @@ -169,7 +169,9 @@ module "services" { max_count = try(each.value.max_count, each.value.desired_count) scaling_cpu_threshold_percentage = each.value.scaling_cpu_threshold_percentage memory = each.value.memory + memory_requests = each.value.memory_requests cpu = each.value.cpu + cpu_requests = each.value.cpu_requests gpu = each.value.gpu health_check_path = each.value.health_check_path k8s_namespace = var.k8s_namespace diff --git a/terraform/modules/happy-stack-eks/variables.tf b/terraform/modules/happy-stack-eks/variables.tf index 1260b35025..79f8b64d92 100644 --- a/terraform/modules/happy-stack-eks/variables.tf +++ b/terraform/modules/happy-stack-eks/variables.tf @@ -69,7 +69,9 @@ variable "services" { service_port : optional(number, null), service_scheme : optional(string, "HTTP"), memory : optional(string, "100Mi"), + memory_requests : optional(string, "100Mi"), cpu : optional(string, "100m"), + cpu_requests : optional(string, "100m"), gpu : optional(number, null), // Whole number of GPUs to request, 0 will schedule all available GPUs. Requires GPU-enabled nodes in the cluster, `k8s-device-plugin` installed, platform_architecture = "amd64", and additional_node_selectors = { "nvidia.com/gpu.present" = "true" } present. health_check_path : optional(string, "/"), aws_iam : optional(object({
name : string,
service_type : optional(string, "INTERNAL"),
allow_mesh_services : optional(list(object({
service : optional(string, null),
stack : optional(string, null),
service_account_name : optional(string, null)
})), null),
ingress_security_groups : optional(list(string), []), // Only used for VPC service_type
alb : optional(object({
name : string,
listener_port : number,
}), null), // Only used for TARGET_GROUP_ONLY
desired_count : optional(number, 2),
max_count : optional(number, 2),
scaling_cpu_threshold_percentage : optional(number, 80),
port : optional(number, 80),
scheme : optional(string, "HTTP"),
cmd : optional(list(string), []),
args : optional(list(string), []),
image_pull_policy : optional(string, "IfNotPresent"), // Supported values: IfNotPresent, Always, Never
tag_mutability : optional(bool, true),
scan_on_push : optional(bool, false),
service_port : optional(number, null),
service_scheme : optional(string, "HTTP"),
memory : optional(string, "100Mi"),
memory_requests : optional(string, "100Mi"),
cpu : optional(string, "100m"),
cpu_requests : optional(string, "100m"),
gpu : optional(number, null), // Whole number of GPUs to request, 0 will schedule all available GPUs. Requires GPU-enabled nodes in the cluster, `k8s-device-plugin` installed, platform_architecture = "amd64", and additional_node_selectors = { "nvidia.com/gpu.present" = "true" } present.
health_check_path : optional(string, "/"),
aws_iam : optional(object({
policy_json : optional(string, ""),
service_account_name : optional(string, null),
}), {}),
path : optional(string, "/*"), // Only used for CONTEXT and TARGET_GROUP_ONLY routing
priority : optional(number, 0), // Only used for CONTEXT and TARGET_GROUP_ONLY routing
success_codes : optional(string, "200-499"),
synthetics : optional(bool, false),
initial_delay_seconds : optional(number, 30),
alb_idle_timeout : optional(number, 60) // in seconds
period_seconds : optional(number, 3),
platform_architecture : optional(string, "amd64"), // Supported values: amd64, arm64; GPU nodes are amd64 only.
additional_node_selectors : optional(map(string), {}), // For GPU use: { "nvidia.com/gpu.present" = "true" }
bypasses : optional(map(object({ // Only used for INTERNAL service_type
paths = optional(set(string), [])
methods = optional(set(string), [])
})), {})
sidecars : optional(map(object({
image : string
tag : string
port : optional(number, 80),
scheme : optional(string, "HTTP"),
memory : optional(string, "100Mi")
cpu : optional(string, "100m")
image_pull_policy : optional(string, "IfNotPresent") // Supported values: IfNotPresent, Always, Never
health_check_path : optional(string, "/")
initial_delay_seconds : optional(number, 30),
period_seconds : optional(number, 3),
})), {})
}))