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

add Name tag to default launch template #529

Merged
merged 1 commit into from
Jul 23, 2021
Merged

Conversation

bwagner5
Copy link
Contributor

Issue, if available:
N/A

Description of changes:

  • Adds a Name tag to the default Karpenter Launch Template (this is the launch template hardcoded in Karpenter that is used when a user does not override the launch template). The Name tag in EC2 is a special tag that is used to fill the Name column of the EC2 Web Console.
  • If a user overrides the launch template, they can specify any Name tag they'd like on the EC2 instance Karpenter will create.

The name format is Karpenter/<Cluster-Name> I can't add the K8s Node Name since the name doesn't exist until after an instance is launched.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@@ -159,6 +159,10 @@ func (p *LaunchTemplateProvider) createLaunchTemplate(ctx context.Context, optio
TagSpecifications: []*ec2.LaunchTemplateTagSpecificationRequest{{
ResourceType: aws.String(ec2.ResourceTypeInstance),
Tags: []*ec2.Tag{
{
Key: aws.String("Name"),
Value: aws.String(fmt.Sprintf("Karpenter/%s", ptr.StringValue(options.Cluster.Name))),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this collide, since we have many LTs per cluster?

Copy link
Contributor Author

@bwagner5 bwagner5 Jul 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we can avoid collisions, maybe this should also have the provisioner as well, but it will still be the same name per instance per provisioner. It might be worse if two provisioners map to the same LT, which would seem to indicate that one of those provisioners is unneeded.

If we want to make these unique and use the actual node-name, then we'd need to call EC2 to add a tag after creation. I'm not sure that's the best thing to do. But open to other opinions. At the end-of-the-day, this is just a convenience tag utilized if a user is looking at the EC2 console denoting that these are Karpenter nodes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's also not per node. It's per-unique-hash-of-scheduling-constraints.

Copy link
Contributor

@ellistarn ellistarn Jul 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see a reasonable argument that they should just all have the same name, but the philosophy behind AWS's naming features is completely opaque to me.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind I was totally confused about what entity this was tagging. All good.

@bwagner5 bwagner5 merged commit 9e7823a into aws:main Jul 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants