diff --git a/examples/cron-job/__snapshots__/chart.test.ts.snap b/examples/cron-job/__snapshots__/chart.test.ts.snap index 71ede01..35aab55 100644 --- a/examples/cron-job/__snapshots__/chart.test.ts.snap +++ b/examples/cron-job/__snapshots__/chart.test.ts.snap @@ -119,6 +119,7 @@ exports[`CronJob example > Change release version 1`] = ` "name": "docker-hub-cred", }, ], + "priorityClassName": "job", "restartPolicy": "Never", }, }, @@ -250,6 +251,7 @@ exports[`CronJob example > Snapshot 1`] = ` "name": "docker-hub-cred", }, ], + "priorityClassName": "job", "restartPolicy": "Never", }, }, diff --git a/examples/job/__snapshots__/chart.test.ts.snap b/examples/job/__snapshots__/chart.test.ts.snap index 78755f8..9e6e988 100644 --- a/examples/job/__snapshots__/chart.test.ts.snap +++ b/examples/job/__snapshots__/chart.test.ts.snap @@ -116,6 +116,7 @@ exports[`Job example > Change release version 1`] = ` "name": "docker-hub-cred", }, ], + "priorityClassName": "job", "restartPolicy": "OnFailure", }, }, @@ -241,6 +242,7 @@ exports[`Job example > Snapshot 1`] = ` "name": "docker-hub-cred", }, ], + "priorityClassName": "job", "restartPolicy": "OnFailure", }, }, diff --git a/lib/cron-job/cron-job-props.ts b/lib/cron-job/cron-job-props.ts index a64d944..83fff9f 100644 --- a/lib/cron-job/cron-job-props.ts +++ b/lib/cron-job/cron-job-props.ts @@ -29,6 +29,12 @@ export interface CronJobProps */ readonly imagePullSecrets?: LocalObjectReference[]; + /** + * Pod's priority class. + * @default "job" + */ + readonly priorityClassName?: string; + /** * list of volumes that can be mounted by containers belonging to the pod. */ diff --git a/lib/cron-job/cron-job.ts b/lib/cron-job/cron-job.ts index ab73f78..c310da6 100644 --- a/lib/cron-job/cron-job.ts +++ b/lib/cron-job/cron-job.ts @@ -50,6 +50,7 @@ export class CronJob extends Construct { volumes: props.volumes, restartPolicy: props.restartPolicy, imagePullSecrets: props.imagePullSecrets, + priorityClassName: props.priorityClassName ?? "job", initContainers: props.initContainers, containers: [ { diff --git a/lib/job/job-props.ts b/lib/job/job-props.ts index d491377..76a5336 100644 --- a/lib/job/job-props.ts +++ b/lib/job/job-props.ts @@ -20,6 +20,12 @@ export interface JobProps */ readonly imagePullSecrets?: LocalObjectReference[]; + /** + * Pod's priority class. + * @default "job" + */ + readonly priorityClassName?: string; + /** * list of volumes that can be mounted by containers belonging to the pod. */ diff --git a/lib/job/job.ts b/lib/job/job.ts index 77a1a81..e418b47 100644 --- a/lib/job/job.ts +++ b/lib/job/job.ts @@ -42,6 +42,7 @@ export class Job extends Construct { volumes: props.volumes, restartPolicy: props.restartPolicy, imagePullSecrets: props.imagePullSecrets, + priorityClassName: props.priorityClassName ?? "job", initContainers: props.initContainers, containers: [ { diff --git a/package-lock.json b/package-lock.json index eda6c75..4df5135 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,8 +22,8 @@ "@typescript-eslint/parser": "^6.8.0", "bats": "^1.10.0", "c8": "^8.0.1", - "cdk8s": "^2.66.12", - "cdk8s-cli": "^2.145.0", + "cdk8s": "^2.67.0", + "cdk8s-cli": "^2.148.0", "constructs": "^10.3.0", "conventional-changelog-conventionalcommits": "^7.0.2", "eslint": "^8.51.0", @@ -3160,9 +3160,9 @@ } }, "node_modules/cdk8s": { - "version": "2.66.12", - "resolved": "https://registry.npmjs.org/cdk8s/-/cdk8s-2.66.12.tgz", - "integrity": "sha512-RwJ6vZw6ln0HK1XKIPx8ZrpkYaLphg/ZpD5RntGiEQ3loJmQOMFstzhzuakNzn5d6pFMX20VKLYNrYkwYxNV1Q==", + "version": "2.67.0", + "resolved": "https://registry.npmjs.org/cdk8s/-/cdk8s-2.67.0.tgz", + "integrity": "sha512-BLjWGhiScI7ehkjGW4dbXT4pEfD9n9qazBwASBv0CPlM7euUKzhkVo0wBWadkOKJ0gDO5fSjLMhum91ilCS87g==", "bundleDependencies": [ "fast-json-patch", "follow-redirects", @@ -3185,15 +3185,15 @@ } }, "node_modules/cdk8s-cli": { - "version": "2.145.0", - "resolved": "https://registry.npmjs.org/cdk8s-cli/-/cdk8s-cli-2.145.0.tgz", - "integrity": "sha512-mgrntnUE6EewRfC8bPMSodQBMGe0TvqyXcxMCpaswfgVNLUiTMzZ5Y/X1vViHajL2QNgbX1MGg8mbyZd22ZPHA==", + "version": "2.148.0", + "resolved": "https://registry.npmjs.org/cdk8s-cli/-/cdk8s-cli-2.148.0.tgz", + "integrity": "sha512-MidVjL5SdYP5pV4+7mzPF7XKjPidvyOrFJbV37FGG6enNeaewyOmLXgXGZpxAX3crjwpotYH/c90uOscBogRXQ==", "dev": true, "dependencies": { "@types/node": "^16", "ajv": "^8.12.0", - "cdk8s": "^2.66.11", - "cdk8s-plus-25": "^2.22.36", + "cdk8s": "^2.67.0", + "cdk8s-plus-25": "^2.22.38", "codemaker": "^1.90.0", "colors": "1.4.0", "constructs": "^10.3.0", @@ -3392,9 +3392,9 @@ } }, "node_modules/cdk8s-plus-25": { - "version": "2.22.37", - "resolved": "https://registry.npmjs.org/cdk8s-plus-25/-/cdk8s-plus-25-2.22.37.tgz", - "integrity": "sha512-3T9wCzfJVTq2d3KCSk3X9ZCgkRiz/0b4p1kXgwNSZVt42qvOg1ox48xkgY4M9XsEr+Mja+QHYVGC70LLfPm+hA==", + "version": "2.22.38", + "resolved": "https://registry.npmjs.org/cdk8s-plus-25/-/cdk8s-plus-25-2.22.38.tgz", + "integrity": "sha512-lyj4FTtS7+vPEyF51nsEq60qIesSi1tg0aYJwMzBpzZDzW/xL5HooGhPs2fMzmsiVhai1fPpFeVCM3ggNjo83A==", "bundleDependencies": [ "minimatch" ], diff --git a/package.json b/package.json index d8e9d88..953d5fe 100644 --- a/package.json +++ b/package.json @@ -50,8 +50,8 @@ "@typescript-eslint/parser": "^6.8.0", "bats": "^1.10.0", "c8": "^8.0.1", - "cdk8s": "^2.66.12", - "cdk8s-cli": "^2.145.0", + "cdk8s": "^2.67.0", + "cdk8s-cli": "^2.148.0", "constructs": "^10.3.0", "conventional-changelog-conventionalcommits": "^7.0.2", "eslint": "^8.51.0", diff --git a/test/cron-job/__snapshots__/cron-job.test.ts.snap b/test/cron-job/__snapshots__/cron-job.test.ts.snap index 6fdc171..7025e9c 100644 --- a/test/cron-job/__snapshots__/cron-job.test.ts.snap +++ b/test/cron-job/__snapshots__/cron-job.test.ts.snap @@ -125,6 +125,7 @@ exports[`CronJob > Props > All the props 1`] = ` "name": "init-container", }, ], + "priorityClassName": "high-priority-nonpreempting", "restartPolicy": "OnFailure", "volumes": [ { @@ -185,6 +186,7 @@ exports[`CronJob > Props > Minimal required props 1`] = ` }, }, ], + "priorityClassName": "job", "restartPolicy": "OnFailure", }, }, diff --git a/test/cron-job/cron-job.test.ts b/test/cron-job/cron-job.test.ts index dbd629d..2768776 100644 --- a/test/cron-job/cron-job.test.ts +++ b/test/cron-job/cron-job.test.ts @@ -74,6 +74,7 @@ describe("CronJob", () => { envFrom: [{ configMapRef: { name: "foo-config" } }], imagePullPolicy: ContainerImagePullPolicy.ALWAYS, imagePullSecrets: [{ name: "foo-secret" }], + priorityClassName: "high-priority-nonpreempting", startingDeadlineSeconds: 200, successfulJobsHistoryLimit: 4, failedJobsHistoryLimit: 2, diff --git a/test/job/__snapshots__/job.test.ts.snap b/test/job/__snapshots__/job.test.ts.snap index b85f078..608cc94 100644 --- a/test/job/__snapshots__/job.test.ts.snap +++ b/test/job/__snapshots__/job.test.ts.snap @@ -122,6 +122,7 @@ exports[`Job > Props > All the props 1`] = ` "name": "init-container", }, ], + "priorityClassName": "high-priority-nonpreempting", "restartPolicy": "Never", "volumes": [ { @@ -174,6 +175,7 @@ exports[`Job > Props > Minimal required props 1`] = ` }, }, ], + "priorityClassName": "job", "restartPolicy": "Never", }, }, diff --git a/test/job/job.test.ts b/test/job/job.test.ts index 8368dea..94f2ab4 100644 --- a/test/job/job.test.ts +++ b/test/job/job.test.ts @@ -73,6 +73,7 @@ describe("Job", () => { envFrom: [{ configMapRef: { name: "foo-config" } }], imagePullPolicy: ContainerImagePullPolicy.ALWAYS, imagePullSecrets: [{ name: "foo-secret" }], + priorityClassName: "high-priority-nonpreempting", resources: { requests: { cpu: Quantity.fromNumber(0.1),