Skip to content

Commit efaea62

Browse files
[release-line-0.4.1] Limit cometbft load balancer ports to only those actually used (#1193)
backport from #1190 [static] --------- Signed-off-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org> Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
1 parent 16e9917 commit efaea62

File tree

3 files changed

+22
-291
lines changed

3 files changed

+22
-291
lines changed

cluster/expected/infra/expected.json

Lines changed: 0 additions & 276 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,186 +1447,6 @@
14471447
"protocol": "TCP",
14481448
"targetPort": 6201
14491449
},
1450-
{
1451-
"name": "cometbft-0-0-gw",
1452-
"port": 26006,
1453-
"protocol": "TCP",
1454-
"targetPort": 26006
1455-
},
1456-
{
1457-
"name": "cometbft-0-1-gw",
1458-
"port": 26016,
1459-
"protocol": "TCP",
1460-
"targetPort": 26016
1461-
},
1462-
{
1463-
"name": "cometbft-0-2-gw",
1464-
"port": 26026,
1465-
"protocol": "TCP",
1466-
"targetPort": 26026
1467-
},
1468-
{
1469-
"name": "cometbft-0-3-gw",
1470-
"port": 26036,
1471-
"protocol": "TCP",
1472-
"targetPort": 26036
1473-
},
1474-
{
1475-
"name": "cometbft-0-4-gw",
1476-
"port": 26046,
1477-
"protocol": "TCP",
1478-
"targetPort": 26046
1479-
},
1480-
{
1481-
"name": "cometbft-0-5-gw",
1482-
"port": 26056,
1483-
"protocol": "TCP",
1484-
"targetPort": 26056
1485-
},
1486-
{
1487-
"name": "cometbft-0-6-gw",
1488-
"port": 26066,
1489-
"protocol": "TCP",
1490-
"targetPort": 26066
1491-
},
1492-
{
1493-
"name": "cometbft-0-7-gw",
1494-
"port": 26076,
1495-
"protocol": "TCP",
1496-
"targetPort": 26076
1497-
},
1498-
{
1499-
"name": "cometbft-0-8-gw",
1500-
"port": 26086,
1501-
"protocol": "TCP",
1502-
"targetPort": 26086
1503-
},
1504-
{
1505-
"name": "cometbft-0-9-gw",
1506-
"port": 26096,
1507-
"protocol": "TCP",
1508-
"targetPort": 26096
1509-
},
1510-
{
1511-
"name": "cometbft-1-0-gw",
1512-
"port": 26106,
1513-
"protocol": "TCP",
1514-
"targetPort": 26106
1515-
},
1516-
{
1517-
"name": "cometbft-1-1-gw",
1518-
"port": 26116,
1519-
"protocol": "TCP",
1520-
"targetPort": 26116
1521-
},
1522-
{
1523-
"name": "cometbft-1-2-gw",
1524-
"port": 26126,
1525-
"protocol": "TCP",
1526-
"targetPort": 26126
1527-
},
1528-
{
1529-
"name": "cometbft-1-3-gw",
1530-
"port": 26136,
1531-
"protocol": "TCP",
1532-
"targetPort": 26136
1533-
},
1534-
{
1535-
"name": "cometbft-1-4-gw",
1536-
"port": 26146,
1537-
"protocol": "TCP",
1538-
"targetPort": 26146
1539-
},
1540-
{
1541-
"name": "cometbft-1-5-gw",
1542-
"port": 26156,
1543-
"protocol": "TCP",
1544-
"targetPort": 26156
1545-
},
1546-
{
1547-
"name": "cometbft-1-6-gw",
1548-
"port": 26166,
1549-
"protocol": "TCP",
1550-
"targetPort": 26166
1551-
},
1552-
{
1553-
"name": "cometbft-1-7-gw",
1554-
"port": 26176,
1555-
"protocol": "TCP",
1556-
"targetPort": 26176
1557-
},
1558-
{
1559-
"name": "cometbft-1-8-gw",
1560-
"port": 26186,
1561-
"protocol": "TCP",
1562-
"targetPort": 26186
1563-
},
1564-
{
1565-
"name": "cometbft-1-9-gw",
1566-
"port": 26196,
1567-
"protocol": "TCP",
1568-
"targetPort": 26196
1569-
},
1570-
{
1571-
"name": "cometbft-2-0-gw",
1572-
"port": 26206,
1573-
"protocol": "TCP",
1574-
"targetPort": 26206
1575-
},
1576-
{
1577-
"name": "cometbft-2-1-gw",
1578-
"port": 26216,
1579-
"protocol": "TCP",
1580-
"targetPort": 26216
1581-
},
1582-
{
1583-
"name": "cometbft-2-2-gw",
1584-
"port": 26226,
1585-
"protocol": "TCP",
1586-
"targetPort": 26226
1587-
},
1588-
{
1589-
"name": "cometbft-2-3-gw",
1590-
"port": 26236,
1591-
"protocol": "TCP",
1592-
"targetPort": 26236
1593-
},
1594-
{
1595-
"name": "cometbft-2-4-gw",
1596-
"port": 26246,
1597-
"protocol": "TCP",
1598-
"targetPort": 26246
1599-
},
1600-
{
1601-
"name": "cometbft-2-5-gw",
1602-
"port": 26256,
1603-
"protocol": "TCP",
1604-
"targetPort": 26256
1605-
},
1606-
{
1607-
"name": "cometbft-2-6-gw",
1608-
"port": 26266,
1609-
"protocol": "TCP",
1610-
"targetPort": 26266
1611-
},
1612-
{
1613-
"name": "cometbft-2-7-gw",
1614-
"port": 26276,
1615-
"protocol": "TCP",
1616-
"targetPort": 26276
1617-
},
1618-
{
1619-
"name": "cometbft-2-8-gw",
1620-
"port": 26286,
1621-
"protocol": "TCP",
1622-
"targetPort": 26286
1623-
},
1624-
{
1625-
"name": "cometbft-2-9-gw",
1626-
"port": 26296,
1627-
"protocol": "TCP",
1628-
"targetPort": 26296
1629-
},
16301450
{
16311451
"name": "cometbft-3-0-gw",
16321452
"port": 26306,
@@ -1639,54 +1459,6 @@
16391459
"protocol": "TCP",
16401460
"targetPort": 26316
16411461
},
1642-
{
1643-
"name": "cometbft-3-2-gw",
1644-
"port": 26326,
1645-
"protocol": "TCP",
1646-
"targetPort": 26326
1647-
},
1648-
{
1649-
"name": "cometbft-3-3-gw",
1650-
"port": 26336,
1651-
"protocol": "TCP",
1652-
"targetPort": 26336
1653-
},
1654-
{
1655-
"name": "cometbft-3-4-gw",
1656-
"port": 26346,
1657-
"protocol": "TCP",
1658-
"targetPort": 26346
1659-
},
1660-
{
1661-
"name": "cometbft-3-5-gw",
1662-
"port": 26356,
1663-
"protocol": "TCP",
1664-
"targetPort": 26356
1665-
},
1666-
{
1667-
"name": "cometbft-3-6-gw",
1668-
"port": 26366,
1669-
"protocol": "TCP",
1670-
"targetPort": 26366
1671-
},
1672-
{
1673-
"name": "cometbft-3-7-gw",
1674-
"port": 26376,
1675-
"protocol": "TCP",
1676-
"targetPort": 26376
1677-
},
1678-
{
1679-
"name": "cometbft-3-8-gw",
1680-
"port": 26386,
1681-
"protocol": "TCP",
1682-
"targetPort": 26386
1683-
},
1684-
{
1685-
"name": "cometbft-3-9-gw",
1686-
"port": 26396,
1687-
"protocol": "TCP",
1688-
"targetPort": 26396
1689-
},
16901462
{
16911463
"name": "cometbft-4-0-gw",
16921464
"port": 26406,
@@ -1698,54 +1470,6 @@
16981470
"port": 26416,
16991471
"protocol": "TCP",
17001472
"targetPort": 26416
1701-
},
1702-
{
1703-
"name": "cometbft-4-2-gw",
1704-
"port": 26426,
1705-
"protocol": "TCP",
1706-
"targetPort": 26426
1707-
},
1708-
{
1709-
"name": "cometbft-4-3-gw",
1710-
"port": 26436,
1711-
"protocol": "TCP",
1712-
"targetPort": 26436
1713-
},
1714-
{
1715-
"name": "cometbft-4-4-gw",
1716-
"port": 26446,
1717-
"protocol": "TCP",
1718-
"targetPort": 26446
1719-
},
1720-
{
1721-
"name": "cometbft-4-5-gw",
1722-
"port": 26456,
1723-
"protocol": "TCP",
1724-
"targetPort": 26456
1725-
},
1726-
{
1727-
"name": "cometbft-4-6-gw",
1728-
"port": 26466,
1729-
"protocol": "TCP",
1730-
"targetPort": 26466
1731-
},
1732-
{
1733-
"name": "cometbft-4-7-gw",
1734-
"port": 26476,
1735-
"protocol": "TCP",
1736-
"targetPort": 26476
1737-
},
1738-
{
1739-
"name": "cometbft-4-8-gw",
1740-
"port": 26486,
1741-
"protocol": "TCP",
1742-
"targetPort": 26486
1743-
},
1744-
{
1745-
"name": "cometbft-4-9-gw",
1746-
"port": 26496,
1747-
"protocol": "TCP",
1748-
"targetPort": 26496
17491473
}
17501474
]
17511475
},

