-
Notifications
You must be signed in to change notification settings - Fork 1
/
limits.tf
51 lines (44 loc) · 1.29 KB
/
limits.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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 {
name = module.label.id
namespace = kubernetes_namespace.namespace.metadata.0.name
}
spec {
limit {
type = "PersistentVolumeClaim"
default = local.storage_amount_default
max = {
storage = var.max_storage
}
}
limit {
type = "Container"
default = merge(local.container_cpu_default, local.container_memory_default)
max = {
cpu = var.max_cpu
memory = var.max_memory
}
}
}
}
resource "kubernetes_resource_quota" "limits" {
metadata {
name = module.label.id
namespace = kubernetes_namespace.namespace.metadata.0.name
}
spec {
hard = {
"pods" = var.max_pods
"persistentvolumeclaims" = var.max_pv_claims
"count/jobs.batch" = var.max_jobs
"count/deployments.apps" = var.max_deployments
"count/services.loadbalancers" = var.max_load_balancers
"count/services.nodeports" = var.max_node_ports
}
}
}