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 Jun 30, 2020
1 parent 9c3c190 commit ff5e323
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 @@ -61,22 +61,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 ff5e323

Please sign in to comment.