From 59f29d143641a7e32d50f03a8727e742a14c96b4 Mon Sep 17 00:00:00 2001 From: paulfouquet <86932794+paulfouquet@users.noreply.github.com> Date: Thu, 13 Jun 2024 16:06:51 +1200 Subject: [PATCH] feat: karpenter allows on-demand instances TDE-1185 (#622) #### Motivation Karpenter should allow on-demand instances. #### Modification Add `on-demand` in the list of requirements capacity types. #### Checklist - [x] Tests updated Tested on nonprod cluster - [ ] Docs updated - [x] Issue linked in Title --- infra/charts/karpenter.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/infra/charts/karpenter.ts b/infra/charts/karpenter.ts index 5559e440f..616b62104 100644 --- a/infra/charts/karpenter.ts +++ b/infra/charts/karpenter.ts @@ -122,7 +122,7 @@ export class KarpenterProvisioner extends Chart { }, }); - const provisionAmd64 = new Provisioner(this, 'ClusterAmd64WorkerNodes', { + const provisionAmd64Spot = new Provisioner(this, 'ClusterAmd64WorkerNodesSpot', { metadata: { name: `karpenter-amd64-spot`, namespace: 'karpenter' }, spec: { // Ensure only pods that tolerate spot run on spot instance types @@ -139,6 +139,20 @@ export class KarpenterProvisioner extends Chart { }, }); + const provisionAmd64OnDemand = new Provisioner(this, 'ClusterAmd64WorkerNodesOnDemand', { + metadata: { name: `karpenter-amd64-on-demand`, namespace: 'karpenter' }, + spec: { + requirements: [ + { key: 'karpenter.sh/capacity-type', operator: 'In', values: ['on-demand'] }, + { key: 'kubernetes.io/arch', operator: 'In', values: ['amd64'] }, + { key: 'karpenter.k8s.aws/instance-family', operator: 'In', values: ['c5', 'c6i', 'c6a'] }, + ], + limits: { resources: { cpu: ProvisionerSpecLimitsResources.fromNumber(2000) } }, + providerRef: { ...AwsNodeTemplate.GVK, name: templateName }, + ttlSecondsAfterEmpty: Duration.minutes(1).toSeconds(), // optional, but never scales down if not set + }, + }); + const provisionArm64 = new Provisioner(this, 'ClusterArmWorkerNodes', { metadata: { name: `karpenter-arm64-spot`, namespace: 'karpenter' }, spec: { @@ -161,7 +175,8 @@ export class KarpenterProvisioner extends Chart { }, }); - provisionAmd64.node.addDependency(template); + provisionAmd64Spot.node.addDependency(template); + provisionAmd64OnDemand.node.addDependency(template); provisionArm64.node.addDependency(template); } }