Skip to content

Commit 746d455

Browse files
author
Vincent Illiano
committed
Merge pull request #390 from simon-z22:simon_modifications
2 parents 05e3df9 + b57e768 commit 746d455

File tree

6 files changed

+41
-1
lines changed

6 files changed

+41
-1
lines changed

main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ module "aks" {
135135
aks_cluster_dns_prefix = "${var.prefix}-aks"
136136
aks_cluster_sku_tier = var.aks_cluster_sku_tier
137137
aks_cluster_location = var.location
138+
node_resource_group_name = var.node_resource_group_name != "" ? var.node_resource_group_name : "MC_${local.aks_rg.name}_${var.prefix}-aks_${var.location}"
138139
cluster_support_tier = var.cluster_support_tier
139140
fips_enabled = var.fips_enabled
140141
aks_cluster_node_auto_scaling = var.default_nodepool_min_nodes == var.default_nodepool_max_nodes ? false : true
@@ -212,6 +213,7 @@ module "node_pools" {
212213
orchestrator_version = var.kubernetes_version
213214
host_encryption_enabled = var.aks_cluster_enable_host_encryption
214215
tags = var.tags
216+
linux_os_config = each.value.linux_os_config
215217
}
216218

217219
# https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/postgresql_flexible_server

modules/aks_node_pool/main.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ resource "azurerm_kubernetes_cluster_node_pool" "autoscale_node_pool" {
2929
lifecycle {
3030
ignore_changes = [node_count]
3131
}
32+
33+
linux_os_config {
34+
sysctl_config {
35+
vm_max_map_count = try(var.linux_os_config.sysctl_config.vm_max_map_count,null)
36+
}
37+
}
3238
}
3339

3440
resource "azurerm_kubernetes_cluster_node_pool" "static_node_pool" {
@@ -52,4 +58,10 @@ resource "azurerm_kubernetes_cluster_node_pool" "static_node_pool" {
5258
node_taints = var.node_taints
5359
orchestrator_version = var.orchestrator_version
5460
tags = var.tags
61+
62+
linux_os_config {
63+
sysctl_config {
64+
vm_max_map_count = try(var.linux_os_config.sysctl_config.vm_max_map_count,null)
65+
}
66+
}
5567
}

modules/aks_node_pool/variables.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,13 @@ variable "proximity_placement_group_id" {
115115
type = string
116116
default = ""
117117
}
118+
119+
variable "linux_os_config"{
120+
description = "Specifications of linux os config. Changing this forces a new resource to be created."
121+
type = object({
122+
sysctl_config = optional(object({
123+
vm_max_map_count = optional(number)
124+
}))
125+
})
126+
default = {}
127+
}

modules/azure_aks/main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ resource "azurerm_kubernetes_cluster" "aks" {
66
name = var.aks_cluster_name
77
location = var.aks_cluster_location
88
resource_group_name = var.aks_cluster_rg
9+
node_resource_group = var.node_resource_group_name != "" ? var.node_resource_group_name : "MC_${var.aks_cluster_rg}_${var.aks_cluster_name}_${var.aks_cluster_location}"
910
dns_prefix = var.aks_private_cluster == false || var.aks_cluster_private_dns_zone_id == "" ? var.aks_cluster_dns_prefix : null
1011
dns_prefix_private_cluster = var.aks_private_cluster && var.aks_cluster_private_dns_zone_id != "" ? var.aks_cluster_dns_prefix : null
1112

@@ -138,7 +139,7 @@ data "azurerm_public_ip" "cluster_public_ip" {
138139

139140
# effective_outbound_ips is a set of strings, that needs to be converted to a list type
140141
name = split("/", tolist(azurerm_kubernetes_cluster.aks.network_profile[0].load_balancer_profile[0].effective_outbound_ips)[0])[8]
141-
resource_group_name = "MC_${var.aks_cluster_rg}_${var.aks_cluster_name}_${var.aks_cluster_location}"
142+
resource_group_name = var.node_resource_group_name != "" ? var.node_resource_group_name : "MC_${var.aks_cluster_rg}_${var.aks_cluster_name}_${var.aks_cluster_location}"
142143

143144
depends_on = [azurerm_kubernetes_cluster.aks]
144145
}

modules/azure_aks/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,3 +259,8 @@ variable "aks_cluster_run_command_enabled" {
259259
type = bool
260260
default = false
261261
}
262+
263+
variable "node_resource_group_name" {
264+
type = string
265+
default = ""
266+
}

variables.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,11 @@ variable "node_pools" {
556556
max_pods = string
557557
node_taints = list(string)
558558
node_labels = map(string)
559+
linux_os_config = optional(object({
560+
sysctl_config = optional(object({
561+
vm_max_map_count = optional(number)
562+
}))
563+
}))
559564
}))
560565

561566
default = {
@@ -808,3 +813,8 @@ variable "aks_cluster_run_command_enabled" {
808813
type = bool
809814
default = false
810815
}
816+
817+
variable "node_resource_group_name" {
818+
type = string
819+
default = ""
820+
}

0 commit comments

Comments
 (0)