Skip to content

Commit

Permalink
Handle replica counts for multi AZ node groups
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Haeusler committed Jul 1, 2020
1 parent 2579545 commit ec09e9e
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions component/main.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,32 @@ local isMultiAz = function(name)
local zoneId = function(name)
std.reverse(std.split(name, '-'))[0];

local replicasPerZone(replicas) =
std.ceil(replicas / std.length(params.availabilityZones));

local machineSpecs = [
{ name: name, spec: params.nodeGroups[name] }
for name in std.objectFields(params.nodeGroups)
if !isMultiAz(name)
] + std.flattenArrays([
[
local spec = {
spec+: {
providerSpec+: {
value+: {
zone: zone,
{
name: name + '-' + zoneId(zone),
spec: params.nodeGroups[name] {
replicas: replicasPerZone(com.getValueOrDefault(params.nodeGroups[name], 'replicas', 1)),
spec+: {
template+: {
spec+: {
providerSpec+: {
value+: {
zone: zone,
},
},
},
},
},
},
} + params.nodeGroups[name];
{ name: name + '-' + zoneId(zone), spec: spec }
}
for zone in params.availabilityZones
]
for name in std.objectFields(params.nodeGroups)
Expand Down

0 comments on commit ec09e9e

Please sign in to comment.