Skip to content

Commit

Permalink
Fix legacy oms settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin-DynamicD committed Sep 25, 2023
1 parent ebfdf22 commit 1950af8
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 16 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ node_user_pool = {
node_count = 2
os_disk_size_gb = 120
os_disk_type = "Ephemeral"
os_type = "Linux"
priority = "Regular"
spot_max_price = -1
vm_size = "Standard_D4ds_v5"
Expand All @@ -173,6 +174,7 @@ node_user_pool = {
| node_taints | list | no | [][^1] | add taints to the nodes |
| os_disk_size_gb | number | no | 120 | size of node disks in GB |
| os_disk_type | string | no | "Ephemeral" | type of disk |
| os_type | string | no | "Linux" | the type of OS to run. As of this writing, supported types are "Windows" "Linux" |
| priority | string | no | "Regular" | the type of nodes |
| spot_max_price | number | no | -1 | used with spot instances, set a price limit on server cost, -1 means no limit |
| vm_size | string | no | "Standard_D4ds_v5" | set the node type |
Expand Down
1 change: 1 addition & 0 deletions aks.tf
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ resource "azurerm_kubernetes_cluster_node_pool" "user" {
node_taints = local.node_user_pool_merged.node_taints
os_disk_size_gb = local.node_user_pool.os_disk_size_gb
os_disk_type = local.node_user_pool.os_disk_type
os_type = local.node_user_pool.os_type
priority = local.node_user_pool.priority
eviction_policy = local.node_user_pool.priority == "Spot" ? local.node_user_pool.eviction_policy : null
spot_max_price = local.node_user_pool.priority == "Spot" ? local.node_user_pool.spot_max_price : null
Expand Down
38 changes: 23 additions & 15 deletions diagnostics.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,12 @@ resource "azurerm_monitor_diagnostic_setting" "aks" {
for_each = local.oms.aks_logs
content {
category = enabled_log.key
retention_policy {
enabled = enabled_log.value
days = local.oms.retention_days
}
}
}

metric {
category = "AllMetrics"
enabled = local.oms.aks_metrics
retention_policy {
enabled = local.oms.aks_metrics
days = local.oms.retention_days
}
}
}

Expand All @@ -39,19 +31,35 @@ resource "azurerm_monitor_diagnostic_setting" "agw" {
for_each = local.oms.agw_logs
content {
category = enabled_log.key
retention_policy {
enabled = enabled_log.value
days = local.oms.retention_days
}
}
}

metric {
category = "AllMetrics"
enabled = local.oms.agw_metrics
retention_policy {
enabled = local.oms.agw_metrics
days = local.oms.retention_days
}
}

resource "random_string" "policySuffix" {
length = 8
special = false
upper = false
}

resource "azurerm_storage_management_policy" "main" {
count = local.oms.enabled == true ? 1 : 0
storage_account_id = local.oms.storage_account_id

rule {
name = "aks_basseline-${random_string.policySuffix.result}"
enabled = true
filters {
blob_types = ["appendBlob"]
}
actions {
base_blob {
delete_after_days_since_modification_greater_than = local.oms.retention_days
}
}
}
}
1 change: 1 addition & 0 deletions test/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ module "aks" {
node_user_pool = {
min_count = 1
node_count = 1
os_type = "Linux"
}
oms = {
enabled = true
Expand Down
1 change: 1 addition & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ variable "node_user_pool" {
node_count = optional(number, 2)
node_labels = optional(map(any), {}) # needs defaults as we merge it later
node_taints = optional(list(string), []) # needs defaults as we concat it later
os_type = optional(string, "Linux")
os_disk_size_gb = optional(number, 120)
os_disk_type = optional(string, "Ephemeral")
priority = optional(string, "Regular")
Expand Down
2 changes: 1 addition & 1 deletion versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
terraform {
required_version = ">= 1.4.0"
required_providers {
azurerm = ">= 3.32.0"
azurerm = ">= 3.74.0"
random = ">= 3.4.0"
}
}

0 comments on commit 1950af8

Please sign in to comment.