Skip to content

Commit

Permalink
feat: Add enable_microsoft_defender/upgrade_max_surge variables for a…
Browse files Browse the repository at this point in the history
…z-aks tf module
  • Loading branch information
using-system committed Apr 1, 2024
1 parent 4d1422c commit be4d07b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
11 changes: 10 additions & 1 deletion terraform/modules/az-aks/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ resource "azurerm_kubernetes_cluster" "aks" {
temporary_name_for_rotation = var.configuration.node_pool.temporary_name_for_rotation
enable_host_encryption = true
only_critical_addons_enabled = var.configuration.node_pool.only_critical_addons_enabled

upgrade_settings {
max_surge = var.configuration.node_pool.upgrade_max_surge
}
}

identity {
Expand All @@ -46,7 +50,12 @@ resource "azurerm_kubernetes_cluster" "aks" {
oms_agent {
log_analytics_workspace_id = var.log_analytics_id
}

dynamic "microsoft_defender" {
for_each = var.configuration.enable_microsoft_defender == false ? [] : ["microsoft_defender"]
content {
log_analytics_workspace_id = var.log_analytics_id
}
}
dynamic "key_management_service" {
for_each = var.configuration.kv_key_management_service_id == null ? [] : ["key_management_service"]

Expand Down
4 changes: 2 additions & 2 deletions terraform/modules/az-aks/tests/cluster_creation.tftest.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ run "plan" {
name = "az-aks-cluster"
configuration = {
version = "1.28.5"
sku = "Free"
sku = "Standard"
private_cluster = true
user_assigned_identity_id = run.setup.assigned_identity_id
local_account_disabled = true
Expand Down Expand Up @@ -100,7 +100,7 @@ run "apply" {
name = "az-aks-cluster"
configuration = {
version = "1.28.5"
sku = "Free"
sku = "Standard"
private_cluster = true
user_assigned_identity_id = run.setup.assigned_identity_id
local_account_disabled = true
Expand Down
2 changes: 2 additions & 0 deletions terraform/modules/az-aks/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ variable "configuration" {
public_ssh_key = optional(string)
automatic_channel_upgrade = optional(string)
kv_key_management_service_id = optional(string)
enable_microsoft_defender = optional(bool, true)
node_pool = object({
type = string
count = number
Expand All @@ -32,6 +33,7 @@ variable "configuration" {
max_pods = optional(number, 110)
temporary_name_for_rotation = optional(string)
only_critical_addons_enabled = optional(bool, true)
upgrade_max_surge = optional(string, "10%")
})
rbac = object({
enabled = bool
Expand Down

0 comments on commit be4d07b

Please sign in to comment.