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

Use spot instances for dask workers #605

Merged
merged 3 commits into from
Aug 15, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 23 additions & 9 deletions eksctl/carbonplan.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ local clusterRegion = "us-west-2";
local masterAzs = ["us-west-2a", "us-west-2b", "us-west-2c"];
local nodeAz = "us-west-2a";

// Node definitions for use with dask and notebook nodes
// These are merged in with the defaults for either node type,
// and so can contain any overrides.
local nodes = [
// Node definitions for notebook nodes. Only `instanceType` is
// supported as a property.
local notebookNodes = [
{ instanceType: "r5.large" },
{ instanceType: "r5.xlarge" },
{ instanceType: "r5.2xlarge" },
Expand All @@ -19,6 +18,15 @@ local nodes = [
{ instanceType: "x1.32xlarge" }
];

// Node definitions for notebook nodes. Only `instanceType` is
// supported as a property.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Node definitions for notebook nodes. Only `instanceType` is
// supported as a property.
// Node definitions for dask worker nodes. Only `instanceType` is
// supported as a property.

local daskNodes = [
{ instanceType: "r5.large" },
{ instanceType: "r5.xlarge" },
{ instanceType: "r5.2xlarge" },
{ instanceType: "r5.8xlarge" },
];

cluster {
metadata+: {
name: "carbonplanhub",
Expand All @@ -44,10 +52,11 @@ cluster {
ng {
// NodeGroup names can't have a '.' in them, while
// instanceTypes always have a .
name: "nb-%s" % std.strReplace(self.instanceType, ".", "-"),
name: "nb-%s" % std.strReplace(n.instanceType, ".", "-"),
availabilityZones: [nodeAz],
minSize: 0,
maxSize: 500,
instanceType: n.instanceType,
ssh: {
publicKeyPath: 'ssh-keys/carbonplan.key.pub'
},
Expand All @@ -60,12 +69,12 @@ cluster {
"hub.jupyter.org/dedicated": "user:NoSchedule"
},

} + n for n in nodes
} + n for n in notebookNodes
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know jsonnet, but there is an inconsistency here.

Below it sais } for n in daskNodes, but here it sais } + n for n in notebookNodes. I'll go ahead and guess this is wrong, but perhaps its the other that is wrong? No clue.

Suggested change
} + n for n in notebookNodes
} n for n in notebookNodes

Copy link
Member Author

Choose a reason for hiding this comment

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

@consideRatio yeah, I was trying to be 'clever' and just be able to set instanceType for both non-spot and spot node pools. However, this becomes unmaintainable soon, so I've reverted that. Now the config is the same as what you'll pass to eksctl.

] + [
ng {
// NodeGroup names can't have a '.' in them, while
// instanceTypes always have a .
name: "dask-%s" % std.strReplace(self.instanceType, ".", "-"),
name: "dask-%s" % std.strReplace(n.instanceType, ".", "-"),
availabilityZones: [nodeAz],
minSize: 0,
maxSize: 500,
Expand All @@ -79,8 +88,13 @@ cluster {
"k8s.dask.org_dedicated" : "worker:NoSchedule",
"k8s.dask.org/dedicated" : "worker:NoSchedule"
},

} + n for n in nodes
instancesDistribution: {
instanceTypes: [n.instanceType],
onDemandBaseCapacity: 0,
onDemandPercentageAboveBaseCapacity: 0,
spotAllocationStrategy: "capacity-optimized",
},
} for n in daskNodes
]


Expand Down
6 changes: 3 additions & 3 deletions eksctl/libsonnet/nodegroup.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ local makeCloudTaints(taints) = {
availabilityZones: [],
minSize: 0,
desiredCapacity: self.minSize,
instanceType: '',
volumeSize: 80,
labels+: {
// Add instance type as label to nodegroups, so they
// can be picked up by the autoscaler
'node.kubernetes.io/instance-type': $.instanceType,
// can be picked up by the autoscaler. If using spot instances,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// can be picked up by the autoscaler. If using spot instances,
// can be picked up by the autoscaler. If using spot instances,

Indentation nitpick

// pick the first instancetype
'node.kubernetes.io/instance-type': if std.objectHas($, 'instanceType') then $.instanceType else $.instancesDistribution.instanceTypes[0],
},
taints+: {},
tags: makeCloudLabels(self.labels) + makeCloudTaints(self.taints),
Expand Down