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: reimplement amiFamily #6569

Merged
merged 10 commits into from
Jul 30, 2024
Merged

Conversation

jmdeal
Copy link
Contributor

@jmdeal jmdeal commented Jul 22, 2024

Fixes #N/A

Description
Reimplements amiFamily for Karpenter's v1 APIs. This enables users to use Karpenter's managed UserData with custom AMIs, along with custom UserData with aliases.

Examples:

# amiFamily is AL2023 since it is not otherwise specified
apiVersion: karpenter.k8s.aws/v1
kind: EC2NodeClass
spec:
  amiSelectorTerms:
    - alias: 'al2023@latest'
# Automatically discover AMIs using the alias, but don't merge UserData
apiVersion: karpenter.k8s.aws/v1
kind: EC2NodeClass
spec:
  amiFamily: Custom
  amiSelectorTerms:
    - alias: 'al2023@latest'
# Use a user-specified AMI ID, but generate AL2023 UserData and default BlockDeviceMappings
apiVersion: karpenter.k8s.aws/v1
kind: EC2NodeClass
spec:
  # Note: amiFamily is **required** with non-alias amiSelectorTerms
  amiFamily: AL2023
  amiSelectorTerms:
    - id: ami-0123456789abcdef

Additionally, this PR fleshes out the Ubuntu migration path for v1. Since Karpenter is dropping native support for Ubuntu AMIs, there will be no Ubuntu alias. Users with v1beta1 EC2NodeClasses using the Ubuntu AMI family will need to specify AMISelectorTerms before upgrading to v1. Failure to do so will result in the conversion webhook failing closed. As long as AMISelectorTerms are pinned, the v1 NodeClass will carry those over, convert the AMIFamily to Ubuntu, and inject the default Ubuntu blockDeviceMappings if necessary.

e.g.

version: karpenter.k8s.aws/v1beta1
kind: EC2NodeClass
spec:
  amiFamily: Ubuntu
  amiSelectorTerms:
  - id: ami-foo
---
# Conversion Webhook Output
version: karpenter.k8s.aws/v1
kind: EC2NodeClass
metadata:
  annotations:
    compatibility.karpenter.k8s.aws/v1beta1-ubuntu: amiFamily,blockDeviceMappings
spec:
  amiFamily: AL2
  amiSelectorTerms:
  - id: ami-foo
  blockDeviceMappings:
  - deviceName: '/dev/sda1'
    rootVolume: true
    ebs:
      encrypted: true
      volumeType: gp3
      volumeSize: 20Gi

How was this change tested?
make presubmit and /karpenter snapshot

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.

Copy link

netlify bot commented Jul 22, 2024

Deploy Preview for karpenter-docs-prod ready!

Name Link
🔨 Latest commit b212441
🔍 Latest deploy log https://app.netlify.com/sites/karpenter-docs-prod/deploys/66a96713d7d3ae00084a0e4d
😎 Deploy Preview https://deploy-preview-6569--karpenter-docs-prod.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@jmdeal jmdeal force-pushed the feat/reimplement-ami-family branch 2 times, most recently from 6ad0d24 to f6138c5 Compare July 23, 2024 04:20
@jmdeal jmdeal marked this pull request as ready for review July 23, 2024 04:21
@jmdeal jmdeal requested a review from a team as a code owner July 23, 2024 04:21
@jmdeal jmdeal requested a review from ellistarn July 23, 2024 04:21
pkg/apis/v1/ec2nodeclass.go Outdated Show resolved Hide resolved
@coveralls
Copy link

coveralls commented Jul 23, 2024

Pull Request Test Coverage Report for Build 10170602493

Details

  • 119 of 123 (96.75%) changed or added relevant lines in 6 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.2%) to 79.278%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pkg/apis/v1/ec2nodeclass.go 28 32 87.5%
Files with Coverage Reduction New Missed Lines %
pkg/apis/v1/ec2nodeclass.go 1 90.0%
Totals Coverage Status
Change from base Build 10170533870: 0.2%
Covered Lines: 5976
Relevant Lines: 7538

💛 - Coveralls

Copy link
Contributor Author

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

/karpenter snapshot

@jmdeal jmdeal force-pushed the feat/reimplement-ami-family branch from bca07ee to 922c1da Compare July 23, 2024 05:29
Copy link
Contributor

