Skip to content

Commit d26e08b

Browse files
committed
DTOSS-11646: Setup Container Apps container probes
We need to configure a container probe (liveness/readiness & startup) 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. Also update the terradocs on the container app module and update the README.md for instructions on how to deploy probes from the root module.
1 parent 31255bb commit d26e08b

File tree

7 files changed

+91
-10
lines changed

7 files changed

+91
-10
lines changed

infrastructure/modules/container-app/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,9 @@ module "container-app" {
122122
replica_restart_alert_threshold = 1 (already defaults to this)
123123
}
124124
```
125+
126+
## Container Probes
127+
128+
To enable container probs on webapps:
129+
- Set `probe_path = "/healthcheck"` (by convention).
130+
- Ensure the application accepts requests from `127.0.0.1` and `localhost` so the probe running inside the container can access the health endpoint.

infrastructure/modules/container-app/main.tf

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,32 @@ resource "azurerm_container_app" "main" {
103103
secret_name = lower(env.value.name)
104104
}
105105
}
106+
107+
dynamic "startup_probe" {
108+
for_each = local.probe_enabled ? [1] : []
109+
110+
content {
111+
transport = "HTTP"
112+
path = var.probe_path
113+
port = var.port
114+
interval_seconds = 5
115+
timeout = 2
116+
failure_count_threshold = 30
117+
}
118+
}
119+
120+
dynamic "liveness_probe" {
121+
for_each = local.probe_enabled ? [1] : []
122+
123+
content {
124+
transport = "HTTP"
125+
path = var.probe_path
126+
port = var.port
127+
interval_seconds = 5
128+
timeout = 2
129+
failure_count_threshold = 2
130+
}
131+
}
106132
}
107133
min_replicas = var.min_replicas
108134
}
@@ -145,6 +171,7 @@ resource "azurerm_container_app" "main" {
145171
}
146172
}
147173
}
174+
148175
}
149176

150177
# Enable Microsoft Entra ID authentication if specified

infrastructure/modules/container-app/tfdocs.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,14 @@ Type: `number`
210210

211211
Default: `8080`
212212

213+
### <a name="input_probe_path"></a> [probe\_path](#input\_probe\_path)
214+
215+
Description: Path for the HTTP health probe. If null, HTTP health probe is disabled. Note /healthcheck is the normal convention.
216+
217+
Type: `string`
218+
219+
Default: `null`
220+
213221
### <a name="input_replica_restart_alert_threshold"></a> [replica\_restart\_alert\_threshold](#input\_replica\_restart\_alert\_threshold)
214222

215223
Description: The replica restart alert threshold, default will be 1.

infrastructure/modules/container-app/variables.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,12 @@ variable "replica_restart_alert_threshold" {
190190
default = 1
191191
}
192192

193+
variable "probe_path" {
194+
description = "Path for the HTTP health probe. If null, HTTP health probe is disabled. Note /healthcheck is the normal convention."
195+
type = string
196+
default = null
197+
}
198+
193199
locals {
194200
memory = "${var.memory}Gi"
195201
cpu = var.memory / 2
@@ -203,4 +209,5 @@ locals {
203209
PT12H = "PT5M"
204210
}
205211
alert_frequency = local.alert_frequency_map[var.alert_window_size]
212+
probe_enabled = var.probe_path != null && var.is_web_app
206213
}

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
}

infrastructure/modules/sql-server/tfdocs.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,30 @@ Type: `string`
132132

133133
The following input variables are optional (have default values):
134134

135+
### <a name="input_action_group_id"></a> [action\_group\_id](#input\_action\_group\_id)
136+
137+
Description: ID of the action group to notify.
138+
139+
Type: `string`
140+
141+
Default: `null`
142+
143+
### <a name="input_alert_cpu_threshold"></a> [alert\_cpu\_threshold](#input\_alert\_cpu\_threshold)
144+
145+
Description: If alerting is enabled this will control what the cpu threshold will be, default will be 90.
146+
147+
Type: `number`
148+
149+
Default: `90`
150+
151+
### <a name="input_alert_window_size"></a> [alert\_window\_size](#input\_alert\_window\_size)
152+
153+
Description: The period of time that is used to monitor alert activity e.g. PT1M, PT5M, PT15M, PT30M, PT1H, PT6H, PT12H. The interval between checks is adjusted accordingly.
154+
155+
Type: `string`
156+
157+
Default: `"PT5M"`
158+
135159
### <a name="input_auditing_policy_retention_in_days"></a> [auditing\_policy\_retention\_in\_days](#input\_auditing\_policy\_retention\_in\_days)
136160

137161
Description: number of days for audit log policies
@@ -164,6 +188,14 @@ Type: `string`
164188

165189
Default: `"baseline"`
166190

191+
### <a name="input_enable_alerting"></a> [enable\_alerting](#input\_enable\_alerting)
192+
193+
Description: Whether monitoring and alerting is enabled for the Azure SQL Server.
194+
195+
Type: `bool`
196+
197+
Default: `false`
198+
167199
### <a name="input_firewall_rules"></a> [firewall\_rules](#input\_firewall\_rules)
168200

169201
Description: If the FW rule enabling Azure Services Passthrough should be deployed.
@@ -345,6 +377,7 @@ Description: The ID of the SQL Server.
345377

346378
The following resources are used by this module:
347379

380+
- [azurerm_monitor_metric_alert.cpu](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_metric_alert) (resource)
348381
- [azurerm_mssql_database.defaultdb](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/mssql_database) (resource)
349382
- [azurerm_mssql_database_extended_auditing_policy.database_auditing_policy](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/mssql_database_extended_auditing_policy) (resource)
350383
- [azurerm_mssql_firewall_rule.firewall_rule](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/mssql_firewall_rule) (resource)

infrastructure/modules/storage/tfdocs.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,14 @@ Type: `string`
8181

8282
The following input variables are optional (have default values):
8383

84+
### <a name="input_access_tier"></a> [access\_tier](#input\_access\_tier)
85+
86+
Description: Defines the access tier for BlobStorage, FileStorage and StorageV2 accounts. Valid options are Hot, Cool, Cold and Premium.
87+
88+
Type: `string`
89+
90+
Default: `"Hot"`
91+
8492
### <a name="input_account_replication_type"></a> [account\_replication\_type](#input\_account\_replication\_type)
8593

8694
Description: The type of replication to use for this Storage Account. Can be either LRS, GRS, RAGRS or ZRS.
@@ -97,14 +105,6 @@ Type: `string`
97105

98106
Default: `"Standard"`
99107

100-
### <a name="input_access_tier"></a> [access\_tier](#input\_access\_tier)
101-
102-
Description: Defines the access tier for BlobStorage, FileStorage and StorageV2 accounts. Valid options are Hot, Cool, Cold and Premium. Defaults to Hot.
103-
104-
Type: `string`
105-
106-
Default: `"Hot"`
107-
108108
### <a name="input_action_group_id"></a> [action\_group\_id](#input\_action\_group\_id)
109109

110110
Description: ID of the action group to notify.

0 commit comments

Comments
 (0)