From 5515edba18f7b67bc79f2b5167c5ea26b9b2771b Mon Sep 17 00:00:00 2001 From: Carus Kyle Date: Thu, 25 Apr 2024 11:10:39 +0100 Subject: [PATCH] feat: Add OS and Kubelet disk type options. OS Disk type can be either Managed or Temporary. Kubelet Disk type can be either OS or Ephemeral. The default behaviour for the option, and when not set, is to use Managed and OS for the OS and Kubelet respectively. When set to Temporary and Ephemeral the local temporary storage will be used if available on the node. Signed-off-by: Carus Kyle --- main.tf | 20 ++++++++++---------- modules/aks_node_pool/main.tf | 11 ++++++----- modules/aks_node_pool/variables.tf | 17 +++++++++++------ variables.tf | 16 +++++++++------- 4 files changed, 36 insertions(+), 28 deletions(-) diff --git a/main.tf b/main.tf index 37825c4c..aef46e0c 100644 --- a/main.tf +++ b/main.tf @@ -8,12 +8,12 @@ # provider "azurerm" { - subscription_id = var.subscription_id - client_id = var.client_id - client_secret = var.client_secret - tenant_id = var.tenant_id - partner_id = var.partner_id - use_msi = var.use_msi + subscription_id = var.subscription_id + client_id = var.client_id + client_secret = var.client_secret + tenant_id = var.tenant_id + partner_id = var.partner_id + use_msi = var.use_msi features {} } @@ -197,8 +197,8 @@ module "node_pools" { machine_type = each.value.machine_type fips_enabled = var.fips_enabled os_disk_size = each.value.os_disk_size - # TODO: enable with azurerm v2.37.0 - # os_disk_type = each.value.os_disk_type + os_disk_type = each.value.os_disk_type + kubelet_disk_type = each.value.kubelet_disk_type enable_auto_scaling = each.value.min_nodes == each.value.max_nodes ? false : true node_count = each.value.min_nodes min_nodes = each.value.min_nodes == each.value.max_nodes ? null : each.value.min_nodes @@ -271,11 +271,11 @@ module "message_broker" { } data "external" "git_hash" { - program = ["files/tools/iac_git_info.sh"] + program = ["${path.module}/files/tools/iac_git_info.sh"] } data "external" "iac_tooling_version" { - program = ["files/tools/iac_tooling_version.sh"] + program = ["${path.module}/files/tools/iac_tooling_version.sh"] } resource "kubernetes_config_map" "sas_iac_buildinfo" { diff --git a/modules/aks_node_pool/main.tf b/modules/aks_node_pool/main.tf index 500cd98e..a9cdd077 100755 --- a/modules/aks_node_pool/main.tf +++ b/modules/aks_node_pool/main.tf @@ -14,10 +14,10 @@ resource "azurerm_kubernetes_cluster_node_pool" "autoscale_node_pool" { proximity_placement_group_id = var.proximity_placement_group_id == "" ? null : var.proximity_placement_group_id vm_size = var.machine_type os_disk_size_gb = var.os_disk_size - # TODO: enable after azurerm v2.37.0 - # os_disk_type = var.os_disk_type - os_type = var.os_type - enable_auto_scaling = var.enable_auto_scaling + os_disk_type = var.os_disk_type + kubelet_disk_type = var.kubelet_disk_type + os_type = var.os_type == null ? null : var.os_type + enable_auto_scaling = var.enable_auto_scaling # Still in preview, revisit if needed later - https://docs.microsoft.com/en-us/azure/aks/use-multiple-node-pools#assign-a-public-ip-per-node-for-your-node-pools-preview # enable_node_public_ip = var.enable_node_public_ip node_count = var.node_count @@ -46,7 +46,8 @@ resource "azurerm_kubernetes_cluster_node_pool" "static_node_pool" { vm_size = var.machine_type os_disk_size_gb = var.os_disk_size # TODO: enable after azurerm v2.37.0 - # os_disk_type = var.os_disk_type + os_disk_type = var.os_disk_type + kubelet_disk_type = var.kubelet_disk_type os_type = var.os_type enable_auto_scaling = var.enable_auto_scaling node_count = var.node_count diff --git a/modules/aks_node_pool/variables.tf b/modules/aks_node_pool/variables.tf index e3981b8c..76856e5a 100755 --- a/modules/aks_node_pool/variables.tf +++ b/modules/aks_node_pool/variables.tf @@ -46,12 +46,17 @@ variable "os_disk_size" { default = 100 } -# TODO: enable after azurerm v2.37.0 -# variable "os_disk_type" { -# description = "The type of disk which should be used for the Operating System. Possible values are Ephemeral and Managed. Defaults to Managed. Changing this forces a new resource to be created" -# type = string -# default = "Managed" -# } +variable "os_disk_type" { + description = "(Optional) The type of disk which should be used for the Operating System. Possible values are Ephemeral and Managed. Changing this forces a new resource to be created" + type = string + default = null +} + +variable "kubelet_disk_type" { + description = "(Optional) The type of disk which should be used for the Kubelet. Possible values are OS (Where the OS Disk Type is then used) and Temporary. Defaults to Managed. Changing this forces a new resource to be created" + type = string + default = null +} variable "os_type" { description = "The Operating System which should be used for this Node Pool. Changing this forces a new resource to be created. Possible values are Linux and Windows. Defaults to Linux" diff --git a/variables.tf b/variables.tf index dfbc8e17..b13c2a05 100644 --- a/variables.tf +++ b/variables.tf @@ -542,13 +542,15 @@ variable "node_pools_proximity_placement" { variable "node_pools" { description = "Node pool definitions" type = map(object({ - machine_type = string - os_disk_size = number - min_nodes = string - max_nodes = string - max_pods = string - node_taints = list(string) - node_labels = map(string) + machine_type = string + os_disk_size = number + kubelet_disk_type = optional(string) + os_disk_type = optional(string) + min_nodes = string + max_nodes = string + max_pods = string + node_taints = list(string) + node_labels = map(string) })) default = {