-
Notifications
You must be signed in to change notification settings - Fork 205
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
Karpenter Addon: adding AMI Selector, refactor to use NodeTemplate #736
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
16e58a9
adding AMI Selector, refactor to use NodeTemplate
youngjeong46 26fbfae
uncomment Node Termination Handler Addon
youngjeong46 b32fc52
Karpenter doc updated
youngjeong46 8847e02
addressing PR + spellcheck on doc
youngjeong46 867da6d
adding Taints to SPI
youngjeong46 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,40 @@ import { Cluster } from 'aws-cdk-lib/aws-eks'; | |
* Configuration options for the add-on | ||
*/ | ||
interface KarpenterAddOnProps extends HelmAddOnUserProps { | ||
/** | ||
* Taints for the provisioned nodes - Taints may prevent pods from scheduling if they are not tolerated by the pod. | ||
*/ | ||
taints?: { | ||
key: string, | ||
value: string, | ||
effect: "NoSchedule" | "PreferNoSchedule" | "NoExecute", | ||
}[], | ||
|
||
/** | ||
* Provisioned nodes will have these taints, but pods do not need to tolerate these taints to be provisioned by this\ | ||
* provisioner. These taints are expected to be temporary and some other entity (e.g. a DaemonSet) is responsible for | ||
* removing the taint after it has finished initializing the node. | ||
*/ | ||
startupTaints?: { | ||
key: string, | ||
value: string, | ||
effect: "NoSchedule" | "PreferNoSchedule" | "NoExecute", | ||
}, | ||
|
||
/** | ||
* Labels applied to all nodes | ||
*/ | ||
labels?: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have type Values for this and annotations. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. addressed. |
||
[key: string]: string | ||
}, | ||
|
||
/** | ||
* Annotations applied to all nodes | ||
*/ | ||
annotations?: { | ||
[key: string]: string | ||
} | ||
|
||
/** | ||
* Requirement properties for a Provisioner (Optional) - If not provided, the add-on will | ||
* deploy a Provisioner with default values. | ||
|
@@ -29,12 +63,6 @@ interface KarpenterAddOnProps extends HelmAddOnUserProps { | |
vals: string[], | ||
}[] | ||
|
||
taints?: { | ||
key: string, | ||
value: string, | ||
effect: "NoSchedule" | "PreferNoSchedule" | "NoExecute", | ||
}[] | ||
|
||
/** | ||
* Tags needed for subnets - Subnet tags and security group tags are required for the provisioner to be created | ||
*/ | ||
|
@@ -54,6 +82,13 @@ interface KarpenterAddOnProps extends HelmAddOnUserProps { | |
*/ | ||
amiFamily?: "AL2" | "Bottlerocket" | "Ubuntu" | ||
|
||
/** | ||
* AMI Selector | ||
*/ | ||
amiSelector?: { | ||
[key: string]: string | ||
} | ||
|
||
/** | ||
* Enables consolidation which attempts to reduce cluster cost by both removing un-needed nodes and down-sizing those that can't be removed. | ||
* Mutually exclusive with the ttlSecondsAfterEmpty parameter. | ||
|
@@ -117,7 +152,7 @@ const RELEASE = 'blueprints-addon-karpenter'; | |
const defaultProps: HelmAddOnProps = { | ||
name: KARPENTER, | ||
namespace: KARPENTER, | ||
version: 'v0.27.3', | ||
version: 'v0.28.0', | ||
chart: KARPENTER, | ||
release: KARPENTER, | ||
repository: 'oci://public.ecr.aws/karpenter/karpenter', | ||
|
@@ -150,7 +185,11 @@ export class KarpenterAddOn extends HelmAddOn { | |
const subnetTags = this.options.subnetTags || {}; | ||
const sgTags = this.options.securityGroupTags || {}; | ||
const taints = this.options.taints || []; | ||
const startupTaints = this.options.startupTaints || []; | ||
const labels = this.options.labels || {}; | ||
const annotations = this.options.annotations || {}; | ||
const amiFamily = this.options.amiFamily; | ||
const amiSelector = this.options.amiSelector; | ||
const ttlSecondsAfterEmpty = this.options.ttlSecondsAfterEmpty || null; | ||
const ttlSecondsUntilExpired = this.options.ttlSecondsUntilExpired || null; | ||
const weight = this.options.weight || null; | ||
|
@@ -279,21 +318,37 @@ export class KarpenterAddOn extends HelmAddOn { | |
kind: 'Provisioner', | ||
metadata: { name: 'default' }, | ||
spec: { | ||
consolidation: consolidation, | ||
requirements: this.convert(requirements), | ||
providerRef: { | ||
name: "default" | ||
}, | ||
taints: taints, | ||
startupTaints: startupTaints, | ||
labels: labels, | ||
annotations: annotations, | ||
requirements: this.convert(requirements), | ||
limits: limits, | ||
provider: { | ||
amiFamily: amiFamily, | ||
subnetSelector: subnetTags, | ||
securityGroupSelector: sgTags, | ||
}, | ||
consolidation: consolidation, | ||
ttlSecondsUntilExpired: ttlSecondsUntilExpired, | ||
ttlSecondsAfterEmpty: ttlSecondsAfterEmpty, | ||
weight: weight, | ||
}, | ||
}); | ||
provisioner.node.addDependency(karpenterChart); | ||
|
||
const nodeTemplate = cluster.addManifest('default-node-template', { | ||
apiVersion: "karpenter.k8s.aws/v1alpha1", | ||
kind: "AWSNodeTemplate", | ||
metadata: { | ||
name: "default" | ||
}, | ||
spec: { | ||
amiFamily: amiFamily, | ||
amiSelector: amiSelector, | ||
subnetSelector: subnetTags, | ||
securityGroupSelector: sgTags, | ||
}, | ||
}); | ||
nodeTemplate.node.addDependency(provisioner); | ||
} | ||
|
||
return Promise.resolve(karpenterChart); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use this type https://docs.aws.amazon.com/cdk/api/v1/docs/@aws-cdk_aws-eks.TaintSpec.html?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This didn't work - the provisioner CRD doesn't recognize TaintEffect interface and will cause an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I proposed to only change the API layer for convenience. The backend will remain the same, you will need to convert TaintEffect to string. However, this functionality is already released, so my only comment here is: let's extracts the TaintType, put it in the spi types and reuse in the current form.