Skip to content

Commit 8e41175

Browse files
lays147yupwei68
andauthored
Add support for nodepool autoscaling (Azure#75)
* Add nodepool autoscaling support Signed-off-by: Lays Rodrigues <lays.silva@sensedia.com> * Add test/fixture for autoscaling support Signed-off-by: Lays Rodrigues <lays.silva@sensedia.com> * Update README example usage Signed-off-by: Lays Rodrigues <lays.silva@sensedia.com> * Update variables.tf * Update variables.tf add description * Update README.md format * Update main.tf format * Update variables.tf * Update main.tf format * Update README.md format * Update variables.tf * Update README.md * Update main.tf * Update README.md Co-authored-by: Yuping Wei <56525716+yupwei68@users.noreply.github.com>
1 parent a9fa12b commit 8e41175

File tree

4 files changed

+32
-2
lines changed

4 files changed

+32
-2
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ module "aks" {
4848
rbac_aad_admin_group_object_ids = [data.azuread_group.aks_cluster_admins.id]
4949
rbac_aad_managed = true
5050
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.
5155
5256
depends_on = [module.network]
5357
}

main.tf

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ resource "azurerm_kubernetes_cluster" "main" {
3131
vm_size = var.agents_size
3232
os_disk_size_gb = var.os_disk_size_gb
3333
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
3437
}
3538

3639
dynamic "service_principal" {

test/fixture/main.tf

+6-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,12 @@ module "aks" {
4040
sku_tier = "Paid"
4141
enable_kube_dashboard = true
4242
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]
4449
}
4550

4651
module "aks_without_monitor" {

variables.tf

+19-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ variable "log_retention_in_days" {
4545
}
4646

4747
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."
4949
type = number
5050
default = 2
5151
}
@@ -163,3 +163,21 @@ variable "orchestrator_version" {
163163
type = string
164164
default = null
165165
}
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+
}

0 commit comments

Comments
 (0)