feat: Add autoscaling_group_tags variable to self-managed-node-groups (#2084)

Co-authored-by: Bryant Biggs <bryantbiggs@gmail.com>
This commit is contained in:
Gabriel Féron
2022-06-02 14:26:49 +02:00
committed by GitHub
parent 8178010326
commit 8584dcb2e0
5 changed files with 26 additions and 2 deletions

View File

@@ -97,6 +97,12 @@ module "eks" {
self_managed_node_group_defaults = { self_managed_node_group_defaults = {
create_security_group = false create_security_group = false
# enable discovery of autoscaling groups by cluster-autoscaler
autoscaling_group_tags = {
"k8s.io/cluster-autoscaler/enabled" : true,
"k8s.io/cluster-autoscaler/${local.name}" : "owned",
}
} }
self_managed_node_groups = { self_managed_node_groups = {

View File

@@ -77,6 +77,7 @@ module "self_managed_node_group" {
| Name | Description | Type | Default | Required | | Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:| |------|-------------|------|---------|:--------:|
| <a name="input_ami_id"></a> [ami\_id](#input\_ami\_id) | The AMI from which to launch the instance | `string` | `""` | no | | <a name="input_ami_id"></a> [ami\_id](#input\_ami\_id) | The AMI from which to launch the instance | `string` | `""` | no |
| <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 |
| <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 | | <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 |
| <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 | | <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 |
| <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 | | <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 |

View File

@@ -400,6 +400,16 @@ resource "aws_autoscaling_group" "this" {
} }
} }
dynamic "tag" {
for_each = var.autoscaling_group_tags
content {
key = tag.key
value = tag.value
propagate_at_launch = false
}
}
timeouts { timeouts {
delete = var.delete_timeout delete = var.delete_timeout
} }

View File

@@ -464,6 +464,12 @@ variable "use_default_tags" {
default = false default = false
} }
variable "autoscaling_group_tags" {
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"
type = map(string)
default = {}
}
################################################################################ ################################################################################
# Autoscaling group schedule # Autoscaling group schedule
################################################################################ ################################################################################

View File

@@ -387,8 +387,9 @@ module "self_managed_node_group" {
create_schedule = try(each.value.create_schedule, var.self_managed_node_group_defaults.create_schedule, false) create_schedule = try(each.value.create_schedule, var.self_managed_node_group_defaults.create_schedule, false)
schedules = try(each.value.schedules, var.self_managed_node_group_defaults.schedules, null) schedules = try(each.value.schedules, var.self_managed_node_group_defaults.schedules, null)
delete_timeout = try(each.value.delete_timeout, var.self_managed_node_group_defaults.delete_timeout, null) delete_timeout = try(each.value.delete_timeout, var.self_managed_node_group_defaults.delete_timeout, null)
use_default_tags = try(each.value.use_default_tags, var.self_managed_node_group_defaults.use_default_tags, false) use_default_tags = try(each.value.use_default_tags, var.self_managed_node_group_defaults.use_default_tags, false)
autoscaling_group_tags = try(each.value.autoscaling_group_tags, var.self_managed_node_group_defaults.autoscaling_group_tags, {})
# User data # User data
platform = try(each.value.platform, var.self_managed_node_group_defaults.platform, "linux") platform = try(each.value.platform, var.self_managed_node_group_defaults.platform, "linux")