-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Not able to tag autoscaling group created by EKS Managed Node Group #2448
Comments
this is a lifecycle issue - you cannot add this tag logic until the node groups exist. this is why the module does not offer this logic natively; it has to be added after the nodegroups are created |
@yasinlachiny you should be able to solve your issue if you where to not use "${tag.asg}-${tag.key}" as key replaced the unknown tag.asg with something node group name related. We do simple node group labels and node group taints propagation to the ASG's as tag and we made it work in this way. |
@wcarlsen |
The sha256 stuff is totally unnecessary and can be skipped though locals {
node_label_tag_prefix = "k8s.io/cluster-autoscaler/node-template/label/"
node_taint_tag_prefix = "k8s.io/cluster-autoscaler/node-template/taint/"
node_labels = flatten([for k, v in module.eks.eks_managed_node_groups : [
for l, w in v.node_group_labels : {
sha : sha256("${k}${l}")
name : v.node_group_autoscaling_group_names[0]
key : l
value : w
}
] if length(v.node_group_labels) > 0])
node_taints = flatten([for k, v in module.eks.eks_managed_node_groups : [
for l, w in v.node_group_taints : {
sha : sha256("${k}${w.key}")
name : v.node_group_autoscaling_group_names[0]
key : w.key
value : w.value
effect : w.effect
}
] if length(v.node_group_taints) > 0])
}
resource "aws_autoscaling_group_tag" "labels" {
for_each = {
for k, v in local.node_labels :
v.sha => v
}
autoscaling_group_name = each.value.name
tag {
key = "${local.node_label_tag_prefix}${each.value.key}"
propagate_at_launch = true
value = each.value.value
}
}
resource "aws_autoscaling_group_tag" "taints" {
for_each = {
for k, v in local.node_taints :
v.sha => v
}
autoscaling_group_name = each.value.name
tag {
key = "${local.node_taint_tag_prefix}${each.value.key}"
propagate_at_launch = true
value = "${each.value.value}:${each.value.effect}"
}
} |
@bryantbiggs I know above example is super specific for the cluster-autoscaler, but would the above approach make sense in some form to include for managed node groups. I would be happy to make an attempt, if you'd like? |
This has already been tried and exhausted - its not possible at the moment #1558 (comment) |
if you want tags on managed nodegroups, use the module as its defined with the custom launch template and the tags will be added correctly |
@bryantbiggs sorry for being a bit persistent, but did you notice how the key in the loop above is 100% predictable, because it uses a combination of node group name and label key instead of use an asg related key? Doesn't that make a difference? |
Nodegroup names are not a known entity, users can utilize the prefix option which is randomly generated by Terraform |
Sorry I meant the key in module.eks.eks_managed_node_groups which is known, since it is user defined. |
I mean, you are free to experiment and try out solutions but I fear we've already exhausted them. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Description
I have an issue like #2128. The provided document does not exist in the master branch and actually, it doesn't work.
I'm trying to add tag for ASG , it is working when all the resources are already created. but when I am trying to run it from scratch I am getting this error
and this is my code:
It's working well for the currently deployed node_group but for the new node group it throughs an error.
It may because of the well known issue of unknown values used in a for_each loop.
If your request is for a new feature, please use the
Feature request
template.Versions
I tested it with 18.29 and 19.6.0
Module version [Required]:
Terraform version:
Expected behavior
It's working fine for deployed node_group and I expected that it works fine for new node group
Actual behavior
I got an error
The text was updated successfully, but these errors were encountered: