Skip to content

Commit 2fdcd65

Browse files
committed
DTOSS-11646: Setup Container Apps container probes
We need to configure a container probe (liveness/readiness) for our Azure Container Apps deployment. By default, the web application should only have a heath probe if the variable probe_path is set. If probe_path is null then it's disabled. Please note that we cannot do this for the Postgres DB container as there is no Django / restful interface to implement.
1 parent 6144dfb commit 2fdcd65

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

infrastructure/modules/container-app/main.tf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,20 @@ resource "azurerm_container_app" "main" {
103103
secret_name = lower(env.value.name)
104104
}
105105
}
106+
107+
dynamic "liveness_probe" {
108+
for_each = local.probe_enabled ? [1] : []
109+
110+
content {
111+
transport = "HTTP"
112+
path = var.probe_path
113+
port = local.effective_liveness_port
114+
initial_delay = 45
115+
interval_seconds = 10
116+
timeout = 2
117+
failure_count_threshold = 4
118+
}
119+
}
106120
}
107121
min_replicas = var.min_replicas
108122
}
@@ -145,6 +159,7 @@ resource "azurerm_container_app" "main" {
145159
}
146160
}
147161
}
162+
148163
}
149164

150165
# Enable Microsoft Entra ID authentication if specified

infrastructure/modules/container-app/variables.tf

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ variable "exposed_port" {
9393
default = null
9494
}
9595

96+
variable "liveness_probe_port" {
97+
description = "Port for the liveness probe to check. Default is var.port."
98+
type = number
99+
default = null
100+
}
101+
96102
variable "memory" {
97103
description = "Memory allocated to the app (GiB). Also dictates the CPU allocation: CPU(%)=MEMORY(Gi)/2. Maximum: 4Gi"
98104
default = "0.5"
@@ -190,6 +196,12 @@ variable "replica_restart_alert_threshold" {
190196
default = 1
191197
}
192198

199+
variable "probe_path" {
200+
description = "Path for the liveness probe. If null, liveness probe is disabled."
201+
type = string
202+
default = null
203+
}
204+
193205
locals {
194206
memory = "${var.memory}Gi"
195207
cpu = var.memory / 2
@@ -202,5 +214,7 @@ locals {
202214
PT6H = "PT5M"
203215
PT12H = "PT5M"
204216
}
205-
alert_frequency = local.alert_frequency_map[var.alert_window_size]
217+
alert_frequency = local.alert_frequency_map[var.alert_window_size]
218+
probe_enabled = var.probe_path != null
219+
effective_liveness_port = var.liveness_probe_port != null ? var.liveness_probe_port : var.port
206220
}

infrastructure/modules/dashboard/variables.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ variable "tags" {
2424
}
2525

2626
variable "dashboard_properties" {
27-
type = string
28-
default = "{}"
27+
type = string
28+
default = "{}"
2929
description = "JSON data representing dashboard body. See above for details on how to obtain this from the Portal."
3030
}

0 commit comments

Comments
 (0)