Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional node pools submodule #267

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions modules/node-pools/data.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
data "azurerm_kubernetes_cluster" "main" {
name = var.cluster_name
resource_group_name = var.resource_group_name
}
37 changes: 37 additions & 0 deletions modules/node-pools/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
resource "azurerm_kubernetes_cluster_node_pool" "workers" {
for_each = var.additional_node_pools

name = each.value["name"]
kubernetes_cluster_id = data.azurerm_kubernetes_cluster.main.id
vm_size = each.value["vm_size"]

enable_auto_scaling = lookup(each.value, "enable_auto_scaling", false)
enable_host_encryption = lookup(each.value, "enable_host_encryption", false)
enable_node_public_ip = lookup(each.value, "enable_node_public_ip", false)
eviction_policy = lookup(each.value, "priority", "Regular") == "Spot" ? lookup(each.value, "eviction_policy", "Delete") : null
fips_enabled = lookup(each.value, "fips_enabled", false)
kubelet_disk_type = lookup(each.value, "kubelet_disk_type", null)
max_pods = lookup(each.value, "max_pods", null)
mode = lookup(each.value, "mode", "User")
node_labels = lookup(each.value, "node_labels", null)
node_public_ip_prefix_id = lookup(each.value, "enable_node_public_ip", false) == true ? lookup(each.value, "node_public_ip_prefix_id", null) : null
node_taints = lookup(each.value, "node_taints", [])
orchestrator_version = lookup(each.value, "orchestrator_version", null)
os_disk_size_gb = lookup(each.value, "os_disk_size_gb", null)
os_disk_type = lookup(each.value, "os_disk_type", "Managed")
pod_subnet_id = lookup(each.value, "pod_subnet_id", null)
os_sku = lookup(each.value, "os_sku", "Ubuntu")
os_type = lookup(each.value, "os_type", "Linux")
priority = lookup(each.value, "priority", "Regular")
proximity_placement_group_id = lookup(each.value, "proximity_placement_group_id", null)
spot_max_price = lookup(each.value, "spot_max_price", -1)
tags = merge(var.tags, lookup(each.value, "tags", {}))
scale_down_mode = lookup(each.value, "priority", "Regular") == "Regular" ? lookup(each.value, "scale_down_mode", "Delete") : "Delete"
ultra_ssd_enabled = lookup(each.value, "ultra_ssd_enabled", false)
vnet_subnet_id = var.vnet_subnet_id
workload_runtime = lookup(each.value, "workload_runtime", "OCIContainer")
zones = lookup(each.value, "zones", [])
max_count = lookup(each.value, "enable_auto_scaling", false) == true ? lookup(each.value, "max_count", null) : null
min_count = lookup(each.value, "enable_auto_scaling", false) == true ? lookup(each.value, "min_count", null) : null
node_count = lookup(each.value, "node_count", 0)
}
Empty file added modules/node-pools/outputs.tf
Empty file.
15 changes: 15 additions & 0 deletions modules/node-pools/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
variable "resource_group_name" {
type = string
description = "The resource group name to be imported"
}

variable "cluster_name" {
type = string
description = "The name for the AKS cluster"
}

variable "additional_node_pools" {
description = "Specify a map of node pools where key - the name if the pool, value - the object which represents the parameters for pool`s configuration. Dy default nothing will be createdy"
type = map(any)
default = {}
}
14 changes: 14 additions & 0 deletions modules/node-pools/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
terraform {
required_version = ">= 1.2"

required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = ">= 3.21"
}
tls = {
source = "hashicorp/tls"
version = ">= 3.1"
}
}
}