diff --git a/API.md b/API.md index 73eea2a..7028885 100644 --- a/API.md +++ b/API.md @@ -304,6 +304,7 @@ const ploneBaseOptions: PloneBaseOptions = { ... } | imagePullPolicy | string | *No description.* | | limitCpu | string | *No description.* | | limitMemory | string | *No description.* | +| livenessEnabled | boolean | *No description.* | | livenessFailureThreshold | number | *No description.* | | livenessIimeoutSeconds | number | *No description.* | | livenessInitialDelaySeconds | number | *No description.* | @@ -311,6 +312,7 @@ const ploneBaseOptions: PloneBaseOptions = { ... } | livenessSuccessThreshold | number | *No description.* | | maxUnavailable | string \| number | *No description.* | | minAvailable | string \| number | *No description.* | +| readinessEnabled | boolean | *No description.* | | readinessFailureThreshold | number | *No description.* | | readinessIimeoutSeconds | number | *No description.* | | readinessInitialDelaySeconds | number | *No description.* | @@ -372,6 +374,16 @@ public readonly limitMemory: string; --- +##### `livenessEnabled`Optional + +```typescript +public readonly livenessEnabled: boolean; +``` + +- *Type:* boolean + +--- + ##### `livenessFailureThreshold`Optional ```typescript @@ -442,6 +454,16 @@ public readonly minAvailable: string | number; --- +##### `readinessEnabled`Optional + +```typescript +public readonly readinessEnabled: boolean; +``` + +- *Type:* boolean + +--- + ##### `readinessFailureThreshold`Optional ```typescript diff --git a/src/plone.ts b/src/plone.ts index 2b76d22..3c8a132 100644 --- a/src/plone.ts +++ b/src/plone.ts @@ -21,12 +21,14 @@ export interface PloneBaseOptions { readonly requestMemory?: string; readonly environment?: kplus.Env; // readiness Probe + readonly readinessEnabled?: boolean; readonly readinessInitialDelaySeconds?: number; readonly readinessIimeoutSeconds?: number; readonly readinessPeriodSeconds?: number; readonly readinessSuccessThreshold?: number; readonly readinessFailureThreshold?: number; // liveness Probe + readonly livenessEnabled?: boolean; readonly livenessInitialDelaySeconds?: number; readonly livenessIimeoutSeconds?: number; readonly livenessPeriodSeconds?: number; @@ -83,24 +85,28 @@ export class Plone extends Construct { path: '/', port: IntOrString.fromNumber(backendPort), }; - - const backendLivenessProbe: Probe = { - httpGet: backendActionHttpGet, - initialDelaySeconds: backend.livenessInitialDelaySeconds ?? 30, - timeoutSeconds: backend.livenessIimeoutSeconds ?? 5, - periodSeconds: backend.livenessPeriodSeconds ?? 10, - successThreshold: backend.livenessSuccessThreshold ?? 1, - failureThreshold: backend.livenessFailureThreshold ?? 3, - }; - const backendReadinessProbe: Probe = { - httpGet: backendActionHttpGet, - initialDelaySeconds: backend.readinessInitialDelaySeconds ?? 10, - timeoutSeconds: backend.readinessIimeoutSeconds ?? 15, - periodSeconds: backend.readinessPeriodSeconds ?? 10, - successThreshold: backend.readinessSuccessThreshold ?? 1, - failureThreshold: backend.readinessFailureThreshold ?? 3, - }; - + var backendLivenessProbe: Probe | undefined = undefined; + if (backend.livenessEnabled ?? false) { + backendLivenessProbe = { + httpGet: backendActionHttpGet, + initialDelaySeconds: backend.livenessInitialDelaySeconds ?? 30, + timeoutSeconds: backend.livenessIimeoutSeconds ?? 5, + periodSeconds: backend.livenessPeriodSeconds ?? 10, + successThreshold: backend.livenessSuccessThreshold ?? 1, + failureThreshold: backend.livenessFailureThreshold ?? 3, + }; + } + var backendReadinessProbe: Probe | undefined = undefined; + if (backend.readinessEnabled ?? true) { + backendReadinessProbe = { + httpGet: backendActionHttpGet, + initialDelaySeconds: backend.readinessInitialDelaySeconds ?? 10, + timeoutSeconds: backend.readinessIimeoutSeconds ?? 15, + periodSeconds: backend.readinessPeriodSeconds ?? 10, + successThreshold: backend.readinessSuccessThreshold ?? 1, + failureThreshold: backend.readinessFailureThreshold ?? 3, + }; + } // Deployment const backendDeployment = new PloneDeployment(this, 'backend', { labels: backendLabels, @@ -151,22 +157,28 @@ export class Plone extends Construct { path: '/', port: IntOrString.fromNumber(frontendPort), }; - const frontendLivenessProbe: Probe = { - httpGet: frontendActionHttpGet, - initialDelaySeconds: frontend.livenessInitialDelaySeconds ?? 30, - timeoutSeconds: frontend.livenessIimeoutSeconds ?? 5, - periodSeconds: frontend.livenessPeriodSeconds ?? 10, - successThreshold: frontend.livenessSuccessThreshold ?? 1, - failureThreshold: frontend.livenessFailureThreshold ?? 3, - }; - const frontendReadinessProbe: Probe = { - httpGet: frontendActionHttpGet, - initialDelaySeconds: frontend.readinessInitialDelaySeconds ?? 10, - timeoutSeconds: frontend.readinessIimeoutSeconds ?? 15, - periodSeconds: frontend.readinessPeriodSeconds ?? 10, - successThreshold: frontend.readinessSuccessThreshold ?? 1, - failureThreshold: frontend.readinessFailureThreshold ?? 3, - }; + var frontendLivenessProbe: Probe | undefined = undefined; + if (frontend.livenessEnabled ?? false) { + frontendLivenessProbe = { + httpGet: frontendActionHttpGet, + initialDelaySeconds: frontend.livenessInitialDelaySeconds ?? 30, + timeoutSeconds: frontend.livenessIimeoutSeconds ?? 5, + periodSeconds: frontend.livenessPeriodSeconds ?? 10, + successThreshold: frontend.livenessSuccessThreshold ?? 1, + failureThreshold: frontend.livenessFailureThreshold ?? 3, + }; + } + var frontendReadinessProbe: Probe | undefined = undefined; + if (frontend.readinessEnabled ?? true) { + frontendReadinessProbe = { + httpGet: frontendActionHttpGet, + initialDelaySeconds: frontend.readinessInitialDelaySeconds ?? 10, + timeoutSeconds: frontend.readinessIimeoutSeconds ?? 15, + periodSeconds: frontend.readinessPeriodSeconds ?? 10, + successThreshold: frontend.readinessSuccessThreshold ?? 1, + failureThreshold: frontend.readinessFailureThreshold ?? 3, + }; + } // Environment for RAZZLE var frontendEnvironment = frontend.environment ?? new kplus.Env([], {}); diff --git a/test/__snapshots__/httpcache.test.ts.snap b/test/__snapshots__/httpcache.test.ts.snap index beca9a5..11dcafc 100644 --- a/test/__snapshots__/httpcache.test.ts.snap +++ b/test/__snapshots__/httpcache.test.ts.snap @@ -37,17 +37,7 @@ exports[`defaults 1`] = ` "envFrom": [], "image": "plone/plone-backend:latest", "imagePullPolicy": "IfNotPresent", - "livenessProbe": { - "failureThreshold": 3, - "httpGet": { - "path": "/", - "port": 8080, - }, - "initialDelaySeconds": 30, - "periodSeconds": 10, - "successThreshold": 1, - "timeoutSeconds": 5, - }, + "livenessProbe": {}, "name": "backend-container", "readinessProbe": { "failureThreshold": 3, @@ -161,17 +151,7 @@ exports[`defaults 1`] = ` "envFrom": [], "image": "plone/plone-frontend:latest", "imagePullPolicy": "IfNotPresent", - "livenessProbe": { - "failureThreshold": 3, - "httpGet": { - "path": "/", - "port": 3000, - }, - "initialDelaySeconds": 30, - "periodSeconds": 10, - "successThreshold": 1, - "timeoutSeconds": 5, - }, + "livenessProbe": {}, "name": "frontend-container", "readinessProbe": { "failureThreshold": 3, diff --git a/test/__snapshots__/plone.test.ts.snap b/test/__snapshots__/plone.test.ts.snap index aa266ec..ef4d3c7 100644 --- a/test/__snapshots__/plone.test.ts.snap +++ b/test/__snapshots__/plone.test.ts.snap @@ -37,17 +37,7 @@ exports[`defaults 1`] = ` "envFrom": [], "image": "plone/plone-backend:latest", "imagePullPolicy": "IfNotPresent", - "livenessProbe": { - "failureThreshold": 3, - "httpGet": { - "path": "/", - "port": 8080, - }, - "initialDelaySeconds": 30, - "periodSeconds": 10, - "successThreshold": 1, - "timeoutSeconds": 5, - }, + "livenessProbe": {}, "name": "backend-container", "readinessProbe": { "failureThreshold": 3, @@ -161,17 +151,7 @@ exports[`defaults 1`] = ` "envFrom": [], "image": "plone/plone-frontend:latest", "imagePullPolicy": "IfNotPresent", - "livenessProbe": { - "failureThreshold": 3, - "httpGet": { - "path": "/", - "port": 3000, - }, - "initialDelaySeconds": 30, - "periodSeconds": 10, - "successThreshold": 1, - "timeoutSeconds": 5, - }, + "livenessProbe": {}, "name": "frontend-container", "readinessProbe": { "failureThreshold": 3, @@ -285,17 +265,7 @@ exports[`defaults-classicui 1`] = ` "envFrom": [], "image": "plone/plone-backend:latest", "imagePullPolicy": "IfNotPresent", - "livenessProbe": { - "failureThreshold": 3, - "httpGet": { - "path": "/", - "port": 8080, - }, - "initialDelaySeconds": 30, - "periodSeconds": 10, - "successThreshold": 1, - "timeoutSeconds": 5, - }, + "livenessProbe": {}, "name": "backend-container", "readinessProbe": { "failureThreshold": 3, @@ -409,17 +379,7 @@ exports[`defaults-with-pdps 1`] = ` "envFrom": [], "image": "plone/plone-backend:latest", "imagePullPolicy": "IfNotPresent", - "livenessProbe": { - "failureThreshold": 3, - "httpGet": { - "path": "/", - "port": 8080, - }, - "initialDelaySeconds": 30, - "periodSeconds": 10, - "successThreshold": 1, - "timeoutSeconds": 5, - }, + "livenessProbe": {}, "name": "backend-container", "readinessProbe": { "failureThreshold": 3, @@ -533,17 +493,7 @@ exports[`defaults-with-pdps 1`] = ` "envFrom": [], "image": "plone/plone-frontend:latest", "imagePullPolicy": "IfNotPresent", - "livenessProbe": { - "failureThreshold": 3, - "httpGet": { - "path": "/", - "port": 3000, - }, - "initialDelaySeconds": 30, - "periodSeconds": 10, - "successThreshold": 1, - "timeoutSeconds": 5, - }, + "livenessProbe": {}, "name": "frontend-container", "readinessProbe": { "failureThreshold": 3,