Skip to content

Commit

Permalink
feat: karpenter allows on-demand instances TDE-1185 (#622)
Browse files Browse the repository at this point in the history
#### 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
  • Loading branch information
paulfouquet authored Jun 13, 2024
1 parent 8180a0f commit 59f29d1
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions infra/charts/karpenter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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: {
Expand All @@ -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);
}
}

0 comments on commit 59f29d1

Please sign in to comment.