Skip to content

Commit

Permalink
feat: allow stacks to change cpu/mem requests (#2614)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakeyheath authored Oct 20, 2023
1 parent 964e735 commit a1affe8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion terraform/modules/happy-stack-eks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
| <a name="input_image_tags"></a> [image\_tags](#input\_image\_tags) | Override image tag for each docker image | `map(string)` | `{}` | no |
| <a name="input_k8s_namespace"></a> [k8s\_namespace](#input\_k8s\_namespace) | K8S namespace for this stack | `string` | n/a | yes |
| <a name="input_routing_method"></a> [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 |
| <a name="input_services"></a> [services](#input\_services) | The services you want to deploy as part of this stack. | <pre>map(object({<br> name : string,<br> service_type : optional(string, "INTERNAL"),<br> allow_mesh_services : optional(list(object({<br> service : optional(string, null),<br> stack : optional(string, null),<br> service_account_name : optional(string, null)<br> })), null),<br> ingress_security_groups : optional(list(string), []), // Only used for VPC service_type<br> alb : optional(object({<br> name : string,<br> listener_port : number,<br> }), null), // Only used for TARGET_GROUP_ONLY<br> desired_count : optional(number, 2),<br> max_count : optional(number, 2),<br> scaling_cpu_threshold_percentage : optional(number, 80),<br> port : optional(number, 80),<br> scheme : optional(string, "HTTP"),<br> cmd : optional(list(string), []),<br> args : optional(list(string), []),<br> image_pull_policy : optional(string, "IfNotPresent"), // Supported values: IfNotPresent, Always, Never<br> tag_mutability : optional(bool, true),<br> scan_on_push : optional(bool, false),<br> service_port : optional(number, null),<br> service_scheme : optional(string, "HTTP"),<br> memory : optional(string, "100Mi"),<br> cpu : optional(string, "100m"),<br> 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.<br> health_check_path : optional(string, "/"),<br> aws_iam : optional(object({<br> policy_json : optional(string, ""),<br> service_account_name : optional(string, null),<br> }), {}),<br> path : optional(string, "/*"), // Only used for CONTEXT and TARGET_GROUP_ONLY routing<br> priority : optional(number, 0), // Only used for CONTEXT and TARGET_GROUP_ONLY routing<br> success_codes : optional(string, "200-499"),<br> synthetics : optional(bool, false),<br> initial_delay_seconds : optional(number, 30),<br> alb_idle_timeout : optional(number, 60) // in seconds<br> period_seconds : optional(number, 3),<br> platform_architecture : optional(string, "amd64"), // Supported values: amd64, arm64; GPU nodes are amd64 only.<br> additional_node_selectors : optional(map(string), {}), // For GPU use: { "nvidia.com/gpu.present" = "true" }<br> bypasses : optional(map(object({ // Only used for INTERNAL service_type<br> paths = optional(set(string), [])<br> methods = optional(set(string), [])<br> })), {})<br> sidecars : optional(map(object({<br> image : string<br> tag : string<br> port : optional(number, 80),<br> scheme : optional(string, "HTTP"),<br> memory : optional(string, "100Mi")<br> cpu : optional(string, "100m")<br> image_pull_policy : optional(string, "IfNotPresent") // Supported values: IfNotPresent, Always, Never<br> health_check_path : optional(string, "/")<br> initial_delay_seconds : optional(number, 30),<br> period_seconds : optional(number, 3),<br> })), {})<br> }))</pre> | n/a | yes |
| <a name="input_services"></a> [services](#input\_services) | The services you want to deploy as part of this stack. | <pre>map(object({<br> name : string,<br> service_type : optional(string, "INTERNAL"),<br> allow_mesh_services : optional(list(object({<br> service : optional(string, null),<br> stack : optional(string, null),<br> service_account_name : optional(string, null)<br> })), null),<br> ingress_security_groups : optional(list(string), []), // Only used for VPC service_type<br> alb : optional(object({<br> name : string,<br> listener_port : number,<br> }), null), // Only used for TARGET_GROUP_ONLY<br> desired_count : optional(number, 2),<br> max_count : optional(number, 2),<br> scaling_cpu_threshold_percentage : optional(number, 80),<br> port : optional(number, 80),<br> scheme : optional(string, "HTTP"),<br> cmd : optional(list(string), []),<br> args : optional(list(string), []),<br> image_pull_policy : optional(string, "IfNotPresent"), // Supported values: IfNotPresent, Always, Never<br> tag_mutability : optional(bool, true),<br> scan_on_push : optional(bool, false),<br> service_port : optional(number, null),<br> service_scheme : optional(string, "HTTP"),<br> memory : optional(string, "100Mi"),<br> memory_requests : optional(string, "100Mi"),<br> cpu : optional(string, "100m"),<br> cpu_requests : optional(string, "100m"),<br> 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.<br> health_check_path : optional(string, "/"),<br> aws_iam : optional(object({<br> policy_json : optional(string, ""),<br> service_account_name : optional(string, null),<br> }), {}),<br> path : optional(string, "/*"), // Only used for CONTEXT and TARGET_GROUP_ONLY routing<br> priority : optional(number, 0), // Only used for CONTEXT and TARGET_GROUP_ONLY routing<br> success_codes : optional(string, "200-499"),<br> synthetics : optional(bool, false),<br> initial_delay_seconds : optional(number, 30),<br> alb_idle_timeout : optional(number, 60) // in seconds<br> period_seconds : optional(number, 3),<br> platform_architecture : optional(string, "amd64"), // Supported values: amd64, arm64; GPU nodes are amd64 only.<br> additional_node_selectors : optional(map(string), {}), // For GPU use: { "nvidia.com/gpu.present" = "true" }<br> bypasses : optional(map(object({ // Only used for INTERNAL service_type<br> paths = optional(set(string), [])<br> methods = optional(set(string), [])<br> })), {})<br> sidecars : optional(map(object({<br> image : string<br> tag : string<br> port : optional(number, 80),<br> scheme : optional(string, "HTTP"),<br> memory : optional(string, "100Mi")<br> cpu : optional(string, "100m")<br> image_pull_policy : optional(string, "IfNotPresent") // Supported values: IfNotPresent, Always, Never<br> health_check_path : optional(string, "/")<br> initial_delay_seconds : optional(number, 30),<br> period_seconds : optional(number, 3),<br> })), {})<br> }))</pre> | n/a | yes |
| <a name="input_skip_config_injection"></a> [skip\_config\_injection](#input\_skip\_config\_injection) | Skip injecting app configs into the services / tasks | `bool` | `false` | no |
| <a name="input_stack_name"></a> [stack\_name](#input\_stack\_name) | Happy Path stack name | `string` | n/a | yes |
| <a name="input_stack_prefix"></a> [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 |
Expand Down
2 changes: 2 additions & 0 deletions terraform/modules/happy-stack-eks/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions terraform/modules/happy-stack-eks/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit a1affe8

Please sign in to comment.