@crossdelta/infrastructure 0.6.2 → 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 CHANGED
@@ -1177,6 +1177,26 @@ function createVPC(config) {
1177
1177
  // lib/runtimes/doks/workloads.ts
1178
1178
  var k8s6 = __toESM(require("@pulumi/kubernetes"));
1179
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
1180
1200
  var normalizeK8sConfig = (config) => {
1181
1201
  if (config.ports) {
1182
1202
  return config;
@@ -1295,24 +1315,11 @@ var createServiceVolumes = (provider, namespace, config, labels) => {
1295
1315
  }));
1296
1316
  return { pvcs, volumeMounts, volumes };
1297
1317
  };
1298
- var buildHealthProbes = (config) => {
1318
+ var buildHealthProbes2 = (config) => {
1299
1319
  if (!config.healthCheck) {
1300
1320
  return {};
1301
1321
  }
1302
- const { healthCheck } = config;
1303
- const probeConfig = {
1304
- initialDelaySeconds: healthCheck.initialDelaySeconds ?? DEFAULTS.healthCheck.initialDelaySeconds,
1305
- periodSeconds: healthCheck.periodSeconds ?? DEFAULTS.healthCheck.periodSeconds,
1306
- failureThreshold: healthCheck.failureThreshold ?? DEFAULTS.healthCheck.failureThreshold,
1307
- successThreshold: healthCheck.successThreshold ?? DEFAULTS.healthCheck.successThreshold,
1308
- timeoutSeconds: healthCheck.timeoutSeconds ?? DEFAULTS.healthCheck.timeoutSeconds
1309
- };
1310
- const port = healthCheck.port ?? config.ports.primary.port;
1311
- const probe = healthCheck.httpPath ? { httpGet: { path: healthCheck.httpPath, port } } : { tcpSocket: { port } };
1312
- return {
1313
- livenessProbe: { ...probeConfig, ...probe },
1314
- readinessProbe: { ...probeConfig, ...probe }
1315
- };
1322
+ return buildHealthProbes(config.healthCheck, config.ports.primary.port, DEFAULTS.healthCheck);
1316
1323
  };
1317
1324
  var buildContainerPorts = (config) => {
1318
1325
  const normalizeProtocol = (protocol) => protocol === "HTTP" || protocol === "HTTPS" || protocol === "GRPC" ? "TCP" : protocol ?? "TCP";
@@ -1411,7 +1418,7 @@ var deployK8sService = (provider, namespace, config) => {
1411
1418
  const secret = createServiceSecret(provider, namespace, normalizedConfig, labels);
1412
1419
  const envVars = buildEnvVars(normalizedConfig);
1413
1420
  const { pvcs, volumeMounts, volumes } = createServiceVolumes(provider, namespace, normalizedConfig, labels);
1414
- const { livenessProbe, readinessProbe } = buildHealthProbes(normalizedConfig);
1421
+ const { livenessProbe, readinessProbe } = buildHealthProbes2(normalizedConfig);
1415
1422
  const containerPorts = buildContainerPorts(normalizedConfig);
1416
1423
  const servicePorts = buildServicePorts(normalizedConfig);
1417
1424
  const deployment = new k8s6.apps.v1.Deployment(`${normalizedConfig.name}-deployment`, {
package/dist/index.js CHANGED
@@ -1083,6 +1083,26 @@ function createVPC(config) {
1083
1083
  // lib/runtimes/doks/workloads.ts
1084
1084
  import * as k8s6 from "@pulumi/kubernetes";
1085
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
1086
1106
  var normalizeK8sConfig = (config) => {
1087
1107
  if (config.ports) {
1088
1108
  return config;
@@ -1201,24 +1221,11 @@ var createServiceVolumes = (provider, namespace, config, labels) => {
1201
1221
  }));
1202
1222
  return { pvcs, volumeMounts, volumes };
1203
1223
  };
1204
- var buildHealthProbes = (config) => {
1224
+ var buildHealthProbes2 = (config) => {
1205
1225
  if (!config.healthCheck) {
1206
1226
  return {};
1207
1227
  }
1208
- const { healthCheck } = config;
1209
- const probeConfig = {
1210
- initialDelaySeconds: healthCheck.initialDelaySeconds ?? DEFAULTS.healthCheck.initialDelaySeconds,
1211
- periodSeconds: healthCheck.periodSeconds ?? DEFAULTS.healthCheck.periodSeconds,
1212
- failureThreshold: healthCheck.failureThreshold ?? DEFAULTS.healthCheck.failureThreshold,
1213
- successThreshold: healthCheck.successThreshold ?? DEFAULTS.healthCheck.successThreshold,
1214
- timeoutSeconds: healthCheck.timeoutSeconds ?? DEFAULTS.healthCheck.timeoutSeconds
1215
- };
1216
- const port = healthCheck.port ?? config.ports.primary.port;
1217
- const probe = healthCheck.httpPath ? { httpGet: { path: healthCheck.httpPath, port } } : { tcpSocket: { port } };
1218
- return {
1219
- livenessProbe: { ...probeConfig, ...probe },
1220
- readinessProbe: { ...probeConfig, ...probe }
1221
- };
1228
+ return buildHealthProbes(config.healthCheck, config.ports.primary.port, DEFAULTS.healthCheck);
1222
1229
  };
1223
1230
  var buildContainerPorts = (config) => {
1224
1231
  const normalizeProtocol = (protocol) => protocol === "HTTP" || protocol === "HTTPS" || protocol === "GRPC" ? "TCP" : protocol ?? "TCP";
@@ -1317,7 +1324,7 @@ var deployK8sService = (provider, namespace, config) => {
1317
1324
  const secret = createServiceSecret(provider, namespace, normalizedConfig, labels);
1318
1325
  const envVars = buildEnvVars(normalizedConfig);
1319
1326
  const { pvcs, volumeMounts, volumes } = createServiceVolumes(provider, namespace, normalizedConfig, labels);
1320
- const { livenessProbe, readinessProbe } = buildHealthProbes(normalizedConfig);
1327
+ const { livenessProbe, readinessProbe } = buildHealthProbes2(normalizedConfig);
1321
1328
  const containerPorts = buildContainerPorts(normalizedConfig);
1322
1329
  const servicePorts = buildServicePorts(normalizedConfig);
1323
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 health check (e.g., '/health') */
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) */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crossdelta/infrastructure",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "publishConfig": {