Skip to content

Commit

Permalink
Merge pull request #21 from goci-io/psp
Browse files Browse the repository at this point in the history
fix: do not set defaults when max value is set to 0
  • Loading branch information
etwillbefine authored Aug 1, 2020
2 parents 640cd18 + ee4075b commit 74f951a
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 74f951a

Please sign in to comment.