cluster/pulumi/common-sv/src/synchronizer/cometBftNodeConfigs.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export class CometBftNodeConfigs {
3737
privateKey: staticConf.privateKey,
3838
identifier: this.nodeIdentifier,
3939
externalAddress: this.p2pExternalAddress(staticConf.nodeIndex),
40-
istioPort: this.istioExternalPort(staticConf.nodeIndex),
40+
istioPort: istioCometbftExternalPort(this._domainMigrationId, staticConf.nodeIndex),
4141
retainBlocks: staticConf.retainBlocks,
4242
validator: staticConf.validator,
4343
};
@@ -82,13 +82,13 @@ export class CometBftNodeConfigs {
8282
}
8383

8484
private p2pExternalAddress(nodeIndex: number): string {
85-
return `${CLUSTER_HOSTNAME}:${this.istioExternalPort(nodeIndex)}`;
86-
}
87-
88-
private istioExternalPort(nodeIndex: number) {
89-
// TODO(#10482) Revisit port scheme
90-
return nodeIndex >= 10
91-
? Number(`26${this._domainMigrationId}${nodeIndex}`)
92-
: Number(`26${this._domainMigrationId}${nodeIndex}6`);
85+
return `${CLUSTER_HOSTNAME}:${istioCometbftExternalPort(this._domainMigrationId, nodeIndex)}`;
9386
}
9487
}
88+
89+
export const istioCometbftExternalPort = (migrationId: number, nodeIndex: number): number => {
90+
// TODO(DACH-NY/canton-network-node#10482) Revisit port scheme
91+
return nodeIndex >= 10
92+
? Number(`26${migrationId}${nodeIndex}`)
93+
: Number(`26${migrationId}${nodeIndex}6`);
94+
};

