Skip to content

Commit

Permalink
feature: set resource requests
Browse files Browse the repository at this point in the history
  • Loading branch information
jensens committed Aug 1, 2024
1 parent a9ac5e2 commit 00da868
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 14 deletions.
20 changes: 18 additions & 2 deletions src/deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,26 @@ export interface PloneDeploymentOptions {
* CPU limit
* @default 1
*/
readonly limitCpu?: number;
readonly limitCpu?: string;

/**
* memory limit
* @default 1
*/
readonly limitMemory?: string;

/**
* CPU request
* @default 1
*/
readonly requestCpu?: string;

/**
* memory request
* @default 1
*/
readonly requestMemory?: string;

/**
* Port number.
*/
Expand Down Expand Up @@ -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 ?? {},
Expand Down
13 changes: 10 additions & 3 deletions src/plone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
30 changes: 25 additions & 5 deletions test/__snapshots__/deployment.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 20 additions & 4 deletions test/__snapshots__/plone.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 00da868

Please sign in to comment.