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

feat: Add imageID status field #4637

Merged
merged 60 commits into from Oct 11, 2023
Merged

feat: Add imageID status field #4637

merged 60 commits into from Oct 11, 2023

Conversation

gfcroft
Copy link
Contributor

@gfcroft gfcroft commented Sep 15, 2023

feat: Add karpenter.k8s.aws/instance-ami-id label
Fixes #4372

Description
Add the karpenter.k8s.aws/instance-ami-id label to nodes via retrieval of ami-id value from feet override reponse

  • Because a node template may have an existing launch template name set, we have to look up the data for the launch template via an AWS Api call to ec2:DescribeLaunchTemplateVersions
    • Note that there will be extra expense therefore in order to perform this op, so I have added use of the cache for this data
    • Launch template versions seems to be the only viable api to get at the full template data
  • To use this API, we need to add permission to describe launch template versions on the Karpenter controller role; I have update the docs to use ec2:DescribeLaunchTemplate* in the permissions set, instead of ec2:DescribeLaunchTemplates, in order to cover this additional permission (and any similar permissions required in future)
  • the only constant I could see we currently have to cover karpenter.k8s.aws/instance-ami-id label is Have to add in the image id - seems it’s just defined in v1alpha1 ? Hopefully that’s not totally deprecated…
  • By always using imageID as an override parameter, we are dependant now on create fleet request being for a fleet of type ‘instant’ - see: https://docs.aws.amazon.com/sdk-for-go/api/service/ec2/#FleetLaunchTemplateOverridesRequest
    - We seem to only create ‘instant’ fleets, so this will work for now - https://github.com/aws/karpenter/blob/2dfebc9602a9bf6848616fb3740c0f25a455d650/pkg/providers/instance/instance.go#L209-L209

How was this change tested?
requirement for label added to unit tests, also verified by running my against my own eks cluster and seeing that the node labels are indeed added to provisioned nodes appropriately (either via nodes provisioned by karpenter auto-generated launch templates, or via a pre-defined launch template set in aws node template)

Does this change impact docs?

  • Yes, PR includes docs updates

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

@netlify
Copy link

netlify bot commented Sep 15, 2023

Deploy Preview for karpenter-docs-prod canceled.

Name Link
🔨 Latest commit 535d34b
🔍 Latest deploy log https://app.netlify.com/sites/karpenter-docs-prod/deploys/652657bf1142c0000804bf80

…mplate is in use. Consolidate launch template related data into a struct
…ler to lookup launch template versions"

This reverts commit 11cf6fb.

we won't need to perform ec2:DescribeLaunchTemplateVersions for the aws#4637 feature
pkg/providers/instancetype/zz_generated.bandwidth.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/pricing/zz_generated.pricing.go Outdated Show resolved Hide resolved
@gfcroft gfcroft marked this pull request as ready for review September 21, 2023 21:04
@gfcroft gfcroft requested a review from a team as a code owner September 21, 2023 21:04
@gfcroft gfcroft marked this pull request as draft September 21, 2023 22:44
@gfcroft
Copy link
Contributor Author

gfcroft commented Oct 1, 2023

as this change depends on the status field of node claim supporting ImageID which requires an update to karpenter-core (to be accomplished by: kubernetes-sigs/karpenter#559) I expect tests to fail until that is merged and go.mod is updated accordingly

pkg/apis/v1beta1/labels.go Outdated Show resolved Hide resolved
pkg/providers/instancetype/zz_generated.bandwidth.go Outdated Show resolved Hide resolved
pkg/providers/pricing/zz_generated.pricing.go Outdated Show resolved Hide resolved
@jonathan-innis jonathan-innis self-assigned this Oct 9, 2023
jonathan-innis
jonathan-innis previously approved these changes Oct 10, 2023
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

@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.

/karpenter snapshot

@github-actions
Copy link
Contributor

Snapshot successfully published to oci://071440425669.dkr.ecr.us-east-1.amazonaws.com/karpenter/snapshot/karpenter:v0-9bdb097847d77671014b3722961cfe5b5e495be2.

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

@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.

/karpenter snapshot

@jonathan-innis jonathan-innis changed the title feat: Add karpenter.k8s.aws/instance-ami-id label feat: Add imageID status field Oct 11, 2023
@github-actions
Copy link
Contributor

Snapshot successfully published to oci://071440425669.dkr.ecr.us-east-1.amazonaws.com/karpenter/snapshot/karpenter:v0-535d34b23a9535616bb5f134df9f759f636390ac.

@jonathan-innis jonathan-innis merged commit 33a3a7f into aws:main Oct 11, 2023
22 of 24 checks passed
gfcroft added a commit to gfcroft/karpenter-provider-aws that referenced this pull request Nov 25, 2023
…eID… (aws#559)

Co-authored-by: Jonathan Innis <jonathan.innis.ji@gmail.com>
Co-authored-by: Jonathan Innis <joinnis@amazon.com>
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.

Add karpenter.k8s.aws/instance-ami-id label
3 participants