Skip to content

Commit

Permalink
feat(stacks.api): add instanceTypes config and karpenter option
Browse files Browse the repository at this point in the history
Signed-off-by: Braden Mars <bradenmars@bradenmars.me>
  • Loading branch information
BradenM committed Aug 26, 2023
1 parent 02a3e93 commit 2bc3405
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
12 changes: 10 additions & 2 deletions packages/stacks/api/src/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ export const tagKarpenter = (stack: blueprints.EksBlueprint) => {
* @param clusterName Cluster name to target. Defaults to lazy lookup.
* @param subnetNames Subnet names to target. Defaults to lazy lookup.
*/
export const buildKarpenter = (clusterName?: string, subnetNames?: string) => {
export const buildKarpenter = (
clusterName?: string,
subnetNames?: string,
instanceTypes?: string[],
) => {
const sgTag =
clusterName ??
Lazy.uncachedString(
Expand All @@ -121,7 +125,11 @@ export const buildKarpenter = (clusterName?: string, subnetNames?: string) => {
requirements: [
{ key: Label.ARCH, op: 'In', vals: ['arm64'] },
{ key: Label.CAPACITY_TYPE, op: 'In', vals: ['spot', 'on-demand'] },
{ key: Label.INSTANCE_CATEGORY, op: 'In', vals: ['c', 'm', 'r', 't'] },
{
key: Label.INSTANCE_CATEGORY,
op: 'In',
vals: instanceTypes ?? ['c', 'm', 'r', 't'],
},
{ key: Label.INSTANCE_HYPERVISOR, op: 'In', vals: ['nitro'] },
],
subnetTags: {
Expand Down
6 changes: 5 additions & 1 deletion packages/stacks/api/src/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,11 @@ export class Pipeline {
).build(),
)
.addOns(
buildKarpenter(),
buildKarpenter(
undefined,
undefined,
config.apiStack!.eks.instanceTypes ?? undefined,
),
new CrisisCleanupAddOn({
config,
secretsProvider,
Expand Down
5 changes: 5 additions & 0 deletions packages/stacks/api/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ export const eksConfigSchema = eksAddonSchema.extend({
.array(z.string())
.describe('ARNs to add to platform team.')
.default([]),
instanceTypes: z
.array(z.string())
.nullable()
.default(null)
.describe('List of instance families for karpenter to provision.'),
})

export interface EKSConfig extends z.infer<typeof eksConfigSchema> {}
Expand Down

0 comments on commit 2bc3405

Please sign in to comment.