cluster/pulumi/infra/src/istio.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
import * as k8s from '@pulumi/kubernetes';
44
import * as pulumi from '@pulumi/pulumi';
55
import { local } from '@pulumi/command';
6+
import { dsoSize, istioCometbftExternalPort } from 'splice-pulumi-common-sv';
67
import { spliceConfig } from 'splice-pulumi-common/src/config/config';
78
import { PodMonitor, ServiceMonitor } from 'splice-pulumi-common/src/metrics';
89

910
import {
1011
activeVersion,
1112
DecentralizedSynchronizerUpgradeConfig,
13+
DeploySvRunbook,
1214
ExactNamespace,
1315
getDnsNames,
1416
HELM_MAX_HISTORY_SIZE,
@@ -156,13 +158,18 @@ function configureInternalGatewayService(
156158
) {
157159
const externalIPRanges = loadIPRanges();
158160
// see notes when installing a CometBft node in the full deployment
159-
const cometBftIngressPorts = Array.from(
160-
Array(DecentralizedSynchronizerUpgradeConfig.highestMigrationId + 1).keys()
161-
).flatMap((domain: number) => {
162-
return Array.from(Array(10).keys()).map(node => {
163-
return ingressPort(`cometbft-${domain}-${node}-gw`, Number(`26${domain}${node}6`));
161+
const cometBftIngressPorts = DecentralizedSynchronizerUpgradeConfig.runningMigrations()
162+
.map(migrationInfo => migrationInfo.id)
163+
.flatMap((domain: number) => {
164+
return (DeploySvRunbook ? [0] : [])
165+
.concat(Array.from(Array(dsoSize).keys()).map(n => n + 1))
166+
.map(node => {
167+
return ingressPort(
168+
`cometbft-${domain}-${node}-gw`,
169+
istioCometbftExternalPort(domain, node)
170+
);
171+
});
164172
});
165-
});
166173
return configureGatewayService(
167174
ingressNs,
168175
ingressIp,

0 commit comments

Comments
 (0)