feature: variabilize replicas number for deployment
This commit is contained in:
parent
3c62528dd4
commit
ce557fe8f2
6
input.tf
6
input.tf
@ -53,3 +53,9 @@ variable "volumes" {
|
|||||||
)
|
)
|
||||||
default = {}
|
default = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "replicas" {
|
||||||
|
type = number
|
||||||
|
default = 1
|
||||||
|
description = "number of replicas for the application's pod"
|
||||||
|
}
|
2
main.tf
2
main.tf
@ -43,7 +43,7 @@ resource "kubernetes_deployment_v1" "deployment" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
spec {
|
spec {
|
||||||
replicas = "1"
|
replicas = var.replicas
|
||||||
selector {
|
selector {
|
||||||
match_labels = {
|
match_labels = {
|
||||||
"app.kubernetes.io/name" = local.label_name
|
"app.kubernetes.io/name" = local.label_name
|
||||||
|
@ -7,6 +7,7 @@ run "terraform-plan" {
|
|||||||
image = {
|
image = {
|
||||||
name = "container.localdomain/test-image"
|
name = "container.localdomain/test-image"
|
||||||
}
|
}
|
||||||
|
replicas = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
assert {
|
assert {
|
||||||
@ -15,7 +16,7 @@ run "terraform-plan" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
assert {
|
assert {
|
||||||
condition = kubernetes_deployment_v1.deployment.spec[0].replicas == "1"
|
condition = kubernetes_deployment_v1.deployment.spec[0].replicas == "2"
|
||||||
error_message = "invalid number of replicas"
|
error_message = "invalid number of replicas"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user