diff --git a/terraform/modules/happy-service-eks/README.md b/terraform/modules/happy-service-eks/README.md index bd74db60ca..64faf5e58a 100644 --- a/terraform/modules/happy-service-eks/README.md +++ b/terraform/modules/happy-service-eks/README.md @@ -66,6 +66,7 @@ | [deployment\_stage](#input\_deployment\_stage) | The name of the deployment stage of the Application | `string` | `"dev"` | no | | [desired\_count](#input\_desired\_count) | How many instances of this task should we run across our cluster? | `number` | `2` | no | | [eks\_cluster](#input\_eks\_cluster) | eks-cluster module output |
object({| n/a | yes | +| [emptydir\_volumes](#input\_emptydir\_volumes) | define any emptyDir volumes to make available to the pod |
cluster_id : string,
cluster_arn : string,
cluster_endpoint : string,
cluster_ca : string,
cluster_oidc_issuer_url : string,
cluster_version : string,
worker_iam_role_name : string,
worker_security_group : string,
oidc_provider_arn : string,
})
list(object({| `[]` | no | | [gpu](#input\_gpu) | Number of GPUs per pod, 0 allocates all available GPUs | `number` | `null` | no | | [gpu\_requests](#input\_gpu\_requests) | Number of GPUs requested per pod, 0 allocates all available GPUs | `number` | `null` | no | | [health\_check\_command](#input\_health\_check\_command) | Health check command to run for CLI services | `list(string)` | `[]` | no | diff --git a/terraform/modules/happy-service-eks/main.tf b/terraform/modules/happy-service-eks/main.tf index ba07fab16d..569c1f7572 100644 --- a/terraform/modules/happy-service-eks/main.tf +++ b/terraform/modules/happy-service-eks/main.tf @@ -311,6 +311,14 @@ resource "kubernetes_deployment_v1" "deployment" { } } + dynamic "volume_mount" { + for_each = toset(var.emptydir_volumes) + content { + mount_path = "/var/${volume_mount.value.name}" + name = volume_mount.value.name + } + } + dynamic "liveness_probe" { for_each = length(var.health_check_command) == 0 ? [] : [var.health_check_command] content { @@ -422,7 +430,13 @@ resource "kubernetes_deployment_v1" "deployment" { } } } - + dynamic "volume_mount" { + for_each = toset(var.emptydir_volumes) + content { + mount_path = "/var/${volume_mount.value.name}" + name = volume_mount.value.name + } + } dynamic "env" { for_each = var.additional_env_vars content { @@ -526,7 +540,13 @@ resource "kubernetes_deployment_v1" "deployment" { read_only = true } } - + dynamic "volume_mount" { + for_each = toset(var.emptydir_volumes) + content { + mount_path = "/var/${volume_mount.value.name}" + name = volume_mount.value.name + } + } env { name = "DEPLOYMENT_STAGE" value = var.deployment_stage @@ -631,6 +651,16 @@ resource "kubernetes_deployment_v1" "deployment" { name = volume.value } } + + dynamic "volume" { + for_each = toset(var.emptydir_volumes) + content { + empty_dir { + size_limit = volume.value.parameters.size_limit + } + name = volume.value.name + } + } } } } diff --git a/terraform/modules/happy-service-eks/variables.tf b/terraform/modules/happy-service-eks/variables.tf index 5cf9b426e7..e55e2537cf 100644 --- a/terraform/modules/happy-service-eks/variables.tf +++ b/terraform/modules/happy-service-eks/variables.tf @@ -258,6 +258,17 @@ variable "additional_volumes_from_config_maps" { description = "Additional volumes to add to the container from the following config maps" } +variable "emptydir_volumes" { + type = list(object({ + name : string, + parameters : object({ + size_limit : optional(string, "500mi"), + }) + })) + default = [] + description = "define any emptyDir volumes to make available to the pod" +} + variable "progress_deadline_seconds" { type = number description = "The maximum time in seconds for a deployment to make progress before it is considered to be failed. Defaults to 600 seconds." diff --git a/terraform/modules/happy-stack-eks/README.md b/terraform/modules/happy-stack-eks/README.md index 5206b94f91..1f85cdee04 100644 --- a/terraform/modules/happy-stack-eks/README.md +++ b/terraform/modules/happy-stack-eks/README.md @@ -52,6 +52,7 @@ | [app\_name](#input\_app\_name) | The happy application name | `string` | `""` | no | | [create\_dashboard](#input\_create\_dashboard) | Create a dashboard for this stack | `bool` | `false` | no | | [deployment\_stage](#input\_deployment\_stage) | Deployment stage for the app | `string` | n/a | yes | +| [emptydir\_volumes](#input\_emptydir\_volumes) | define any emptyDir volumes to make available to the pod |
name : string,
parameters : object({
size_limit : optional(string, "500mi"),
})
}))
list(object({| `[]` | no | | [enable\_service\_mesh](#input\_enable\_service\_mesh) | Enable service mesh for this stack | `bool` | `false` | no | | [image\_tag](#input\_image\_tag) | Please provide a default image tag | `string` | n/a | yes | | [image\_tags](#input\_image\_tags) | Override image tag for each docker image | `map(string)` | `{}` | no | diff --git a/terraform/modules/happy-stack-eks/main.tf b/terraform/modules/happy-stack-eks/main.tf index 66429e04dc..38b307fb3b 100644 --- a/terraform/modules/happy-stack-eks/main.tf +++ b/terraform/modules/happy-stack-eks/main.tf @@ -228,6 +228,8 @@ module "services" { additional_volumes_from_config_maps = var.additional_volumes_from_config_maps additional_pod_labels = var.additional_pod_labels + emptydir_volumes = var.emptydir_volumes + tags = local.secret["tags"] regional_wafv2_arn = local.regional_waf_arn diff --git a/terraform/modules/happy-stack-eks/variables.tf b/terraform/modules/happy-stack-eks/variables.tf index bd5fc14a04..9d242e1517 100644 --- a/terraform/modules/happy-stack-eks/variables.tf +++ b/terraform/modules/happy-stack-eks/variables.tf @@ -275,6 +275,17 @@ variable "additional_env_vars_from_secrets" { description = "Additional environment variables to add to the container from the following secrets" } +variable "emptydir_volumes" { + type = list(object({ + name : string, + parameters : object({ + size_limit : optional(string, "500mi"), + }) + })) + default = [] + description = "define any emptyDir volumes to make available to the pod" +} + variable "additional_volumes_from_secrets" { type = object({ items : optional(list(string), []),
name : string,
parameters : object({
size_limit : optional(string, "500mi"),
})
}))