in src/logic/Logic.js [26:114]
constructor(input) {
// Calculate clusters, using Packer
const packer = new Packer();
const validCombinations = [];
const space = {
net: input.network,
mask: input.netmask,
};
let ok = true;
let count = 1;
while (ok && count < 1001) {
const networks = [];
const targetNumberLength = count.toString().length;
for (let j = 1; j <= count; j++) {
networks.push({
mask: input.nodeNetmask,
name: 'node-' + this.pad(targetNumberLength, j),
vpcName: 'vpc-' + this.pad(targetNumberLength, j),
subnetRangeName: 'N/A',
type: 'PRIMARY',
description:
'Main VPC range for node-' + this.pad(targetNumberLength, j),
});
networks.push({
mask: input.clusterNetmask,
name: 'cluster-' + this.pad(targetNumberLength, j),
vpcName: 'vpc-' + this.pad(targetNumberLength, j),
subnetRangeName: 'cluster-' + this.pad(targetNumberLength, j),
type: 'SECONDARY',
description:
'Secondary range for VPC node-' +
this.pad(targetNumberLength, j) +
' (for pods)',
});
networks.push({
mask: input.serviceNetmask,
name: 'service-' + this.pad(targetNumberLength, j),
vpcName: 'vpc-' + this.pad(targetNumberLength, j),
subnetRangeName: 'service-' + this.pad(targetNumberLength, j),
type: 'SECONDARY',
description:
'Secondary range for VPC node-' +
this.pad(targetNumberLength, j) +
' (for services)',
});
if (input.masterNetwork === 'UNIQUE') {
networks.push({
mask: 28,
name: 'master-' + this.pad(targetNumberLength, j),
vpcName: 'N/A',
subnetRangeName: 'N/A',
type: 'MANAGED',
description:
'IP range for managed VPC for master(s) for cluster node-' +
this.pad(targetNumberLength, j),
});
}
}
if (input.masterNetwork === 'SHARE') {
networks.push({
mask: 28,
name: 'master',
vpcName: 'N/A',
subnetRangeName: 'N/A',
type: 'MANAGED',
description:
'Shared IP range for managed VPC for master(s) for all clusters',
});
}
const packerResults = packer.pack(space, networks);
if (packerResults.state === 'ok') {
validCombinations.push({
networks: packerResults.packedNets,
freeRanges: packerResults.freeRanges,
});
} else {
ok = false;
}
count++;
}
this.combinations = validCombinations;
}