Skip to content

Commit 9b931bd

Browse files
authored
Merge pull request #79 from kbst/aksdefaultnodepool
Aksdefaultnodepool
2 parents c8044a1 + 07920b7 commit 9b931bd

File tree

5 files changed

+63
-33
lines changed

5 files changed

+63
-33
lines changed

azurerm/_modules/aks/main.tf

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,21 @@ resource "azurerm_kubernetes_cluster" "current" {
1212
enabled = true
1313
}
1414

15-
agent_pool_profile {
16-
name = var.agent_pool_profile_name
17-
count = var.agent_pool_profile_count
18-
vm_size = var.agent_pool_profile_vm_size
19-
os_type = var.agent_pool_profile_os_type
20-
os_disk_size_gb = var.agent_pool_profile_os_disk_size_gb
15+
default_node_pool {
16+
name = var.default_node_pool_name
17+
type = var.default_node_pool_type
18+
19+
enable_auto_scaling = var.default_node_pool_enable_auto_scaling
20+
21+
# set min and max count only if autoscaling is _enabled_
22+
min_count = var.default_node_pool_enable_auto_scaling ? var.default_node_pool_min_count : null
23+
max_count = var.default_node_pool_enable_auto_scaling ? var.default_node_pool_max_count : null
24+
25+
# set node count only if auto scaling is _disabled_
26+
node_count = var.default_node_pool_enable_auto_scaling ? null : var.default_node_pool_node_count
27+
28+
vm_size = var.default_node_pool_vm_size
29+
os_disk_size_gb = var.default_node_pool_os_disk_size_gb
2130
}
2231

2332
service_principal {
@@ -34,4 +43,3 @@ resource "azurerm_kubernetes_cluster" "current" {
3443

3544
tags = var.metadata_labels
3645
}
37-

azurerm/_modules/aks/variables.tf

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,33 +29,50 @@ variable "dns_prefix" {
2929
default = "api"
3030
}
3131

32-
variable "agent_pool_profile_name" {
32+
variable "default_node_pool_name" {
3333
type = string
34-
description = "Name of agent pool profile."
34+
description = "Name of default node pool."
3535
default = "default"
3636
}
3737

38-
variable "agent_pool_profile_count" {
38+
variable "default_node_pool_type" {
3939
type = string
40-
description = "Number of worker nodes"
40+
description = "Type of default node pool. Defaults to VirtualMachineScaleSets, use AvailabilitySet for backwards compatibility with older clusters."
41+
default = "VirtualMachineScaleSets"
42+
}
43+
44+
variable "default_node_pool_enable_auto_scaling" {
45+
type = bool
46+
description = "Wether to enable auto scaling for the default node pool. Defaults to true."
47+
default = true
48+
}
49+
50+
variable "default_node_pool_min_count" {
51+
type = string
52+
description = "Min number of worker nodes"
4153
default = "1"
4254
}
4355

44-
variable "agent_pool_profile_vm_size" {
56+
variable "default_node_pool_max_count" {
4557
type = string
46-
description = "VM size of worker nodes"
47-
default = "Standard_D1_v2"
58+
description = "Max number of worker nodes"
59+
default = "1"
4860
}
4961

50-
variable "agent_pool_profile_os_type" {
62+
variable "default_node_pool_node_count" {
5163
type = string
52-
description = "OS type of worker nodes"
53-
default = "Linux"
64+
description = "Static number of worker nodes"
65+
default = "1"
5466
}
5567

56-
variable "agent_pool_profile_os_disk_size_gb" {
68+
variable "default_node_pool_vm_size" {
69+
type = string
70+
description = "VM size of worker nodes"
71+
default = "Standard_D1_v2"
72+
}
73+
74+
variable "default_node_pool_os_disk_size_gb" {
5775
type = string
5876
description = "Disk size of worker nodes (in GB)"
5977
default = "30"
6078
}
61-

azurerm/cluster/configuration.tf

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@ locals {
1616

1717
dns_prefix = lookup(local.cfg, "dns_prefix", "api")
1818

19-
agent_pool_profile_name = lookup(local.cfg, "agent_pool_profile_name", "default")
19+
default_node_pool_name = lookup(local.cfg, "default_node_pool_name", "default")
20+
default_node_pool_type = lookup(local.cfg, "default_node_pool_type", "VirtualMachineScaleSets")
2021

21-
agent_pool_profile_count = lookup(local.cfg, "agent_pool_profile_count", "1")
22+
default_node_pool_enable_auto_scaling = lookup(local.cfg, "default_node_pool_enable_auto_scaling", true)
23+
default_node_pool_min_count = lookup(local.cfg, "default_node_pool_min_count", "1")
24+
default_node_pool_max_count = lookup(local.cfg, "default_node_pool_max_count", "1")
25+
default_node_pool_node_count = lookup(local.cfg, "default_node_pool_node_count", "1")
2226

23-
agent_pool_profile_vm_size = lookup(local.cfg, "agent_pool_profile_vm_size", "Standard_D1_v2")
27+
default_node_pool_vm_size = lookup(local.cfg, "default_node_pool_vm_size", "Standard_D1_v2")
2428

25-
agent_pool_profile_os_type = lookup(local.cfg, "agent_pool_profile_os_type", "Linux")
26-
27-
agent_pool_profile_os_disk_size_gb = lookup(local.cfg, "agent_pool_profile_os_disk_size_gb", "30")
29+
default_node_pool_os_disk_size_gb = lookup(local.cfg, "default_node_pool_os_disk_size_gb", "30")
2830
}
29-

azurerm/cluster/main.tf

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,14 @@ module "cluster" {
2727

2828
dns_prefix = local.dns_prefix
2929

30-
agent_pool_profile_name = local.agent_pool_profile_name
31-
agent_pool_profile_count = local.agent_pool_profile_count
32-
agent_pool_profile_vm_size = local.agent_pool_profile_vm_size
33-
agent_pool_profile_os_type = local.agent_pool_profile_os_type
34-
agent_pool_profile_os_disk_size_gb = local.agent_pool_profile_os_disk_size_gb
35-
}
30+
default_node_pool_name = local.default_node_pool_name
31+
default_node_pool_type = local.default_node_pool_type
32+
33+
default_node_pool_enable_auto_scaling = local.default_node_pool_enable_auto_scaling
34+
default_node_pool_min_count = local.default_node_pool_min_count
35+
default_node_pool_max_count = local.default_node_pool_max_count
36+
default_node_pool_node_count = local.default_node_pool_node_count
3637

38+
default_node_pool_vm_size = local.default_node_pool_vm_size
39+
default_node_pool_os_disk_size_gb = local.default_node_pool_os_disk_size_gb
40+
}

tests/config.auto.tfvars

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ clusters = {
2424
project_id = "terraform-kubestack-testing"
2525
name_prefix = "kbstacctest"
2626
base_domain = "infra.serverwolken.de"
27-
cluster_min_master_version = "1.13.11"
27+
cluster_min_master_version = "1.13"
2828
cluster_min_node_count = 1
2929
cluster_max_node_count = 1
3030
region = "europe-west1"

0 commit comments

Comments
 (0)