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

Delete Launch templates on deletion of EC2NodeClass #5453

Merged
merged 11 commits into from
Jan 23, 2024

Conversation

jigisha620
Copy link
Contributor

@jigisha620 jigisha620 commented Jan 11, 2024

Fixes #995

Description
Added a method to delete the launch templates on deletion of EC2NodeClass. Added tests for the same.

How was this change tested?
Deployed the changes on my local EKS cluster. Steps followed -

  1. Install Karpenter
  2. Created Nodepool that references a Nodeclass
  3. Deployed sample applications
  4. Removed sample applications
  5. Removed the Nodeclass object

Performing the nodeclass object deletion will trigger a flow that deletes the launch templates.

Does this change impact docs?

  • Yes, PR includes docs updates
  • Yes, issue opened: #
  • No

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

@jigisha620 jigisha620 requested a review from a team as a code owner January 11, 2024 01:03
@jigisha620 jigisha620 requested a review from bwagner5 January 11, 2024 01:03
Copy link

netlify bot commented Jan 11, 2024

Deploy Preview for karpenter-docs-prod canceled.

Name Link
🔨 Latest commit 841d738
🔍 Latest deploy log https://app.netlify.com/sites/karpenter-docs-prod/deploys/65aff8e2d7c0ef00070761de

@coveralls
Copy link

coveralls commented Jan 11, 2024

Pull Request Test Coverage Report for Build 7629633106

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.1%) to 82.673%

Totals Coverage Status
Change from base Build 7619678293: 0.1%
Covered Lines: 5005
Relevant Lines: 6054

💛 - Coveralls

@jmdeal
Copy link
Contributor

jmdeal commented Jan 11, 2024

NIce work 🎉 A high level thing, since each cluster can have multiple EC2NodeClasses we really only want to delete the LaunchTemplates which are 'owned' by that NodeClass. We just need to keep in mind there's not a 1-1 mapping between launch templates, some EC2NodeClasses could share launch templates and some could have multiple.

@jigisha620
Copy link
Contributor Author

NIce work 🎉 A high level thing, since each cluster can have multiple EC2NodeClasses we really only want to delete the LaunchTemplates which are 'owned' by that NodeClass. We just need to keep in mind there's not a 1-1 mapping between launch templates, some EC2NodeClasses could share launch templates and some could have multiple.

Thank you. Also, that makes sense. I have updated the LT deletion in such a way that it will check for a tag that corresponds to the nodeclass it is associated with. Also the tag would be added to LT on creation now. The hashed LT name now also contains clusterName and nodeClassName.

Copy link
Contributor

@jonathan-innis jonathan-innis left a comment

Choose a reason for hiding this comment

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

Nice work 🎉

pkg/providers/launchtemplate/launchtemplate.go Outdated Show resolved Hide resolved
pkg/providers/launchtemplate/launchtemplate.go Outdated Show resolved Hide resolved
pkg/providers/launchtemplate/launchtemplate.go Outdated Show resolved Hide resolved
pkg/providers/launchtemplate/launchtemplate.go Outdated Show resolved Hide resolved
pkg/fake/ec2api.go Outdated Show resolved Hide resolved
pkg/providers/launchtemplate/launchtemplate.go Outdated Show resolved Hide resolved
@jonathan-innis
Copy link
Contributor

Do we have an E2E test to validate all of the launch templates are gone when we delete the EC2NodeClass? Take a look at https://github.com/aws/karpenter-provider-aws/blob/main/test/suites/integration/instance_profile_test.go#L47 for a similar style of test

@jigisha620
Copy link
Contributor Author

jigisha620 commented Jan 19, 2024

Do we have an E2E test to validate all of the launch templates are gone when we delete the EC2NodeClass? Take a look at https://github.com/aws/karpenter-provider-aws/blob/main/test/suites/integration/instance_profile_test.go#L47 for a similar style of test

No, there's no E2E test to validate that. I will add it. I was thinking if it should be done in a separate PR?

Copy link
Contributor Author

@jigisha620 jigisha620 left a comment

Choose a reason for hiding this comment

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

/karpenter snapshot

Copy link
Contributor

Snapshot successfully published to oci://021119463062.dkr.ecr.us-east-1.amazonaws.com/karpenter/snapshot/karpenter:v0-5226e34569915a217d7250a69553b0902b6844ad.
To install you must login to the ECR repo with an AWS account:

aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 021119463062.dkr.ecr.us-east-1.amazonaws.com

Copy link
Contributor Author

@jigisha620 jigisha620 left a comment

Choose a reason for hiding this comment

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

/karpenter snapshot

Copy link
Contributor

Snapshot successfully published to oci://021119463062.dkr.ecr.us-east-1.amazonaws.com/karpenter/snapshot/karpenter:v0-9244e17b9da1320d58ae0b6d8482a19e400a8701.
To install you must login to the ECR repo with an AWS account:

aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 021119463062.dkr.ecr.us-east-1.amazonaws.com

Copy link
Contributor Author

@jigisha620 jigisha620 left a comment

Choose a reason for hiding this comment

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

/karpenter snapshot

Copy link
Contributor

Snapshot successfully published to oci://021119463062.dkr.ecr.us-east-1.amazonaws.com/karpenter/snapshot/karpenter:v0-21359e1725d2f9f4867f9e24fc5b602f99c8a0a2.
To install you must login to the ECR repo with an AWS account:

aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 021119463062.dkr.ecr.us-east-1.amazonaws.com

Copy link
Contributor Author

@jigisha620 jigisha620 left a comment

Choose a reason for hiding this comment

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

/karpenter snapshot

jonathan-innis
jonathan-innis previously approved these changes Jan 23, 2024
Copy link
Contributor

@jonathan-innis jonathan-innis left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

Copy link
Contributor

Snapshot successfully published to oci://021119463062.dkr.ecr.us-east-1.amazonaws.com/karpenter/snapshot/karpenter:v0-99f194586901b445206bc312a7a476f08b7533b4.
To install you must login to the ECR repo with an AWS account:

aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 021119463062.dkr.ecr.us-east-1.amazonaws.com

Copy link
Contributor Author

@jigisha620 jigisha620 left a comment

Choose a reason for hiding this comment

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

/karpenter snapshot

Copy link
Contributor

Snapshot successfully published to oci://021119463062.dkr.ecr.us-east-1.amazonaws.com/karpenter/snapshot/karpenter:v0-841d7384d35b15a30773805b85053795b9645898.
To install you must login to the ECR repo with an AWS account:

aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 021119463062.dkr.ecr.us-east-1.amazonaws.com

Copy link
Contributor

@jmdeal jmdeal left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@jigisha620 jigisha620 merged commit 0df4e3b into aws:main Jan 23, 2024
27 checks passed
@jigisha620 jigisha620 deleted the feature-delete-LT branch February 13, 2024 00:04
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.

Launch Template Removal After Uninstalling Karpenter
4 participants