diff --git a/src/deployment.ts b/src/deployment.ts index 4c82d83..30f2022 100644 --- a/src/deployment.ts +++ b/src/deployment.ts @@ -48,7 +48,7 @@ export interface PloneDeploymentOptions { * CPU limit * @default 1 */ - readonly limitCpu?: number; + readonly limitCpu?: string; /** * memory limit @@ -56,6 +56,18 @@ export interface PloneDeploymentOptions { */ readonly limitMemory?: string; + /** + * CPU request + * @default 1 + */ + readonly requestCpu?: string; + + /** + * memory request + * @default 1 + */ + readonly requestMemory?: string; + /** * Port number. */ @@ -136,9 +148,13 @@ export class PloneDeployment extends Construct { envFrom: envFrom, resources: { limits: { - cpu: k8s.Quantity.fromNumber(options.limitCpu ?? 1), + cpu: k8s.Quantity.fromString(options.limitCpu ?? '1000m'), memory: k8s.Quantity.fromString(options.limitMemory ?? '1Gi'), }, + requests: { + cpu: k8s.Quantity.fromString(options.requestCpu ?? '200m'), + memory: k8s.Quantity.fromString(options.requestMemory ?? '300Mi'), + }, }, livenessProbe: options.livenessProbe ?? {}, readinessProbe: options.readinessProbe ?? {}, diff --git a/src/plone.ts b/src/plone.ts index 6806333..4a38ec0 100644 --- a/src/plone.ts +++ b/src/plone.ts @@ -11,8 +11,10 @@ export interface PloneBaseOptions { readonly replicas?: number; readonly maxUnavailable?: number | string; readonly minAvailable?: number | string; - readonly limitCpu?: number; + readonly limitCpu?: string; readonly limitMemory?: string; + readonly requestCpu?: string; + readonly requestMemory?: string; readonly environment?: kplus.Env; } export interface PloneOptions { @@ -78,8 +80,10 @@ export class Plone extends Construct { imagePullPolicy: backend.imagePullPolicy ?? 'IfNotPresent', }, replicas: backend.replicas, - limitCpu: backend.limitCpu ?? 1, + limitCpu: backend.limitCpu ?? '500Mi', limitMemory: backend.limitMemory ?? '512Mi', + requestCpu: backend.requestCpu ?? '200Mi', + requestMemory: backend.requestMemory ?? '256Mi', pdb: { maxUnavailable: backend.maxUnavailable ?? undefined, minAvailable: backend.minAvailable ?? undefined, @@ -151,8 +155,11 @@ export class Plone extends Construct { imagePullPolicy: frontend.imagePullPolicy ?? 'IfNotPresent', }, replicas: frontend.replicas, - limitCpu: frontend.limitCpu ?? 1, + limitCpu: frontend.limitCpu ?? '500Mi', limitMemory: frontend.limitMemory ?? '1Gi', + requestCpu: backend.requestCpu ?? '200Mi', + requestMemory: backend.requestMemory ?? '256Mi', + pdb: { maxUnavailable: frontend.maxUnavailable ?? undefined, minAvailable: frontend.minAvailable ?? undefined, diff --git a/test/__snapshots__/deployment.test.ts.snap b/test/__snapshots__/deployment.test.ts.snap index 0046194..dbfd643 100644 --- a/test/__snapshots__/deployment.test.ts.snap +++ b/test/__snapshots__/deployment.test.ts.snap @@ -37,9 +37,13 @@ exports[`defaults 1`] = ` "readinessProbe": {}, "resources": { "limits": { - "cpu": 1, + "cpu": "1000m", "memory": "1Gi", }, + "requests": { + "cpu": "200m", + "memory": "300Mi", + }, }, }, ], @@ -93,9 +97,13 @@ exports[`with-environment 1`] = ` "readinessProbe": {}, "resources": { "limits": { - "cpu": 1, + "cpu": "1000m", "memory": "1Gi", }, + "requests": { + "cpu": "200m", + "memory": "300Mi", + }, }, }, ], @@ -159,9 +167,13 @@ exports[`with-environment-from-secret 1`] = ` "readinessProbe": {}, "resources": { "limits": { - "cpu": 1, + "cpu": "1000m", "memory": "1Gi", }, + "requests": { + "cpu": "200m", + "memory": "300Mi", + }, }, }, ], @@ -220,9 +232,13 @@ exports[`with-environment-valueFrom 1`] = ` "readinessProbe": {}, "resources": { "limits": { - "cpu": 1, + "cpu": "1000m", "memory": "1Gi", }, + "requests": { + "cpu": "200m", + "memory": "300Mi", + }, }, }, ], @@ -271,9 +287,13 @@ exports[`with-pdp 1`] = ` "readinessProbe": {}, "resources": { "limits": { - "cpu": 1, + "cpu": "1000m", "memory": "1Gi", }, + "requests": { + "cpu": "200m", + "memory": "300Mi", + }, }, }, ], diff --git a/test/__snapshots__/plone.test.ts.snap b/test/__snapshots__/plone.test.ts.snap index f922c08..3360c37 100644 --- a/test/__snapshots__/plone.test.ts.snap +++ b/test/__snapshots__/plone.test.ts.snap @@ -62,9 +62,13 @@ exports[`defaults 1`] = ` }, "resources": { "limits": { - "cpu": 1, + "cpu": "500Mi", "memory": "512Mi", }, + "requests": { + "cpu": "200Mi", + "memory": "256Mi", + }, }, }, ], @@ -182,9 +186,13 @@ exports[`defaults 1`] = ` }, "resources": { "limits": { - "cpu": 1, + "cpu": "500Mi", "memory": "1Gi", }, + "requests": { + "cpu": "200Mi", + "memory": "256Mi", + }, }, }, ], @@ -302,9 +310,13 @@ exports[`defaults-with-pdps 1`] = ` }, "resources": { "limits": { - "cpu": 1, + "cpu": "500Mi", "memory": "512Mi", }, + "requests": { + "cpu": "200Mi", + "memory": "256Mi", + }, }, }, ], @@ -422,9 +434,13 @@ exports[`defaults-with-pdps 1`] = ` }, "resources": { "limits": { - "cpu": 1, + "cpu": "500Mi", "memory": "1Gi", }, + "requests": { + "cpu": "200Mi", + "memory": "256Mi", + }, }, }, ],