Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [CCIE-2375] ephemeral volume support #2977

Merged
merged 16 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions terraform/modules/happy-service-eks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
| <a name="input_deployment_stage"></a> [deployment\_stage](#input\_deployment\_stage) | The name of the deployment stage of the Application | `string` | `"dev"` | no |
| <a name="input_desired_count"></a> [desired\_count](#input\_desired\_count) | How many instances of this task should we run across our cluster? | `number` | `2` | no |
| <a name="input_eks_cluster"></a> [eks\_cluster](#input\_eks\_cluster) | eks-cluster module output | <pre>object({<br> cluster_id : string,<br> cluster_arn : string,<br> cluster_endpoint : string,<br> cluster_ca : string,<br> cluster_oidc_issuer_url : string,<br> cluster_version : string,<br> worker_iam_role_name : string,<br> worker_security_group : string,<br> oidc_provider_arn : string,<br> })</pre> | n/a | yes |
| <a name="input_emptydir_volumes"></a> [emptydir\_volumes](#input\_emptydir\_volumes) | define any emptyDir volumes to make available to the pod | <pre>list(object({<br> name : string,<br> parameters : object({<br> size_limit : optional(string, "500mi"),<br> })<br> }))</pre> | `[]` | no |
| <a name="input_gpu"></a> [gpu](#input\_gpu) | Number of GPUs per pod, 0 allocates all available GPUs | `number` | `null` | no |
| <a name="input_gpu_requests"></a> [gpu\_requests](#input\_gpu\_requests) | Number of GPUs requested per pod, 0 allocates all available GPUs | `number` | `null` | no |
| <a name="input_health_check_path"></a> [health\_check\_path](#input\_health\_check\_path) | path to use for health checks | `string` | `"/"` | no |
Expand Down
43 changes: 38 additions & 5 deletions terraform/modules/happy-service-eks/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,15 @@ resource "kubernetes_deployment_v1" "deployment" {
}
}

dynamic "volume_mount" {
for_each = toset(var.emptydir_volumes)
content {
# TODO FIXME do we want the mount path to be configurable????
mount_path = "/var/${volume_mount.value.name}"
name = volume_mount.value.name
}
}

liveness_probe {
http_get {
path = var.health_check_path
Expand Down Expand Up @@ -381,7 +390,14 @@ resource "kubernetes_deployment_v1" "deployment" {
}
}
}

dynamic "volume_mount" {
for_each = toset(var.emptydir_volumes)
content {
# TODO FIXME do we want the mount path to be configurable????
mount_path = "/var/${volume_mount.value.name}"
name = volume_mount.value.name
}
}
dynamic "env" {
for_each = var.additional_env_vars
content {
Expand Down Expand Up @@ -458,7 +474,14 @@ resource "kubernetes_deployment_v1" "deployment" {
read_only = true
}
}

dynamic "volume_mount" {
for_each = toset(var.emptydir_volumes)
content {
# TODO FIXME do we want the mount path to be configurable????
rzlim08 marked this conversation as resolved.
Show resolved Hide resolved
mount_path = "/var/${volume_mount.value.name}"
name = volume_mount.value.name
}
}
env {
name = "DEPLOYMENT_STAGE"
value = var.deployment_stage
Expand Down Expand Up @@ -535,14 +558,24 @@ resource "kubernetes_deployment_v1" "deployment" {
}

dynamic "volume" {
for_each = toset(var.additional_volumes_from_config_maps.items)
for_each = toset(var.additional_volumes_from_secrets.items)
rzlim08 marked this conversation as resolved.
Show resolved Hide resolved
content {
config_map {
name = volume.value
secret {
secret_name = volume.value
}
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
}
}
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions terraform/modules/happy-service-eks/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,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."
Expand Down
1 change: 1 addition & 0 deletions terraform/modules/happy-stack-eks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
| <a name="input_app_name"></a> [app\_name](#input\_app\_name) | The happy application name | `string` | `""` | no |
| <a name="input_create_dashboard"></a> [create\_dashboard](#input\_create\_dashboard) | Create a dashboard for this stack | `bool` | `false` | no |
| <a name="input_deployment_stage"></a> [deployment\_stage](#input\_deployment\_stage) | Deployment stage for the app | `string` | n/a | yes |
| <a name="input_emptydir_volumes"></a> [emptydir\_volumes](#input\_emptydir\_volumes) | define any emptyDir volumes to make available to the pod | <pre>list(object({<br> name : string,<br> parameters : object({<br> size_limit : optional(string, "500mi"),<br> })<br> }))</pre> | `[]` | no |
| <a name="input_enable_service_mesh"></a> [enable\_service\_mesh](#input\_enable\_service\_mesh) | Enable service mesh for this stack | `bool` | `false` | no |
| <a name="input_image_tag"></a> [image\_tag](#input\_image\_tag) | Please provide a default image tag | `string` | n/a | yes |
| <a name="input_image_tags"></a> [image\_tags](#input\_image\_tags) | Override image tag for each docker image | `map(string)` | `{}` | no |
Expand Down
3 changes: 3 additions & 0 deletions terraform/modules/happy-stack-eks/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,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
Expand Down Expand Up @@ -256,5 +258,6 @@ module "tasks" {
additional_env_vars_from_secrets = var.additional_env_vars_from_secrets
additional_volumes_from_secrets = var.additional_volumes_from_secrets
additional_volumes_from_config_maps = var.additional_volumes_from_config_maps

}

11 changes: 11 additions & 0 deletions terraform/modules/happy-stack-eks/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,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), []),
Expand Down
Loading