diff --git a/deploy/deploy.schema.json b/deploy/deploy.schema.json index 645c83ec..b77b0852 100644 --- a/deploy/deploy.schema.json +++ b/deploy/deploy.schema.json @@ -604,6 +604,25 @@ "required": ["enabled", "serviceName", "endpointAddress", "port"], "properties": { "enabled": { "type": "boolean" }, + "serviceName": { + "type": "string", + "minLength": 1, + "maxLength": 63, + "pattern": "^[a-z0-9]([-a-z0-9]*[a-z0-9])?$" + }, + "endpointAddress": { "type": "string", "minLength": 1 }, + "port": { "type": "integer", "minimum": 1, "maximum": 65535 }, + "nodes": { + "type": "object", + "additionalProperties": { "$ref": "#/$defs/externalPostgresNodeOverride" } + } + }, + "additionalProperties": false + }, + "externalPostgresNodeOverride": { + "type": "object", + "required": ["serviceName", "endpointAddress", "port"], + "properties": { "serviceName": { "type": "string", "minLength": 1, diff --git a/deploy/deploy.yaml b/deploy/deploy.yaml index b3be688c..8abaa6e6 100644 --- a/deploy/deploy.yaml +++ b/deploy/deploy.yaml @@ -384,6 +384,11 @@ lanes: serviceName: jd01-pk01-platform-postgres endpointAddress: 82.156.23.220 port: 5432 + nodes: + NC01: + serviceName: nc01-host-postgres + endpointAddress: 10.42.0.1 + port: 5432 runtimeStore: postgres: image: postgres:16-alpine diff --git a/scripts/gitops-render.mjs b/scripts/gitops-render.mjs index 27c74a3e..14be4803 100644 --- a/scripts/gitops-render.mjs +++ b/scripts/gitops-render.mjs @@ -5150,15 +5150,18 @@ function v02PostgresManifest({ profile = "v02", migrationSql, source, image = "p }; } -function externalPostgresConfigForLane(deploy, profile) { +function externalPostgresConfigForLane(deploy, profile, args = {}) { if (!isRuntimeLane(profile)) return null; const config = deploy?.lanes?.[profile]?.externalPostgres; if (!config || config.enabled !== true) return null; - assert.ok(typeof config.serviceName === "string" && config.serviceName.length > 0, `deploy.lanes.${profile}.externalPostgres.serviceName is required`); - assert.ok(typeof config.endpointAddress === "string" && config.endpointAddress.length > 0, `deploy.lanes.${profile}.externalPostgres.endpointAddress is required`); - const port = Number(config.port ?? 5432); + const nodeId = effectiveSecretPlaneNodeId(args); + const nodeConfig = nodeId ? config?.nodes?.[nodeId] : null; + const effective = nodeConfig && typeof nodeConfig === "object" && !Array.isArray(nodeConfig) ? { ...config, ...nodeConfig } : config; + assert.ok(typeof effective.serviceName === "string" && effective.serviceName.length > 0, `deploy.lanes.${profile}.externalPostgres.serviceName is required`); + assert.ok(typeof effective.endpointAddress === "string" && effective.endpointAddress.length > 0, `deploy.lanes.${profile}.externalPostgres.endpointAddress is required`); + const port = Number(effective.port ?? 5432); assert.ok(Number.isInteger(port) && port > 0 && port <= 65535, `deploy.lanes.${profile}.externalPostgres.port must be a valid TCP port`); - return { serviceName: config.serviceName, endpointAddress: config.endpointAddress, port }; + return { serviceName: effective.serviceName, endpointAddress: effective.endpointAddress, port }; } function externalPostgresManifest({ profile = "v03", config, source }) { @@ -5960,7 +5963,7 @@ async function plannedFiles(args) { for (const profile of profiles) { const namespace = namespaceNameForProfile(profile); const includeDeviceAgent = profile === "dev"; - const externalPostgres = externalPostgresConfigForLane(deploy, profile); + const externalPostgres = externalPostgresConfigForLane(deploy, profile, args); const workbenchRedis = workbenchRuntimeRedisConfigForProfile(deploy, profile); const runtimeConfigMaps = runtimeConfigMapsForProfile(deploy, profile); const runtimeSecretPlane = await runtimeSecretPlaneConfigForProfile(deploy, profile, args);