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

Worker group tags #252

Merged
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ project adheres to [Semantic Versioning](http://semver.org/).
##### Added

- Ability to configure force_delete for the worker group ASG (by @stefansedich)
- Ability to configure worker group ASG tags (by @stefansedich)

##### Changed

Expand Down
18 changes: 18 additions & 0 deletions examples/eks_test_fixture/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,24 @@ locals {
# },
# ]


# the commented out worker group tags below shows an example of how to define
# custom tags for the worker groups ASG
# worker_group_tags = [
# [
# {
# key = "k8s.io/cluster-autoscaler/node-template/taint/nvidia.com/gpu"
# value = "gpu:NoSchedule"
# },
# ],
# [
# {
# key = "k8s.io/cluster-autoscaler/node-template/taint/nvidia.com/gpu"
# value = "gpu:NoSchedule"
# },
# ],
# ]

worker_groups = [
{
# This will launch an autoscaling group with only On-Demand instances
Expand Down
14 changes: 14 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ variable "workers_group_defaults" {
default = {}
}

variable "worker_group_tags" {
description = "A list of lists containing maps defining extra tags to be applied to the worker group ASG."
type = "list"

default = [[]]
}

variable "worker_groups_launch_template" {
description = "A list of maps defining worker group configurations to be defined using AWS Launch Templates. See workers_group_defaults for valid keys."
type = "list"
Expand All @@ -124,6 +131,13 @@ variable "workers_group_launch_template_defaults" {
default = {}
}

variable "worker_group_launch_template_tags" {
description = "A list of lists containing maps defining extra tags to be applied to the worker group template ASG."
type = "list"

default = [[]]
}

variable "worker_security_group_id" {
description = "If provided, all workers will be attached to this security group. If not given, a security group will be created with necessary ingres/egress to work with the EKS cluster."
default = ""
Expand Down
3 changes: 2 additions & 1 deletion workers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ resource "aws_autoscaling_group" "workers" {
map("key", "kubernetes.io/cluster/${aws_eks_cluster.this.name}", "value", "owned", "propagate_at_launch", true),
map("key", "k8s.io/cluster-autoscaler/${lookup(var.worker_groups[count.index], "autoscaling_enabled", local.workers_group_defaults["autoscaling_enabled"]) == 1 ? "enabled" : "disabled" }", "value", "true", "propagate_at_launch", false)
),
local.asg_tags)
local.asg_tags,
list(var.worker_group_tags[length(var.worker_group_tags) > count.index ? count.index : "0"]))
}"]

lifecycle {
Expand Down
3 changes: 2 additions & 1 deletion workers_launch_template.tf
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ resource "aws_autoscaling_group" "workers_launch_template" {
map("key", "kubernetes.io/cluster/${aws_eks_cluster.this.name}", "value", "owned", "propagate_at_launch", true),
map("key", "k8s.io/cluster-autoscaler/${lookup(var.worker_groups_launch_template[count.index], "autoscaling_enabled", local.workers_group_launch_template_defaults["autoscaling_enabled"]) == 1 ? "enabled" : "disabled" }", "value", "true", "propagate_at_launch", false)
),
local.asg_tags)
local.asg_tags,
list(var.worker_group_launch_template_tags[length(var.worker_group_launch_template_tags) > count.index ? count.index : "0"]))
}"]

lifecycle {
Expand Down