Skip to content

Commit

Permalink
do not set defaults when max value is set to 0
Browse files Browse the repository at this point in the history
  • Loading branch information
etwillbefine committed Aug 1, 2020
1 parent 640cd18 commit ee4075b
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions limits.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
locals {
container_cpu_default = var.max_cpu == 0 ? {} : { cpu = "50m" }
container_memory_default = var.max_memory == 0 ? {} : { memory = "64Mi" }
storage_amount_default = var.max_storage == 0 ? {} : { storage = "2Gi" }
}

resource "kubernetes_limit_range" "limits" {
metadata {
Expand All @@ -7,24 +12,17 @@ resource "kubernetes_limit_range" "limits" {

spec {
limit {
type = "PersistentVolumeClaim"

default = {
storage = "2Gi"
}
type = "PersistentVolumeClaim"
default = local.storage_amount_default

max = {
storage = var.max_storage
}
}

limit {
type = "Container"

default = {
cpu = "50m"
memory = "64Mi"
}
type = "Container"
default = merge(local.container_cpu_default, local.container_memory_default)

max = {
cpu = var.max_cpu
Expand Down

0 comments on commit ee4075b

Please sign in to comment.