Skip to content

Commit 191f4a5

Browse files
committed
EKS: Allow setting additional tags and labels for node pools
1 parent 6c11d9c commit 191f4a5

File tree

6 files changed

+35
-2
lines changed

6 files changed

+35
-2
lines changed

aws/_modules/eks/node_pool/main.tf

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ resource "aws_eks_node_group" "nodes" {
1313
instance_types = var.instance_types
1414
disk_size = var.disk_size
1515

16-
tags = var.eks_metadata_tags
17-
labels = var.metadata_labels
16+
tags = merge(var.tags, var.eks_metadata_tags)
17+
labels = merge(var.labels, var.metadata_labels)
1818

1919
dynamic "taint" {
2020
for_each = var.taints

aws/_modules/eks/node_pool/variables.tf

+12
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,15 @@ variable "taints" {
6767
}))
6868
description = "Kubernetes taints to set for node pool."
6969
}
70+
71+
variable "tags" {
72+
type = map(string)
73+
description = "AWS tags to set on the node pool. Merged with Kubestack default tags."
74+
default = {}
75+
}
76+
77+
variable "labels" {
78+
type = map(string)
79+
description = "Kubernetes labels to set on the nodes created by the node pool. Merged with Kubestack default labels."
80+
default = {}
81+
}

aws/cluster/node-pool/configuration.tf

+4
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,8 @@ locals {
2828
vpc_subnet_map_public_ip = lookup(local.cfg, "vpc_subnet_map_public_ip", null)
2929

3030
taints = local.cfg["taints"] == null ? toset([]) : local.cfg["taints"]
31+
32+
tags = local.cfg["tags"]
33+
34+
labels = local.cfg["labels"]
3135
}

aws/cluster/node-pool/main.tf

+4
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,9 @@ module "node_pool" {
1919

2020
taints = local.taints
2121

22+
tags = local.tags
23+
24+
labels = local.labels
25+
2226
depends-on-aws-auth = null
2327
}

aws/cluster/node-pool/variables.tf

+4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ variable "configuration" {
2828
value = string
2929
effect = string
3030
})))
31+
32+
tags = optional(map(string))
33+
34+
labels = optional(map(string))
3135
}))
3236
description = "Map with per workspace module configuration."
3337
}

tests/eks_zero_node_pools.tf

+9
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ module "eks_zero_node_pool_existing_subnets" {
1616
desired_capacity = 1
1717
min_size = 1
1818
max_size = 3
19+
20+
tags = {
21+
"k8s.io/cluster-autoscaler/node-template/label/nvidia.com/gpu" = true
22+
"k8s.io/cluster-autoscaler/node-template/taint/dedicated" = "nvidia.com/gpu=true"
23+
}
24+
25+
labels = {
26+
"kubestack.com/test" = true
27+
}
1928
}
2029

2130
# Settings for Ops-cluster

0 commit comments

Comments
 (0)