From ec09e9e06cd5a46b6a144b6d6ad8bc7079a3ef80 Mon Sep 17 00:00:00 2001 From: Christian Haeusler Date: Tue, 30 Jun 2020 16:32:59 +0200 Subject: [PATCH] Handle replica counts for multi AZ node groups --- component/main.jsonnet | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/component/main.jsonnet b/component/main.jsonnet index f048feb..e5ccbcb 100644 --- a/component/main.jsonnet +++ b/component/main.jsonnet @@ -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)