feature: variabilize replicas number for deployment

This commit is contained in:
RouxAntoine 2024-05-29 23:23:41 +02:00
parent 3c62528dd4
commit ce557fe8f2
Signed by: antoine
GPG Key ID: 098FB66FC0475E70
3 changed files with 9 additions and 2 deletions

View File

@ -53,3 +53,9 @@ variable "volumes" {
)
default = {}
}
variable "replicas" {
type = number
default = 1
description = "number of replicas for the application's pod"
}

View File

@ -43,7 +43,7 @@ resource "kubernetes_deployment_v1" "deployment" {
}
}
spec {
replicas = "1"
replicas = var.replicas
selector {
match_labels = {
"app.kubernetes.io/name" = local.label_name

View File

@ -7,6 +7,7 @@ run "terraform-plan" {
image = {
name = "container.localdomain/test-image"
}
replicas = 2
}
assert {
@ -15,7 +16,7 @@ run "terraform-plan" {
}
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"
}
}