Skip to content

Commit

Permalink
Add Node Labels
Browse files Browse the repository at this point in the history
  • Loading branch information
zioproto committed Sep 11, 2024
1 parent 6cd415a commit 09711c4
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,14 @@ Type: `string`

Default: `null`

### <a name="input_node_labels"></a> [node\_labels](#input\_node\_labels)

Description: (Optional) A map of Kubernetes labels which should be applied to nodes in this Node Pool.

Type: `map(string)`

Default: `{}`

### <a name="input_node_pools"></a> [node\_pools](#input\_node\_pools)

Description: A map of node pools that need to be created and attached on the Kubernetes cluster. The key of the map can be the name of the node pool, and the key must be static string. The value of the map is a `node_pool` block as defined below:
Expand All @@ -193,6 +201,7 @@ map(object({
mode = (Optional) Should this Node Pool be used for System or User resources? Possible values are `System` and `User`. Defaults to `User`.
os\_disk\_size\_gb = (Optional) The Agent Operating System disk size in GB. Changing this forces a new resource to be created.
tags = (Optional) A mapping of tags to assign to the resource. At this time there's a bug in the AKS API where Tags for a Node Pool are not stored in the correct case - you [may wish to use Terraform's `ignore_changes` functionality to ignore changes to the casing](https://www.terraform.io/language/meta-arguments/lifecycle#ignore_changess) until this is fixed in the AKS API.
labels = (Optional) A map of Kubernetes labels which should be applied to nodes in this Node Pool.
zones = (Optional) Specifies a list of Availability Zones in which this Kubernetes Cluster Node Pool should be located. Changing this forces a new Kubernetes Cluster Node Pool to be created.
}))

Expand Down Expand Up @@ -234,6 +243,7 @@ map(object({
mode = optional(string)
os_disk_size_gb = optional(number, null)
tags = optional(map(string), {})
labels = optional(map(string), {})
zones = optional(set(string))
}))
```
Expand Down
1 change: 1 addition & 0 deletions locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ locals {
orchestrator_version = pool.orchestrator_version
max_count = pool.max_count
min_count = pool.min_count
labels = pool.labels
os_sku = pool.os_sku
zone = zone
}
Expand Down
3 changes: 3 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ resource "azurerm_kubernetes_cluster" "this" {
max_count = 9
max_pods = 110
min_count = 3
node_labels = var.node_labels
orchestrator_version = var.orchestrator_version
os_sku = "Ubuntu"
tags = merge(var.tags, var.agents_tags)
Expand All @@ -76,6 +77,7 @@ resource "azurerm_kubernetes_cluster" "this" {
## Resources that only support UserAssigned
dynamic "identity" {
for_each = local.managed_identities.user_assigned

content {
type = identity.value.type
identity_ids = identity.value.user_assigned_resource_ids
Expand Down Expand Up @@ -236,6 +238,7 @@ resource "azurerm_kubernetes_cluster_node_pool" "this" {
enable_auto_scaling = true
max_count = each.value.max_count
min_count = each.value.min_count
node_labels = each.value.labels
orchestrator_version = each.value.orchestrator_version
os_sku = each.value.os_sku
tags = var.tags
Expand Down
8 changes: 8 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ variable "node_cidr" {
description = "(Optional) The CIDR to use for node IPs in the Kubernetes cluster. Changing this forces a new resource to be created."
}

variable "node_labels" {
type = map(string)
default = {}
description = "(Optional) A map of Kubernetes labels which should be applied to nodes in this Node Pool."
}

variable "node_pools" {
type = map(object({
name = string
Expand All @@ -111,6 +117,7 @@ variable "node_pools" {
mode = optional(string)
os_disk_size_gb = optional(number, null)
tags = optional(map(string), {})
labels = optional(map(string), {})
zones = optional(set(string))
}))
default = {}
Expand All @@ -126,6 +133,7 @@ map(object({
mode = (Optional) Should this Node Pool be used for System or User resources? Possible values are `System` and `User`. Defaults to `User`.
os_disk_size_gb = (Optional) The Agent Operating System disk size in GB. Changing this forces a new resource to be created.
tags = (Optional) A mapping of tags to assign to the resource. At this time there's a bug in the AKS API where Tags for a Node Pool are not stored in the correct case - you [may wish to use Terraform's `ignore_changes` functionality to ignore changes to the casing](https://www.terraform.io/language/meta-arguments/lifecycle#ignore_changess) until this is fixed in the AKS API.
labels = (Optional) A map of Kubernetes labels which should be applied to nodes in this Node Pool.
zones = (Optional) Specifies a list of Availability Zones in which this Kubernetes Cluster Node Pool should be located. Changing this forces a new Kubernetes Cluster Node Pool to be created.
}))
Expand Down

0 comments on commit 09711c4

Please sign in to comment.