Skip to content

Commit b80dbf4

Browse files
feat: Add autoscaling_group_tags variable to self-managed-node-groups (#2084)
Co-authored-by: Bryant Biggs <[email protected]>
1 parent ca95061 commit b80dbf4

File tree

5 files changed

+26
-2
lines changed

5 files changed

+26
-2
lines changed

examples/self_managed_node_group/main.tf

+6
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ module "eks" {
9797

9898
self_managed_node_group_defaults = {
9999
create_security_group = false
100+
101+
# enable discovery of autoscaling groups by cluster-autoscaler
102+
autoscaling_group_tags = {
103+
"k8s.io/cluster-autoscaler/enabled" : true,
104+
"k8s.io/cluster-autoscaler/${local.name}" : "owned",
105+
}
100106
}
101107

102108
self_managed_node_groups = {

modules/self-managed-node-group/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ module "self_managed_node_group" {
7777
| Name | Description | Type | Default | Required |
7878
|------|-------------|------|---------|:--------:|
7979
| <a name="input_ami_id"></a> [ami\_id](#input\_ami\_id) | The AMI from which to launch the instance | `string` | `""` | no |
80+
| <a name="input_autoscaling_group_tags"></a> [autoscaling\_group\_tags](#input\_autoscaling\_group\_tags) | A map of additional tags to add to the autoscaling group created. Tags are applied to the autoscaling group only and are NOT propagated to instances | `map(string)` | `{}` | no |
8081
| <a name="input_availability_zones"></a> [availability\_zones](#input\_availability\_zones) | A list of one or more availability zones for the group. Used for EC2-Classic and default subnets when not specified with `subnet_ids` argument. Conflicts with `subnet_ids` | `list(string)` | `null` | no |
8182
| <a name="input_block_device_mappings"></a> [block\_device\_mappings](#input\_block\_device\_mappings) | Specify volumes to attach to the instance besides the volumes specified by the AMI | `any` | `{}` | no |
8283
| <a name="input_bootstrap_extra_args"></a> [bootstrap\_extra\_args](#input\_bootstrap\_extra\_args) | Additional arguments passed to the bootstrap script. When `platform` = `bottlerocket`; these are additional [settings](https://github.com/bottlerocket-os/bottlerocket#settings) that are provided to the Bottlerocket user data | `string` | `""` | no |

modules/self-managed-node-group/main.tf

+10
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,16 @@ resource "aws_autoscaling_group" "this" {
400400
}
401401
}
402402

403+
dynamic "tag" {
404+
for_each = var.autoscaling_group_tags
405+
406+
content {
407+
key = tag.key
408+
value = tag.value
409+
propagate_at_launch = false
410+
}
411+
}
412+
403413
timeouts {
404414
delete = var.delete_timeout
405415
}

modules/self-managed-node-group/variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,12 @@ variable "use_default_tags" {
464464
default = false
465465
}
466466

467+
variable "autoscaling_group_tags" {
468+
description = "A map of additional tags to add to the autoscaling group created. Tags are applied to the autoscaling group only and are NOT propagated to instances"
469+
type = map(string)
470+
default = {}
471+
}
472+
467473
################################################################################
468474
# Autoscaling group schedule
469475
################################################################################

node_groups.tf

+3-2
Original file line numberDiff line numberDiff line change
@@ -387,8 +387,9 @@ module "self_managed_node_group" {
387387
create_schedule = try(each.value.create_schedule, var.self_managed_node_group_defaults.create_schedule, false)
388388
schedules = try(each.value.schedules, var.self_managed_node_group_defaults.schedules, null)
389389

390-
delete_timeout = try(each.value.delete_timeout, var.self_managed_node_group_defaults.delete_timeout, null)
391-
use_default_tags = try(each.value.use_default_tags, var.self_managed_node_group_defaults.use_default_tags, false)
390+
delete_timeout = try(each.value.delete_timeout, var.self_managed_node_group_defaults.delete_timeout, null)
391+
use_default_tags = try(each.value.use_default_tags, var.self_managed_node_group_defaults.use_default_tags, false)
392+
autoscaling_group_tags = try(each.value.autoscaling_group_tags, var.self_managed_node_group_defaults.autoscaling_group_tags, {})
392393

393394
# User data
394395
platform = try(each.value.platform, var.self_managed_node_group_defaults.platform, "linux")

0 commit comments

Comments
 (0)