Skip to content

Commit

Permalink
feat: add variable to set resources with default values
Browse files Browse the repository at this point in the history
Having default values is good practice to prevent that our components could eventually starve other workloads on the cluster. However, these should probably be adapted in production clusters and are only a safeguard in case someone forgets to set them.
  • Loading branch information
lentidas committed Apr 3, 2024
1 parent 1d50079 commit bd46ce8
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
10 changes: 10 additions & 0 deletions locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ locals {
"eks.amazonaws.com/role-arn" = var.iam_role_arn != null ? var.iam_role_arn : module.iam_assumable_role_ebs.iam_role_arn
}
}
resources = {
requests = { for k, v in var.resources.controller.requests : k => v if v != null }
limits = { for k, v in var.resources.controller.limits : k => v if v != null }
}
}
node = {
resources = {
requests = { for k, v in var.resources.node.requests : k => v if v != null }
limits = { for k, v in var.resources.node.limits : k => v if v != null }
}
}
}
}]
Expand Down
35 changes: 34 additions & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,40 @@ variable "dependency_ids" {
## Module variables
#######################

variable "resources" {
description = <<-EOT
Resource limits and requests for aws-ebs-csi-driver's components. Follow the style on https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/[official documentation] to understand the format of the values."
NOTE: These are the same values as the defaults on the Helm chart aws-ebs-csi-driver.
EOT
type = object({

controller = optional(object({
requests = optional(object({
cpu = optional(string, "10m")
memory = optional(string, "40Mi")
}), {})
limits = optional(object({
cpu = optional(string)
memory = optional(string, "256Mi")
}), {})
}), {})

node = optional(object({
requests = optional(object({
cpu = optional(string, "10m")
memory = optional(string, "40Mi")
}), {})
limits = optional(object({
cpu = optional(string)
memory = optional(string, "256Mi")
}), {})
}), {})

})
default = {}
}

variable "create_role" {
description = "Boolean to indicate that the OIDC assumable IAM role should be created. **If passing `iam_role_arn` this should be false, otherwise if you want to create the OIDC assumable IAM role provided by this module, you will need to specify the variable `cluster_oidc_issuer_url`.**"
type = bool
Expand All @@ -78,4 +112,3 @@ variable "cluster_oidc_issuer_url" {
type = string
default = "" # Use empty string instead of null because of the replace() that uses this variable.
}

0 comments on commit bd46ce8

Please sign in to comment.