Skip to content

Commit

Permalink
fix service port handling
Browse files Browse the repository at this point in the history
  • Loading branch information
jensens committed Jun 28, 2024
1 parent f2115ed commit aee4466
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 18 deletions.
22 changes: 22 additions & 0 deletions API.md

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

18 changes: 18 additions & 0 deletions src/deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ export interface PloneDeploymentOptions {
*/
readonly replicas?: number;

/**
* CPU limit
* @default 1
*/
readonly limitCpu?: number;

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

/**
* Port number.
*/
Expand Down Expand Up @@ -100,6 +112,12 @@ export class PloneDeployment extends Construct {
imagePullPolicy: image.imagePullPolicy,
env: env,
envFrom: envFrom,
resources: {
limits: {
cpu: k8s.Quantity.fromNumber(options.limitCpu ?? 1),
memory: k8s.Quantity.fromString(options.limitMemory ?? '1Gi'),
},
},
};
const deploymentOptions: k8s.KubeDeploymentProps = {
metadata: {
Expand Down
6 changes: 6 additions & 0 deletions src/plone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export interface PloneBaseOptions {
readonly replicas?: number;
readonly maxUnavailable?: number | string;
readonly minAvailable?: number | string;
readonly limitCpu?: number;
readonly limitMemory?: string;
readonly environment?: kplus.Env;
}
export interface PloneOptions {
Expand All @@ -36,6 +38,8 @@ export class Plone extends Construct {
imagePullPolicy: backend.imagePullPolicy ?? 'IfNotPresent',
},
replicas: backend.replicas,
limitCpu: backend.limitCpu ?? 1,
limitMemory: backend.limitMemory ?? '512Mi',
pdb: {
maxUnavailable: backend.maxUnavailable ?? undefined,
minAvailable: backend.minAvailable ?? undefined,
Expand Down Expand Up @@ -64,6 +68,8 @@ export class Plone extends Construct {
imagePullPolicy: frontend.imagePullPolicy ?? 'IfNotPresent',
},
replicas: frontend.replicas,
limitCpu: frontend.limitCpu ?? 1,
limitMemory: frontend.limitMemory ?? '1Gi',
pdb: {
maxUnavailable: frontend.maxUnavailable ?? undefined,
minAvailable: frontend.minAvailable ?? undefined,
Expand Down
4 changes: 1 addition & 3 deletions src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ export class PloneService extends Construct {
labels: options.labels ?? {},
},
spec: {
type: 'ClusterIP',
clusterIp: 'None',
ports: [{ port: 80, targetPort: targetPort }],
ports: [{ port: options.targetPort, targetPort: targetPort, name: 'backend-http' }],
selector: selectorLabel,
},
};
Expand Down
12 changes: 12 additions & 0 deletions test/__snapshots__/deployment.test.ts.snap

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

44 changes: 32 additions & 12 deletions test/__snapshots__/plone.test.ts.snap

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

5 changes: 2 additions & 3 deletions test/__snapshots__/service.test.ts.snap

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

0 comments on commit aee4466

Please sign in to comment.