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 all commits
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
37 changes: 28 additions & 9 deletions eksctl/carbonplan.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ 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. Config here is merged
// with our notebook node definition.
// A `node.kubernetes.io/instance-type label is added, so pods
// can request a particular kind of node with a nodeSelector
local notebookNodes = [
{ instanceType: "r5.large" },
{ instanceType: "r5.xlarge" },
{ instanceType: "r5.2xlarge" },
Expand All @@ -19,6 +20,19 @@ local nodes = [
{ instanceType: "x1.32xlarge" }
];

// Node definitions for dask worker nodes. Config here is merged
// with our dask worker node definition, which uses spot instances.
// A `node.kubernetes.io/instance-type label is set to the name of the
// *first* item in instanceDistribution.instanceTypes, to match
// what we do with notebook nodes. Pods can request a particular
// kind of node with a nodeSelector
local daskNodes = [
{ instancesDistribution+: { instanceTypes: ["r5.large"] }},
{ instancesDistribution+: { instanceTypes: ["r5.xlarge"] }},
{ instancesDistribution+: { instanceTypes: ["r5.2xlarge"] }},
{ instancesDistribution+: { instanceTypes: ["r5.8xlarge"] }},
];

cluster {
metadata+: {
name: "carbonplanhub",
Expand All @@ -44,10 +58,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 +75,12 @@ cluster {
"hub.jupyter.org/dedicated": "user:NoSchedule"
},

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

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.instancesDistribution.instanceTypes[0], ".", "-"),
availabilityZones: [nodeAz],
minSize: 0,
maxSize: 500,
Expand All @@ -79,8 +94,12 @@ cluster {
"k8s.dask.org_dedicated" : "worker:NoSchedule",
"k8s.dask.org/dedicated" : "worker:NoSchedule"
},

} + n for n in nodes
instancesDistribution+: {
onDemandBaseCapacity: 0,
onDemandPercentageAboveBaseCapacity: 0,
spotAllocationStrategy: "capacity-optimized",
},
} + n 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,
// 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