File tree 4 files changed +32
-2
lines changed
4 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,10 @@ module "aks" {
48
48
rbac_aad_admin_group_object_ids = [data.azuread_group.aks_cluster_admins.id]
49
49
rbac_aad_managed = true
50
50
private_cluster_enabled = true # default value
51
+ enable_auto_scaling = true
52
+ agents_min_count = 1
53
+ agents_max_count = 2
54
+ agents_count = null # Please set `agents_count` `null` while `enable_auto_scaling` is `true` to avoid possible `agents_count` changes.
51
55
52
56
depends_on = [module.network]
53
57
}
Original file line number Diff line number Diff line change @@ -31,6 +31,9 @@ resource "azurerm_kubernetes_cluster" "main" {
31
31
vm_size = var. agents_size
32
32
os_disk_size_gb = var. os_disk_size_gb
33
33
vnet_subnet_id = var. vnet_subnet_id
34
+ enable_auto_scaling = var. enable_auto_scaling
35
+ max_count = var. enable_auto_scaling ? var. agents_max_count : null
36
+ min_count = var. enable_auto_scaling ? var. agents_min_count : null
34
37
}
35
38
36
39
dynamic "service_principal" {
Original file line number Diff line number Diff line change @@ -40,7 +40,12 @@ module "aks" {
40
40
sku_tier = " Paid"
41
41
enable_kube_dashboard = true
42
42
private_cluster_enabled = true
43
- depends_on = [azurerm_resource_group . main ]
43
+ enable_auto_scaling = true
44
+ agents_min_count = 1
45
+ agents_max_count = 2
46
+ agents_count = null
47
+
48
+ depends_on = [azurerm_resource_group . main ]
44
49
}
45
50
46
51
module "aks_without_monitor" {
Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ variable "log_retention_in_days" {
45
45
}
46
46
47
47
variable "agents_count" {
48
- description = " The number of Agents that should exist in the Agent Pool"
48
+ description = " The number of Agents that should exist in the Agent Pool. Please set `agents_count` `null` while `enable_auto_scaling` is `true` to avoid possible `agents_count` changes. "
49
49
type = number
50
50
default = 2
51
51
}
@@ -163,3 +163,21 @@ variable "orchestrator_version" {
163
163
type = string
164
164
default = null
165
165
}
166
+
167
+ variable "enable_auto_scaling" {
168
+ description = " Enable node pool autoscaling"
169
+ type = bool
170
+ default = false
171
+ }
172
+
173
+ variable "agents_max_count" {
174
+ type = number
175
+ description = " Maximum number of nodes in a pool"
176
+ default = null
177
+ }
178
+
179
+ variable "agents_min_count" {
180
+ type = number
181
+ description = " Minimum number of nodes in a pool"
182
+ default = null
183
+ }
You can’t perform that action at this time.
0 commit comments