-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathhpa.tf
51 lines (45 loc) · 1.21 KB
/
hpa.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
resource "kubernetes_horizontal_pod_autoscaler" "hpa" {
for_each = lookup(var.hpa, "enabled", false) == true ? { "hpa" = "true" } : {}
metadata {
name = var.name
namespace = var.namespace
labels = {
app = var.name
}
}
spec {
max_replicas = lookup(var.hpa, "max_replicas", 6)
min_replicas = lookup(var.hpa, "min_replicas", 2)
scale_target_ref {
api_version = "apps/v2beta2"
kind = "Deployment"
name = var.name
}
dynamic "metric" {
for_each = lookup(var.hpa, "target_cpu", "") != "" ? { "cpu" = "true" } : {}
content {
type = "Resource"
resource {
name = "cpu"
target {
type = "Utilization"
average_utilization = lookup(var.hpa, "target_cpu", 100)
}
}
}
}
dynamic "metric" {
for_each = lookup(var.hpa, "target_memory", "") != "" ? { "memory" = "true" } : {}
content {
type = "Resource"
resource {
name = "memory"
target {
type = "Utilization"
average_utilization = lookup(var.hpa, "target_memory", 100)
}
}
}
}
}
}