Snapshot successfully published to oci://021119463062.dkr.ecr.us-east-1.amazonaws.com/karpenter/snapshot/karpenter:0-bca07ee591abfa7cad8d88834fd63ce0c68c3221.
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

helm upgrade --install karpenter oci://021119463062.dkr.ecr.us-east-1.amazonaws.com/karpenter/snapshot/karpenter --version "0-bca07ee591abfa7cad8d88834fd63ce0c68c3221" --namespace "kube-system" --create-namespace \
  --set "settings.clusterName=${CLUSTER_NAME}" \
  --set "settings.interruptionQueue=${CLUSTER_NAME}" \
  --set controller.resources.requests.cpu=1 \
  --set controller.resources.requests.memory=1Gi \
  --set controller.resources.limits.cpu=1 \
  --set controller.resources.limits.memory=1Gi \
  --wait

@jmdeal jmdeal force-pushed the feat/reimplement-ami-family branch 4 times, most recently from f9d5499 to 4f5673c Compare July 24, 2024 22:25
pkg/apis/v1/ec2nodeclass.go Outdated Show resolved Hide resolved
pkg/apis/v1/ec2nodeclass.go Show resolved Hide resolved
pkg/apis/v1/ec2nodeclass_conversion.go Show resolved Hide resolved
pkg/apis/v1/ec2nodeclass_conversion.go Show resolved Hide resolved
pkg/apis/v1/ec2nodeclass_conversion.go Show resolved Hide resolved
pkg/controllers/nodeclass/status/ami_test.go Outdated Show resolved Hide resolved
pkg/apis/v1/ec2nodeclass.go Show resolved Hide resolved
pkg/apis/v1/ec2nodeclass.go Show resolved Hide resolved
pkg/apis/v1/ec2nodeclass.go Show resolved Hide resolved
pkg/apis/v1/ec2nodeclass.go Show resolved Hide resolved
pkg/apis/v1/ec2nodeclass.go Show resolved Hide resolved
pkg/apis/v1/ec2nodeclass_conversion.go Show resolved Hide resolved
Copy link
Contributor

@njtran njtran 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:0-596e09aa3bf64d2cd161a6d219a3dbe7a1856ccb.
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

helm upgrade --install karpenter oci://021119463062.dkr.ecr.us-east-1.amazonaws.com/karpenter/snapshot/karpenter --version "0-596e09aa3bf64d2cd161a6d219a3dbe7a1856ccb" --namespace "kube-system" --create-namespace \
  --set "settings.clusterName=${CLUSTER_NAME}" \
  --set "settings.interruptionQueue=${CLUSTER_NAME}" \
  --set controller.resources.requests.cpu=1 \
  --set controller.resources.requests.memory=1Gi \
  --set controller.resources.limits.cpu=1 \
  --set controller.resources.limits.memory=1Gi \
  --wait

jonathan-innis
jonathan-innis previously approved these changes Jul 30, 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

@njtran njtran 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:0-c83f9a2836a4d14b837dae71bec8a2e20e0fec08.
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

helm upgrade --install karpenter oci://021119463062.dkr.ecr.us-east-1.amazonaws.com/karpenter/snapshot/karpenter --version "0-c83f9a2836a4d14b837dae71bec8a2e20e0fec08" --namespace "kube-system" --create-namespace \
  --set "settings.clusterName=${CLUSTER_NAME}" \
  --set "settings.interruptionQueue=${CLUSTER_NAME}" \
  --set controller.resources.requests.cpu=1 \
  --set controller.resources.requests.memory=1Gi \
  --set controller.resources.limits.cpu=1 \
  --set controller.resources.limits.memory=1Gi \
  --wait

njtran
njtran previously approved these changes Jul 30, 2024
Copy link
Contributor

@njtran njtran left a comment

Choose a reason for hiding this comment

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

LGTM

@njtran njtran force-pushed the feat/reimplement-ami-family branch from c83f9a2 to b212441 Compare July 30, 2024 22:20
@njtran njtran enabled auto-merge (squash) July 30, 2024 22:20
Copy link
Contributor

@njtran njtran left a comment

Choose a reason for hiding this comment

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

LGTM

@njtran njtran merged commit 094b57c into aws:main Jul 30, 2024
16 checks passed
@jmdeal jmdeal deleted the feat/reimplement-ami-family branch August 14, 2024 22:41
@artem-nefedov
Copy link
Contributor

Hello @jmdeal . As the author of this feature, I would appreciate if you can answer a question in #6862

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.

6 participants