Skip to content

Commit 06c51ff

Browse files
kpshjkDennis Ploeger
authored andcommitted
feat: Automatic channel upgrade
Add option to enable automatic_channel_upgrade, not active by default. Define a configurable maintenance window for auto upgrades, if automatich channel upgrades are enabled
1 parent 0b5cbb5 commit 06c51ff

File tree

2 files changed

+59
-1
lines changed

2 files changed

+59
-1
lines changed

main.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
locals {
1111
cluster_name = "${lower(var.project)}${lower(var.stage)}k8s"
12+
has_automatic_channel_upgrade_maintenance_window = var.automatic_channel_upgrade != "none" ? [var.automatic_channel_upgrade] : []
1213
}
1314

1415
# Log analytics required for OMS Agent result processing - usually other logging solutions are used. Hence the affected tfsec rule is
@@ -27,6 +28,19 @@ resource "azurerm_kubernetes_cluster" "k8s" {
2728
sku_tier = var.sku_tier
2829
kubernetes_version = var.kubernetes_version
2930

31+
automatic_channel_upgrade = var.automatic_channel_upgrade != "none" ? var.automatic_channel_upgrade : null
32+
dynamic "maintenance_window_auto_upgrade" {
33+
for_each = local.has_automatic_channel_upgrade_maintenance_window
34+
content {
35+
frequency = "Weekly"
36+
interval = "1"
37+
duration = var.maintenance_window_auto_upgrade_duration
38+
day_of_week = var.maintenance_window_auto_upgrade_day_of_week
39+
start_time = var.maintenance_window_auto_upgrade_start_time
40+
utc_offset = var.maintenance_window_auto_upgrade_utc_offset
41+
}
42+
}
43+
3044
default_node_pool {
3145
name = var.default_node_pool_name
3246
type = "VirtualMachineScaleSets"

vars.tf

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,4 +190,48 @@ variable "azure_container_registry_ids" {
190190
description = <<-EOF
191191
IDs of the azure container registries that the AKS should have pull access to
192192
EOF
193-
}
193+
}
194+
195+
variable "automatic_channel_upgrade" {
196+
type = string
197+
default = "none"
198+
description = <<-EOF
199+
Values:
200+
none, patch, stable, rapid, node-image
201+
see https://learn.microsoft.com/en-us/azure/aks/auto-upgrade-cluster
202+
EOF
203+
}
204+
205+
variable "maintenance_window_auto_upgrade_day_of_week" {
206+
type = string
207+
default = "Monday"
208+
description = <<-EOF
209+
see https://learn.microsoft.com/en-us/azure/aks/planned-maintenance#creating-a-maintenance-window
210+
EOF
211+
}
212+
213+
variable "maintenance_window_auto_upgrade_duration" {
214+
type = string
215+
default = "4"
216+
description = <<-EOF
217+
see https://learn.microsoft.com/en-us/azure/aks/planned-maintenance#creating-a-maintenance-window
218+
EOF
219+
}
220+
221+
variable "maintenance_window_auto_upgrade_start_time" {
222+
type = string
223+
default = "04:00"
224+
description = <<-EOF
225+
Example: "04:00"
226+
see https://learn.microsoft.com/en-us/azure/aks/planned-maintenance#creating-a-maintenance-window
227+
EOF
228+
}
229+
230+
variable "maintenance_window_auto_upgrade_utc_offset" {
231+
type = string
232+
default = "+00:00"
233+
description = <<-EOF
234+
Example: "+00:00"
235+
see https://learn.microsoft.com/en-us/azure/aks/planned-maintenance#creating-a-maintenance-window
236+
EOF
237+
}

0 commit comments

Comments
 (0)