-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathscaledobject.tf
36 lines (34 loc) · 1 KB
/
scaledobject.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
resource "kubernetes_manifest" "scaledobject_cron" {
for_each = {
for runner_name, runner_config in var.bitbucket_runners : runner_name => runner_config
if lookup(runner_config, "cron_scaling_enabled", false)
}
manifest = {
"apiVersion" = "keda.sh/v1alpha1"
"kind" = "ScaledObject"
"metadata" = {
"name" = "bitbucket-${each.key}"
"namespace" = var.k8s_namespace
}
"spec" = {
"scaleTargetRef" = {
"name" = "bitbucket-${each.key}"
"apiVersion" = "apps/v1"
"kind" = "StatefulSet"
}
"minReplicaCount" = 0
"maxReplicaCount" = 1
"triggers" = [
for trigger in lookup(each.value, "triggers", []) : {
"type" = "cron"
"metadata" = {
"start" = trigger.start
"end" = trigger.end
"timezone" = trigger.timezone
"desiredReplicas" = tostring(trigger.desiredReplicas)
}
}
]
}
}
}