mirror of
https://github.com/ysoftdevs/terraform-aws-eks.git
synced 2026-01-15 00:04:07 +01:00
docs: Re-add 'Tags for the ASG to support cluster-autoscaler scale up from 0' example (#2494)
Co-authored-by: Bryant Biggs <bryantbiggs@gmail.com>
This commit is contained in:
@@ -53,6 +53,7 @@ Note that this example may create resources which cost money. Run `terraform des
|
||||
|
||||
| Name | Type |
|
||||
|------|------|
|
||||
| [aws_autoscaling_group_tag.cluster_autoscaler_label_tags](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/autoscaling_group_tag) | resource |
|
||||
| [aws_iam_policy.node_additional](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |
|
||||
| [aws_security_group.remote_access](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group) | resource |
|
||||
| [aws_ami.eks_default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ami) | data source |
|
||||
|
||||
@@ -462,3 +462,52 @@ data "aws_ami" "eks_default_bottlerocket" {
|
||||
values = ["bottlerocket-aws-k8s-${local.cluster_version}-x86_64-*"]
|
||||
}
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Tags for the ASG to support cluster-autoscaler scale up from 0
|
||||
################################################################################
|
||||
|
||||
locals {
|
||||
|
||||
# We need to lookup K8s taint effect from the AWS API value
|
||||
taint_effects = {
|
||||
NO_SCHEDULE = "NoSchedule"
|
||||
NO_EXECUTE = "NoExecute"
|
||||
PREFER_NO_SCHEDULE = "PreferNoSchedule"
|
||||
}
|
||||
|
||||
cluster_autoscaler_label_tags = merge([
|
||||
for name, group in module.eks.eks_managed_node_groups : {
|
||||
for label_name, label_value in coalesce(group.node_group_labels, {}) : "${name}|label|${label_name}" => {
|
||||
autoscaling_group = group.node_group_autoscaling_group_names[0],
|
||||
key = "k8s.io/cluster-autoscaler/node-template/label/${label_name}",
|
||||
value = label_value,
|
||||
}
|
||||
}
|
||||
]...)
|
||||
|
||||
cluster_autoscaler_taint_tags = merge([
|
||||
for name, group in module.eks.eks_managed_node_groups : {
|
||||
for taint in coalesce(group.node_group_taints, []) : "${name}|taint|${taint.key}" => {
|
||||
autoscaling_group = group.node_group_autoscaling_group_names[0],
|
||||
key = "k8s.io/cluster-autoscaler/node-template/taint/${taint.key}"
|
||||
value = "${taint.value}:${local.taint_effects[taint.effect]}"
|
||||
}
|
||||
}
|
||||
]...)
|
||||
|
||||
cluster_autoscaler_asg_tags = merge(local.cluster_autoscaler_label_tags, local.cluster_autoscaler_taint_tags)
|
||||
}
|
||||
|
||||
resource "aws_autoscaling_group_tag" "cluster_autoscaler_label_tags" {
|
||||
for_each = local.cluster_autoscaler_asg_tags
|
||||
|
||||
autoscaling_group_name = each.value.autoscaling_group
|
||||
|
||||
tag {
|
||||
key = each.value.key
|
||||
value = each.value.value
|
||||
|
||||
propagate_at_launch = false
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user