Skip to content

Commit

Permalink
Merge pull request #3445 from consideRatio/pr/nameprefix
Browse files Browse the repository at this point in the history
eksctl: set nodegroup name based on namePrefix, nameBase, and nameSuffix
  • Loading branch information
consideRatio authored Nov 21, 2023
2 parents 8b3d7d2 + f1b7c8a commit 0e17561
Show file tree
Hide file tree
Showing 14 changed files with 151 additions and 152 deletions.
18 changes: 8 additions & 10 deletions eksctl/2i2c-aws-us.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@ local daskNodes = [
},
],
nodeGroups: [
ng {
name: 'core-b',
ng + {
namePrefix: 'core',
nameSuffix: 'b',
nameIncludeInstanceType: false,
availabilityZones: [nodeAz],
ssh: {
publicKeyPath: 'ssh-keys/2i2c-aws-us.key.pub'
Expand All @@ -99,10 +101,8 @@ local daskNodes = [
},
},
] + [
ng {
// NodeGroup names can't have a '.' in them, while
// instanceTypes always have a .
name: "nb-%s" % std.strReplace(n.instanceType, ".", "-"),
ng + {
namePrefix: "nb",
availabilityZones: [nodeAz],
minSize: 0,
maxSize: 500,
Expand All @@ -122,10 +122,8 @@ local daskNodes = [
} + n for n in notebookNodes
] + ( if daskNodes != null then
[
ng {
// NodeGroup names can't have a '.' in them, while
// instanceTypes always have a .
name: "dask-%s" % std.strReplace(n.instancesDistribution.instanceTypes[0], ".", "-"),
ng + {
namePrefix: "dask",
availabilityZones: [nodeAz],
minSize: 0,
maxSize: 500,
Expand Down
18 changes: 8 additions & 10 deletions eksctl/carbonplan.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,10 @@ local daskNodes = [
},
],
nodeGroups: [
ng {
name: 'core-a',
ng + {
namePrefix: 'core',
nameSuffix: 'a',
nameIncludeInstanceType: false,
availabilityZones: [nodeAz],
ssh: {
publicKeyPath: 'ssh-keys/carbonplan.key.pub'
Expand All @@ -116,10 +118,8 @@ local daskNodes = [
},
},
] + [
ng {
// NodeGroup names can't have a '.' in them, while
// instanceTypes always have a .
name: "nb-%s" % std.strReplace(n.instanceType, ".", "-"),
ng + {
namePrefix: "nb",
availabilityZones: [nodeAz],
minSize: 0,
maxSize: 500,
Expand All @@ -138,10 +138,8 @@ local daskNodes = [

} + n for n in notebookNodes
] + [
ng {
// NodeGroup names can't have a '.' in them, while
// instanceTypes always have a .
name: "dask-%s" % std.strReplace(n.instancesDistribution.instanceTypes[0], ".", "-"),
ng + {
namePrefix: "dask",
availabilityZones: [nodeAz],
minSize: 0,
maxSize: 500,
Expand Down
18 changes: 8 additions & 10 deletions eksctl/catalystproject-africa.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ local daskNodes = [];
},
],
nodeGroups: [
ng {
name: 'core-a',
ng + {
namePrefix: 'core',
nameSuffix: 'a',
nameIncludeInstanceType: false,
availabilityZones: [nodeAz],
ssh: {
publicKeyPath: 'ssh-keys/catalystproject-africa.key.pub'
Expand All @@ -80,10 +82,8 @@ local daskNodes = [];
},
},
] + [
ng {
// NodeGroup names can't have a '.' in them, while
// instanceTypes always have a .
name: "nb-%s" % std.strReplace(n.instanceType, ".", "-"),
ng + {
namePrefix: "nb",
availabilityZones: [nodeAz],
minSize: 0,
maxSize: 500,
Expand All @@ -102,10 +102,8 @@ local daskNodes = [];
} + n for n in notebookNodes
] + ( if daskNodes != null then
[
ng {
// NodeGroup names can't have a '.' in them, while
// instanceTypes always have a .
name: "dask-%s" % std.strReplace(n.instancesDistribution.instanceTypes[0], ".", "-"),
ng + {
namePrefix: "dask",
availabilityZones: [nodeAz],
minSize: 0,
maxSize: 500,
Expand Down
18 changes: 8 additions & 10 deletions eksctl/gridsst.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,10 @@ local daskNodes = [
},
],
nodeGroups: [
ng {
name: 'core-b',
ng + {
namePrefix: 'core',
nameSuffix: 'b',
nameIncludeInstanceType: false,
availabilityZones: [nodeAz],
ssh: {
publicKeyPath: 'ssh-keys/gridsst.key.pub'
Expand All @@ -109,10 +111,8 @@ local daskNodes = [
},
},
] + [
ng {
// NodeGroup names can't have a '.' in them, while
// instanceTypes always have a .
name: "nb-%s" % std.strReplace(n.instanceType, ".", "-"),
ng + {
namePrefix: "nb",
availabilityZones: [nodeAz],
minSize: n.minSize,
maxSize: 500,
Expand All @@ -130,10 +130,8 @@ local daskNodes = [
},
} + n for n in notebookNodes
] + [
ng {
// NodeGroup names can't have a '.' in them, while
// instanceTypes always have a .
name: "dask-%s" % std.strReplace(n.instancesDistribution.instanceTypes[0], ".", "-"),
ng + {
namePrefix: "dask",
availabilityZones: [nodeAz],
minSize: 0,
maxSize: 500,
Expand Down
18 changes: 8 additions & 10 deletions eksctl/jupyter-meets-the-earth.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,10 @@ local daskNodes = [
},
],
nodeGroups: [
ng {
name: 'core-b',
ng + {
namePrefix: 'core',
nameSuffix: 'b',
nameIncludeInstanceType: false,
availabilityZones: [nodeAz],
ssh: {
publicKeyPath: 'ssh-keys/jupyter-meets-the-earth.key.pub'
Expand All @@ -123,10 +125,8 @@ local daskNodes = [
},
},
] + [
ng {
// NodeGroup names can't have a '.' in them, while
// instanceTypes always have a .
name: "nb-%s" % std.strReplace(n.instanceType, ".", "-"),
ng + {
namePrefix: "nb",
availabilityZones: [nodeAz],
minSize: 0,
maxSize: 500,
Expand All @@ -145,10 +145,8 @@ local daskNodes = [
} + n for n in notebookNodes
] + ( if daskNodes != null then
[
ng {
// NodeGroup names can't have a '.' in them, while
// instanceTypes always have a .
name: "dask-%s" % std.strReplace(n.instancesDistribution.instanceTypes[0], ".", "-"),
ng + {
namePrefix: "dask",
availabilityZones: [nodeAz],
minSize: 0,
maxSize: 500,
Expand Down
69 changes: 47 additions & 22 deletions eksctl/libsonnet/nodegroup.jsonnet
Original file line number Diff line number Diff line change
@@ -1,34 +1,59 @@
// This file is referenced by ../template.jsonnet. It declares an object
// representing a node group that is used as a common foundation for all
// our node groups.
//
/*
This file is imported by ../template.jsonnet and its generated files.
// Make Auto Scaling Group (ASG) tags for given set of k8s labels
local makeCloudLabels(labels) = {
['k8s.io/cluster-autoscaler/node-template/label/%s' % key]: labels[key]
for key in std.objectFields(labels)
};
Exports an object representing a node group's default fields, and is supposed
to be merged with other objects.
# Make ASG tags for given set of k8s taints
local makeCloudTaints(taints) = {
['k8s.io/cluster-autoscaler/node-template/taint/%s' % key]: taints[key]
for key in std.objectFields(taints)
};
Note that the "name" output field is declared to be calculated based on hidden
fields that objects merging into this can influence.
*/

// Exported object
{
name: '',
// Note that spot instances configured via an Auto Scaling Group (ASG) can have
// multiple instance types associated with it (with the same CPU/RAM/GPU), we
// label them using the first instance type in the ASG as a compromise.
//
// More details at:
// https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/cloudprovider/aws/README.md#using-mixed-instances-policies-and-spot-instances
//
local instanceType = if 'instanceType' in $ then $.instanceType else $.instancesDistribution.instanceTypes[0],
// NodeGroup names can't have a '.' in them as instanceTypes has
local escapedInstanceType = std.strReplace(instanceType, ".", "-"),

// The cluster autoscaler reads specific tags on a Auto Scaling Group's default
// launch template version about the k8s labels and taints that the node group
// has in order to correctly pick the right node group to scale up. These tags
// can't be changed.
local caLabelTags(labels) = {
['k8s.io/cluster-autoscaler/node-template/label/%s' % key]: labels[key]
for key in std.objectFields(labels)
},
local caTaintTags(taints) = {
['k8s.io/cluster-autoscaler/node-template/taint/%s' % key]: taints[key]
for key in std.objectFields(taints)
},
local tags = caLabelTags(self.labels) + caTaintTags(self.taints),

local nameParts = [self.namePrefix, self.nameBase, self.nameSuffix],

// Hidden fields (due to ::) are used as inputs from merged objects to compute
// output fields
namePrefix:: "",
nameIncludeInstanceType:: true,
nameBase:: if self.nameIncludeInstanceType then escapedInstanceType else "",
nameSuffix:: "",
preventScaleUp:: false,

// Output fields
name: std.join("-", std.filter(function(x) x != "", nameParts)),
availabilityZones: [],
minSize: 0,
desiredCapacity: self.minSize,
volumeSize: 80,
labels+: {
// Add instance type as label to nodegroups, so they
// 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],
},
labels+: { 'node.kubernetes.io/instance-type': instanceType },
taints+: {},
tags+: makeCloudLabels(self.labels) + makeCloudTaints(self.taints),
tags+: tags,
iam: {
withAddonPolicies: {
autoScaler: true,
Expand Down
18 changes: 8 additions & 10 deletions eksctl/nasa-cryo.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,10 @@ local daskNodes = [
},
],
nodeGroups: [
ng {
name: 'core-b',
ng + {
namePrefix: 'core',
nameSuffix: 'b',
nameIncludeInstanceType: false,
availabilityZones: [nodeAz],
ssh: {
publicKeyPath: 'ssh-keys/nasa-cryo.key.pub'
Expand All @@ -104,10 +106,8 @@ local daskNodes = [
},
},
] + [
ng {
// NodeGroup names can't have a '.' in them, while
// instanceTypes always have a .
name: "nb-%s" % std.strReplace(n.instanceType, ".", "-"),
ng + {
namePrefix: "nb",
availabilityZones: [nodeAz],
minSize: 0,
maxSize: 500,
Expand All @@ -126,10 +126,8 @@ local daskNodes = [

} + n for n in notebookNodes
] + [
ng {
// NodeGroup names can't have a '.' in them, while
// instanceTypes always have a .
name: "dask-%s" % std.strReplace(n.instancesDistribution.instanceTypes[0], ".", "-"),
ng + {
namePrefix: "dask",
availabilityZones: [nodeAz],
minSize: 0,
maxSize: 500,
Expand Down
18 changes: 8 additions & 10 deletions eksctl/nasa-ghg.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ local daskNodes = [
},
],
nodeGroups: [
ng {
name: 'core-a',
ng + {
namePrefix: 'core',
nameSuffix: 'a',
nameIncludeInstanceType: false,
availabilityZones: [nodeAz],
ssh: {
publicKeyPath: 'ssh-keys/nasa-ghg.key.pub'
Expand All @@ -92,10 +94,8 @@ local daskNodes = [
},
},
] + [
ng {
// NodeGroup names can't have a '.' in them, while
// instanceTypes always have a .
name: "nb-%s" % std.strReplace(n.instanceType, ".", "-"),
ng + {
namePrefix: "nb",
availabilityZones: [nodeAz],
minSize: 0,
maxSize: 500,
Expand All @@ -114,10 +114,8 @@ local daskNodes = [
} + n for n in notebookNodes
] + ( if daskNodes != null then
[
ng {
// NodeGroup names can't have a '.' in them, while
// instanceTypes always have a .
name: "dask-%s" % std.strReplace(n.instancesDistribution.instanceTypes[0], ".", "-"),
ng + {
namePrefix: "dask",
availabilityZones: [nodeAz],
minSize: 0,
maxSize: 500,
Expand Down
18 changes: 8 additions & 10 deletions eksctl/nasa-veda.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,10 @@ local daskNodes = [
},
],
nodeGroups: [
ng {
name: 'core-a',
ng + {
namePrefix: 'core',
nameSuffix: 'a',
nameIncludeInstanceType: false,
availabilityZones: [nodeAz],
ssh: {
publicKeyPath: 'ssh-keys/nasa-veda.key.pub'
Expand All @@ -93,10 +95,8 @@ local daskNodes = [
},
},
] + [
ng {
// NodeGroup names can't have a '.' in them, while
// instanceTypes always have a .
name: "nb-%s" % std.strReplace(n.instanceType, ".", "-"),
ng + {
namePrefix: "nb",
availabilityZones: [nodeAz],
minSize: 0,
maxSize: 500,
Expand All @@ -115,10 +115,8 @@ local daskNodes = [
} + n for n in notebookNodes
] + ( if daskNodes != null then
[
ng {
// NodeGroup names can't have a '.' in them, while
// instanceTypes always have a .
name: "dask-%s" % std.strReplace(n.instancesDistribution.instanceTypes[0], ".", "-"),
ng + {
namePrefix: "dask",
availabilityZones: [nodeAz],
minSize: 0,
maxSize: 500,
Expand Down
Loading

0 comments on commit 0e17561

Please sign in to comment.