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

[EKS] [Node Group]: Give EC2 instances a Name tag #781

Open
tobdub-snce opened this issue Mar 9, 2020 · 32 comments
Open

[EKS] [Node Group]: Give EC2 instances a Name tag #781

tobdub-snce opened this issue Mar 9, 2020 · 32 comments
Labels
EKS Managed Nodes EKS Managed Nodes EKS Amazon Elastic Kubernetes Service Proposed Community submitted issue

Comments

@tobdub-snce
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Tell us about your request
Add Name tag to EKS nodegroup instances, based on the node group name.

Which service(s) is this request for?
EKS node groups.

Tell us about the problem you're trying to solve. What are you trying to do, and why is it hard?
Give EKS EC2 node group instances a Name to make them easier to identify, similar to ECS instances.

Are you currently working around this issue?
Manually adding Name tag.

@tobdub-snce tobdub-snce added the Proposed Community submitted issue label Mar 9, 2020
@mikestef9 mikestef9 added the EKS Amazon Elastic Kubernetes Service label Apr 9, 2020
@webster-chainalysis
Copy link

In general we need our tags to propagate to all resources created by the EKS service as part of a managed node group.

@nodesocket
Copy link

I see that I can specify Tags for a node group, but it is static. I'd like to apply something like:

Screen Shot 2020-04-26 at 8 24 36 PM

Name: eks-stage-worker-${number}

Where ${number} represents the worker number.

@woz5999
Copy link

woz5999 commented May 7, 2020

It's extremely painful to see a huge list of unnamed ec2 instances when you're managing multiple node groups or multiple clusters and can't quickly discern which cluster/node group an instance belongs to.

@bhegazy
Copy link

bhegazy commented May 11, 2020

Yes as @webster-chainalysis mentioned currently the managed node group tags are not propagated to aws resources.
Not sure should we open a new issue or edit this issue to correctly propose propagating managed node groups tags to aws resources ?

@tobdub-snce
Copy link
Author

There is an issue for propagating all tags: #374

@bhegazy
Copy link

bhegazy commented May 11, 2020

Thanks @tobdub I did not see that 👍

@TBBle
Copy link

TBBle commented May 27, 2020

This is different from #374, as I would not expect the NodeGroup's 'Name' tag to propagate down to each EC2 instance, but a unique Name to be generated for each EC2 instance, probably based on the NodeGroup's 'Name' tag. Similar thinking to what hashicorp/terraform-provider-aws#12451 was looking for, I think.

@mikestef9 mikestef9 added the EKS Managed Nodes EKS Managed Nodes label Jun 11, 2020
@rwolfson
Copy link

Although it's not a perfect fix for the issue described here, the new launch template enhancement (#585) looks like it allows setting static tags for instances and volumes in an EKS managed node group. Caveats include that the tags are static per launch template (i.e., you would likely have a LT per node group or cluster), and it's possible that it's a heavy-handed approach for folks that don't need the rest of the LT knobs.

@sanpedroadrian28
Copy link

hello, has there been a fix on this case? it's really a pain to keep naming blank EC2 instances of the EKS node group even if they are being referenced on the tags section of the EC2.

@juan-caylent
Copy link

There is a workaround:
https://stackoverflow.com/questions/63328382/how-can-i-name-eks-worker-nodes-provisioned-with-terraform

But if you need to specify multiple node groups, not sure how to do it.

@acesir
Copy link

acesir commented Oct 16, 2020

As everyone else has clearly pointed out, using launch templates just to propagate the Name tag is pretty horrendous. Is there any news on resolving this issue?

@MichaelX99
Copy link

I'm not exactly sure which issue to put this on so I'll probably but it in a decent number of issues but not having propagating Tags to all EKS cluster resources effectively makes this entire service useless. If you can't tag your resources you can't separate out costs between different programs and therefore will never be allowed by a program manager and rightfully so. This needs to be fixed ASAP.

@rasheedromana97
Copy link

It's extremely painful to see a huge list of unnamed ec2 instances when you're managing multiple node groups or multiple clusters and can't quickly discern which cluster/node group an instance belongs to.

Is there any solution to this issue yet?

@rustlingwind
Copy link

One year past, it seems that no good solution yet ?

@SantiEich
Copy link

Any update?

@amitkarpe
Copy link

Any update?
This feature is very important for our DevOps team.

@casper-gh
Copy link

There is a workaround by using AWS CLI aws autoscaling create-or-update-tags

@TBBle
Copy link

TBBle commented Jun 23, 2021

How does a tag on the ASG put a name on the EC2 instances? Is there a special tag that will propagate and have some kind of template operation done?

@casper-gh
Copy link

@TBBle There's an option called "Propagate at Launch" when you add new tags to ASG.

@TBBle
Copy link

TBBle commented Jun 23, 2021

Won't that propagate the same name to each instance though? Simply adding a tag to the nodes in an instance group is already supported, see #608 (comment) and the docs, so you don't need to add a tag to the EKS-managed ASG and set it to propagate.

I had understood this issue to be requesting that each instance get a unique Name tag, e.g., #781 (comment)

@mohag
Copy link

mohag commented Jun 23, 2021

@TBBle The docs mention the launch templates, which does seem like an option (I can't seem to get the tagging set up from CloudFormation though - I haven't specifically tried to troubleshoot that though). It is possible to create Managed node groups without manually created launch templates as well though (and editing the automatically created one seems far from ideal) and those don't seem to have a way to control the tags on the instances (without messing with the ASG or laucnh template that EKS creates)

@TBBle
Copy link

TBBle commented Jun 24, 2021

