@crossdelta/infrastructure 0.6.1 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +31 -19
- package/dist/index.js +31 -19
- package/dist/runtimes/doks/probes.d.ts +32 -0
- package/dist/runtimes/doks/types.d.ts +3 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -970,21 +970,26 @@ var resolveStreams = (definitions, policies = {}, defaults = DEFAULT_POLICY) =>
|
|
|
970
970
|
var generateSetupScript = (streams) => {
|
|
971
971
|
const streamCommands = streams.map((s) => {
|
|
972
972
|
const subjects = s.subjects.join(",");
|
|
973
|
-
const
|
|
973
|
+
const addArgs = [
|
|
974
974
|
`--retention ${s.retention}`,
|
|
975
975
|
`--storage ${s.storage}`,
|
|
976
976
|
`--max-age ${s.maxAge}`,
|
|
977
977
|
`--replicas ${s.replicas}`,
|
|
978
978
|
`--max-msg-size ${s.maxMsgSize}`
|
|
979
979
|
].join(" ");
|
|
980
|
+
const editArgs = [
|
|
981
|
+
`--max-age ${s.maxAge}`,
|
|
982
|
+
`--replicas ${s.replicas}`,
|
|
983
|
+
`--max-msg-size ${s.maxMsgSize}`
|
|
984
|
+
].join(" ");
|
|
980
985
|
return [
|
|
981
986
|
`echo "Processing stream: ${s.stream} (${subjects})"`,
|
|
982
987
|
`if nats $NATS_OPTS stream info "${s.stream}" > /dev/null 2>&1; then`,
|
|
983
988
|
` echo " Updating existing stream..."`,
|
|
984
|
-
` nats $NATS_OPTS stream edit "${s.stream}" --subjects "${subjects}" ${
|
|
989
|
+
` nats $NATS_OPTS stream edit "${s.stream}" --subjects "${subjects}" ${editArgs} --force`,
|
|
985
990
|
`else`,
|
|
986
991
|
` echo " Creating new stream..."`,
|
|
987
|
-
` nats $NATS_OPTS stream add "${s.stream}" --subjects "${subjects}" ${
|
|
992
|
+
` nats $NATS_OPTS stream add "${s.stream}" --subjects "${subjects}" ${addArgs} --defaults`,
|
|
988
993
|
`fi`,
|
|
989
994
|
`echo " ✅ ${s.stream} ready"`,
|
|
990
995
|
``
|
|
@@ -1172,6 +1177,26 @@ function createVPC(config) {
|
|
|
1172
1177
|
// lib/runtimes/doks/workloads.ts
|
|
1173
1178
|
var k8s6 = __toESM(require("@pulumi/kubernetes"));
|
|
1174
1179
|
var pulumi6 = __toESM(require("@pulumi/pulumi"));
|
|
1180
|
+
|
|
1181
|
+
// lib/runtimes/doks/probes.ts
|
|
1182
|
+
var buildProbe = (path, port, config) => path ? { ...config, httpGet: { path, port } } : { ...config, tcpSocket: { port } };
|
|
1183
|
+
var buildHealthProbes = (healthCheck, primaryPort, defaults) => {
|
|
1184
|
+
const probeConfig = {
|
|
1185
|
+
initialDelaySeconds: healthCheck.initialDelaySeconds ?? defaults.initialDelaySeconds,
|
|
1186
|
+
periodSeconds: healthCheck.periodSeconds ?? defaults.periodSeconds,
|
|
1187
|
+
failureThreshold: healthCheck.failureThreshold ?? defaults.failureThreshold,
|
|
1188
|
+
successThreshold: healthCheck.successThreshold ?? defaults.successThreshold,
|
|
1189
|
+
timeoutSeconds: healthCheck.timeoutSeconds ?? defaults.timeoutSeconds
|
|
1190
|
+
};
|
|
1191
|
+
const port = healthCheck.port ?? primaryPort;
|
|
1192
|
+
const readinessPath = healthCheck.readinessPath ?? healthCheck.httpPath;
|
|
1193
|
+
return {
|
|
1194
|
+
livenessProbe: buildProbe(healthCheck.httpPath, port, probeConfig),
|
|
1195
|
+
readinessProbe: buildProbe(readinessPath, port, probeConfig)
|
|
1196
|
+
};
|
|
1197
|
+
};
|
|
1198
|
+
|
|
1199
|
+
// lib/runtimes/doks/workloads.ts
|
|
1175
1200
|
var normalizeK8sConfig = (config) => {
|
|
1176
1201
|
if (config.ports) {
|
|
1177
1202
|
return config;
|
|
@@ -1290,24 +1315,11 @@ var createServiceVolumes = (provider, namespace, config, labels) => {
|
|
|
1290
1315
|
}));
|
|
1291
1316
|
return { pvcs, volumeMounts, volumes };
|
|
1292
1317
|
};
|
|
1293
|
-
var
|
|
1318
|
+
var buildHealthProbes2 = (config) => {
|
|
1294
1319
|
if (!config.healthCheck) {
|
|
1295
1320
|
return {};
|
|
1296
1321
|
}
|
|
1297
|
-
|
|
1298
|
-
const probeConfig = {
|
|
1299
|
-
initialDelaySeconds: healthCheck.initialDelaySeconds ?? DEFAULTS.healthCheck.initialDelaySeconds,
|
|
1300
|
-
periodSeconds: healthCheck.periodSeconds ?? DEFAULTS.healthCheck.periodSeconds,
|
|
1301
|
-
failureThreshold: healthCheck.failureThreshold ?? DEFAULTS.healthCheck.failureThreshold,
|
|
1302
|
-
successThreshold: healthCheck.successThreshold ?? DEFAULTS.healthCheck.successThreshold,
|
|
1303
|
-
timeoutSeconds: healthCheck.timeoutSeconds ?? DEFAULTS.healthCheck.timeoutSeconds
|
|
1304
|
-
};
|
|
1305
|
-
const port = healthCheck.port ?? config.ports.primary.port;
|
|
1306
|
-
const probe = healthCheck.httpPath ? { httpGet: { path: healthCheck.httpPath, port } } : { tcpSocket: { port } };
|
|
1307
|
-
return {
|
|
1308
|
-
livenessProbe: { ...probeConfig, ...probe },
|
|
1309
|
-
readinessProbe: { ...probeConfig, ...probe }
|
|
1310
|
-
};
|
|
1322
|
+
return buildHealthProbes(config.healthCheck, config.ports.primary.port, DEFAULTS.healthCheck);
|
|
1311
1323
|
};
|
|
1312
1324
|
var buildContainerPorts = (config) => {
|
|
1313
1325
|
const normalizeProtocol = (protocol) => protocol === "HTTP" || protocol === "HTTPS" || protocol === "GRPC" ? "TCP" : protocol ?? "TCP";
|
|
@@ -1406,7 +1418,7 @@ var deployK8sService = (provider, namespace, config) => {
|
|
|
1406
1418
|
const secret = createServiceSecret(provider, namespace, normalizedConfig, labels);
|
|
1407
1419
|
const envVars = buildEnvVars(normalizedConfig);
|
|
1408
1420
|
const { pvcs, volumeMounts, volumes } = createServiceVolumes(provider, namespace, normalizedConfig, labels);
|
|
1409
|
-
const { livenessProbe, readinessProbe } =
|
|
1421
|
+
const { livenessProbe, readinessProbe } = buildHealthProbes2(normalizedConfig);
|
|
1410
1422
|
const containerPorts = buildContainerPorts(normalizedConfig);
|
|
1411
1423
|
const servicePorts = buildServicePorts(normalizedConfig);
|
|
1412
1424
|
const deployment = new k8s6.apps.v1.Deployment(`${normalizedConfig.name}-deployment`, {
|
package/dist/index.js
CHANGED
|
@@ -876,21 +876,26 @@ var resolveStreams = (definitions, policies = {}, defaults = DEFAULT_POLICY) =>
|
|
|
876
876
|
var generateSetupScript = (streams) => {
|
|
877
877
|
const streamCommands = streams.map((s) => {
|
|
878
878
|
const subjects = s.subjects.join(",");
|
|
879
|
-
const
|
|
879
|
+
const addArgs = [
|
|
880
880
|
`--retention ${s.retention}`,
|
|
881
881
|
`--storage ${s.storage}`,
|
|
882
882
|
`--max-age ${s.maxAge}`,
|
|
883
883
|
`--replicas ${s.replicas}`,
|
|
884
884
|
`--max-msg-size ${s.maxMsgSize}`
|
|
885
885
|
].join(" ");
|
|
886
|
+
const editArgs = [
|
|
887
|
+
`--max-age ${s.maxAge}`,
|
|
888
|
+
`--replicas ${s.replicas}`,
|
|
889
|
+
`--max-msg-size ${s.maxMsgSize}`
|
|
890
|
+
].join(" ");
|
|
886
891
|
return [
|
|
887
892
|
`echo "Processing stream: ${s.stream} (${subjects})"`,
|
|
888
893
|
`if nats $NATS_OPTS stream info "${s.stream}" > /dev/null 2>&1; then`,
|
|
889
894
|
` echo " Updating existing stream..."`,
|
|
890
|
-
` nats $NATS_OPTS stream edit "${s.stream}" --subjects "${subjects}" ${
|
|
895
|
+
` nats $NATS_OPTS stream edit "${s.stream}" --subjects "${subjects}" ${editArgs} --force`,
|
|
891
896
|
`else`,
|
|
892
897
|
` echo " Creating new stream..."`,
|
|
893
|
-
` nats $NATS_OPTS stream add "${s.stream}" --subjects "${subjects}" ${
|
|
898
|
+
` nats $NATS_OPTS stream add "${s.stream}" --subjects "${subjects}" ${addArgs} --defaults`,
|
|
894
899
|
`fi`,
|
|
895
900
|
`echo " ✅ ${s.stream} ready"`,
|
|
896
901
|
``
|
|
@@ -1078,6 +1083,26 @@ function createVPC(config) {
|
|
|
1078
1083
|
// lib/runtimes/doks/workloads.ts
|
|
1079
1084
|
import * as k8s6 from "@pulumi/kubernetes";
|
|
1080
1085
|
import * as pulumi6 from "@pulumi/pulumi";
|
|
1086
|
+
|
|
1087
|
+
// lib/runtimes/doks/probes.ts
|
|
1088
|
+
var buildProbe = (path, port, config) => path ? { ...config, httpGet: { path, port } } : { ...config, tcpSocket: { port } };
|
|
1089
|
+
var buildHealthProbes = (healthCheck, primaryPort, defaults) => {
|
|
1090
|
+
const probeConfig = {
|
|
1091
|
+
initialDelaySeconds: healthCheck.initialDelaySeconds ?? defaults.initialDelaySeconds,
|
|
1092
|
+
periodSeconds: healthCheck.periodSeconds ?? defaults.periodSeconds,
|
|
1093
|
+
failureThreshold: healthCheck.failureThreshold ?? defaults.failureThreshold,
|
|
1094
|
+
successThreshold: healthCheck.successThreshold ?? defaults.successThreshold,
|
|
1095
|
+
timeoutSeconds: healthCheck.timeoutSeconds ?? defaults.timeoutSeconds
|
|
1096
|
+
};
|
|
1097
|
+
const port = healthCheck.port ?? primaryPort;
|
|
1098
|
+
const readinessPath = healthCheck.readinessPath ?? healthCheck.httpPath;
|
|
1099
|
+
return {
|
|
1100
|
+
livenessProbe: buildProbe(healthCheck.httpPath, port, probeConfig),
|
|
1101
|
+
readinessProbe: buildProbe(readinessPath, port, probeConfig)
|
|
1102
|
+
};
|
|
1103
|
+
};
|
|
1104
|
+
|
|
1105
|
+
// lib/runtimes/doks/workloads.ts
|
|
1081
1106
|
var normalizeK8sConfig = (config) => {
|
|
1082
1107
|
if (config.ports) {
|
|
1083
1108
|
return config;
|
|
@@ -1196,24 +1221,11 @@ var createServiceVolumes = (provider, namespace, config, labels) => {
|
|
|
1196
1221
|
}));
|
|
1197
1222
|
return { pvcs, volumeMounts, volumes };
|
|
1198
1223
|
};
|
|
1199
|
-
var
|
|
1224
|
+
var buildHealthProbes2 = (config) => {
|
|
1200
1225
|
if (!config.healthCheck) {
|
|
1201
1226
|
return {};
|
|
1202
1227
|
}
|
|
1203
|
-
|
|
1204
|
-
const probeConfig = {
|
|
1205
|
-
initialDelaySeconds: healthCheck.initialDelaySeconds ?? DEFAULTS.healthCheck.initialDelaySeconds,
|
|
1206
|
-
periodSeconds: healthCheck.periodSeconds ?? DEFAULTS.healthCheck.periodSeconds,
|
|
1207
|
-
failureThreshold: healthCheck.failureThreshold ?? DEFAULTS.healthCheck.failureThreshold,
|
|
1208
|
-
successThreshold: healthCheck.successThreshold ?? DEFAULTS.healthCheck.successThreshold,
|
|
1209
|
-
timeoutSeconds: healthCheck.timeoutSeconds ?? DEFAULTS.healthCheck.timeoutSeconds
|
|
1210
|
-
};
|
|
1211
|
-
const port = healthCheck.port ?? config.ports.primary.port;
|
|
1212
|
-
const probe = healthCheck.httpPath ? { httpGet: { path: healthCheck.httpPath, port } } : { tcpSocket: { port } };
|
|
1213
|
-
return {
|
|
1214
|
-
livenessProbe: { ...probeConfig, ...probe },
|
|
1215
|
-
readinessProbe: { ...probeConfig, ...probe }
|
|
1216
|
-
};
|
|
1228
|
+
return buildHealthProbes(config.healthCheck, config.ports.primary.port, DEFAULTS.healthCheck);
|
|
1217
1229
|
};
|
|
1218
1230
|
var buildContainerPorts = (config) => {
|
|
1219
1231
|
const normalizeProtocol = (protocol) => protocol === "HTTP" || protocol === "HTTPS" || protocol === "GRPC" ? "TCP" : protocol ?? "TCP";
|
|
@@ -1312,7 +1324,7 @@ var deployK8sService = (provider, namespace, config) => {
|
|
|
1312
1324
|
const secret = createServiceSecret(provider, namespace, normalizedConfig, labels);
|
|
1313
1325
|
const envVars = buildEnvVars(normalizedConfig);
|
|
1314
1326
|
const { pvcs, volumeMounts, volumes } = createServiceVolumes(provider, namespace, normalizedConfig, labels);
|
|
1315
|
-
const { livenessProbe, readinessProbe } =
|
|
1327
|
+
const { livenessProbe, readinessProbe } = buildHealthProbes2(normalizedConfig);
|
|
1316
1328
|
const containerPorts = buildContainerPorts(normalizedConfig);
|
|
1317
1329
|
const servicePorts = buildServicePorts(normalizedConfig);
|
|
1318
1330
|
const deployment = new k8s6.apps.v1.Deployment(`${normalizedConfig.name}-deployment`, {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { K8sHealthCheck } from './types';
|
|
2
|
+
export interface ProbeHttp {
|
|
3
|
+
httpGet: {
|
|
4
|
+
path: string;
|
|
5
|
+
port: number;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export interface ProbeTcp {
|
|
9
|
+
tcpSocket: {
|
|
10
|
+
port: number;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export interface ProbeConfig {
|
|
14
|
+
initialDelaySeconds: number;
|
|
15
|
+
periodSeconds: number;
|
|
16
|
+
failureThreshold: number;
|
|
17
|
+
successThreshold: number;
|
|
18
|
+
timeoutSeconds: number;
|
|
19
|
+
}
|
|
20
|
+
export type Probe = ProbeConfig & (ProbeHttp | ProbeTcp);
|
|
21
|
+
export interface HealthProbes {
|
|
22
|
+
livenessProbe?: Probe;
|
|
23
|
+
readinessProbe?: Probe;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Builds liveness and readiness probes from a service health check config.
|
|
27
|
+
*
|
|
28
|
+
* - `httpPath` → liveness probe
|
|
29
|
+
* - `readinessPath` → readiness probe (falls back to `httpPath` when omitted)
|
|
30
|
+
* - Neither → tcpSocket probe on the primary port
|
|
31
|
+
*/
|
|
32
|
+
export declare const buildHealthProbes: (healthCheck: K8sHealthCheck, primaryPort: number, defaults: ProbeConfig) => HealthProbes;
|
|
@@ -96,8 +96,10 @@ export interface K8sResourceConfig {
|
|
|
96
96
|
* Health check configuration for Kubernetes probes.
|
|
97
97
|
*/
|
|
98
98
|
export interface K8sHealthCheck {
|
|
99
|
-
/** HTTP path for
|
|
99
|
+
/** HTTP path for liveness probe (e.g., '/health') */
|
|
100
100
|
httpPath?: string;
|
|
101
|
+
/** HTTP path for readiness probe — if omitted, falls back to httpPath (e.g., '/health/ready') */
|
|
102
|
+
readinessPath?: string;
|
|
101
103
|
/** Port for health check (defaults to containerPort) */
|
|
102
104
|
port?: number;
|
|
103
105
|
/** Initial delay before starting probes in seconds (default: 10) */
|