I know eksctl uses CloudFormation and Launch Templates to apply tags to managed node group nodes, so it might be worth a trawl through their implementation if you're looking for inspiration.

At this point, an AWS person and the AWS docs have said that "tagging EC2 instances" is supported through the launch template, so if you're not satisfied with that, best to raise it as a feature request ticket here, probably giving the rationale as to why it's not sufficient or useable-enough. That's what #608 started as, but it's now focussed on tagging ASGs for their own sake, not for propagating to instances, so it'd just be confusing to post it there.

In the meantime, this ticket is still sitting here looking for a way to generate names for EC2 instances from their node-group name, a use-case not covered by any of the existing tickets or systems.

@svenkat89
Copy link

I know eksctl uses CloudFormation and Launch Templates to apply tags to managed node group nodes, so it might be worth a trawl through their implementation if you're looking for inspiration.

At this point, an AWS person and the AWS docs have said that "tagging EC2 instances" is supported through the launch template, so if you're not satisfied with that, best to raise it as a feature request ticket here, probably giving the rationale as to why it's not sufficient or useable-enough. That's what #608 started as, but it's now focussed on tagging ASGs for their own sake, not for propagating to instances, so it'd just be confusing to post it there.

In the meantime, this ticket is still sitting here looking for a way to generate names for EC2 instances from their node-group name, a use-case not covered by any of the existing tickets or systems.

Really eksctl does that? i dont see in the help eksctl create nodegroup , anything related to tags

@TBBle
Copy link

TBBle commented Sep 2, 2021

See nodeGroups.tags in the schema:

Applied to the Autoscaling Group and to the EC2 instances (unmanaged), Applied to the EKS Nodegroup resource and to the EC2 instances (managed)

It's also demonstrated in the "Launch Template support for Managed Nodegroups" and "Auto Scaling" documentation.

The tags configured there will be combined with the "all resources" tags, documented in "Getting Started" and metadata.tags in the config file.

For managed node groups the implementation is in func (m *ManagedNodeGroupResourceSet) makeLaunchTemplateData() and for unmanaged node groups, the implementation is in func newLaunchTemplateData(n *NodeGroupResourceSet).

Both are populating AWS::EC2::LaunchTemplate's TagSpecifications property.

@chandrapratapsingh08
Copy link

I created node-group using CloudFormation and added the tag specification in the launch template to populate the same tags on all node-group resources ASG create.

NodeLaunchTemplate:
Type: "AWS::EC2::LaunchTemplate"
Properties:
LaunchTemplateData:
ImageId: !Ref NodeImageId
KeyName: !Ref KeyName
SecurityGroupIds:
- !Ref NodeSecurityGroup
TagSpecifications:
- ResourceType: instance
Tags:
- Key: Name
Value: kumo-eks-apinode
- ResourceType: volume
Tags:
- Key: Name
Value: kumo-eks-apinode

@lfvillavicencio
Copy link

Amazon, plesase. Add an option for this. Is very ugly to see unnamed instances on EC2 pannel everytime my cluster autoscales

@OloBo-MSK
Copy link

Any news?

@lfvillavicencio
Copy link

Any news?

Yes! Just add a Tag in your autoscaling group with the Key Name and its value will be the name of the EC2 instances created when scaling!!

image

@celestialorb
Copy link

Any news?

Yes! Just add a Tag in your autoscaling group with the Key Name and its value will be the name of the EC2 instances created when scaling!!

image

That's still a manual step post creation of the EKS node group(s), it would be nice if the tags from the EKS node group resource would propagate its tags onto the tags of the ASG which would then propagate to the EC2 nodes themselves.

@TBBle
Copy link

TBBle commented Aug 26, 2022

If you just want to set constant tags per-nodegroup on the EC2 instances, you can set them now in the Launch Template, e.g. if using eksctl, see the links in #781 (comment).

it would be nice if the tags from the EKS node group resource would propagate its tags onto the tags of the ASG

Perhaps upvote #1541 which is somewhat for this, based on the first comment. The original request didn't talk about propagating tags from NodeGroup to ASG. There's #374 which is similar, but for propagating tags from the Cluster object down to all its contained/owned objects.

@atheiman
Copy link

atheiman commented Feb 24, 2023

We provision our EKS cluster using terraform-aws-eks-blueprints - this workaround is working for us for applying a Name tag. It uses a Terraform data source to grab the EKS node group Name tag and apply it as a propagating tag on the related autoscaling group. The same basic approach should work with any terraform approach for provisioning node groups.

module "eks_blueprints" {
  source = "github.com/aws-ia/terraform-aws-eks-blueprints?ref=v4.23.0"

  # ...

  managed_node_groups = {
    ng_a = {
      node_group_name = "ng-a"
      # ...
    }
  }
}

data "aws_eks_node_group" "ng_a" {
  cluster_name    = module.eks_blueprints.eks_cluster_id
  node_group_name = split(":", module.eks_blueprints.managed_node_groups[0].ng_a.managed_nodegroup_id[0])[1]
}

resource "aws_autoscaling_group_tag" "ng_a_Name" {
  autoscaling_group_name = data.aws_eks_node_group.ng_a.resources[0].autoscaling_groups[0].name

  tag {
    key                 = "Name"
    value               = data.aws_eks_node_group.ng_a.tags.Name
    propagate_at_launch = true
  }
}

@syednadeembe
Copy link

What a shame that such a basic thing is missing and no one seems to care

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
EKS Managed Nodes EKS Managed Nodes EKS Amazon Elastic Kubernetes Service Proposed Community submitted issue
Projects
None yet
Development

No branches or pull requests