Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow to set (Cron)Job's priorityClassName #70

Merged
merged 2 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions examples/cron-job/__snapshots__/chart.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ exports[`CronJob example > Change release version 1`] = `
"name": "docker-hub-cred",
},
],
"priorityClassName": "job",
"restartPolicy": "Never",
},
},
Expand Down Expand Up @@ -250,6 +251,7 @@ exports[`CronJob example > Snapshot 1`] = `
"name": "docker-hub-cred",
},
],
"priorityClassName": "job",
"restartPolicy": "Never",
},
},
Expand Down
2 changes: 2 additions & 0 deletions examples/job/__snapshots__/chart.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ exports[`Job example > Change release version 1`] = `
"name": "docker-hub-cred",
},
],
"priorityClassName": "job",
"restartPolicy": "OnFailure",
},
},
Expand Down Expand Up @@ -241,6 +242,7 @@ exports[`Job example > Snapshot 1`] = `
"name": "docker-hub-cred",
},
],
"priorityClassName": "job",
"restartPolicy": "OnFailure",
},
},
Expand Down
6 changes: 6 additions & 0 deletions lib/cron-job/cron-job-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
1 change: 1 addition & 0 deletions lib/cron-job/cron-job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
{
Expand Down
6 changes: 6 additions & 0 deletions lib/job/job-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
1 change: 1 addition & 0 deletions lib/job/job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
{
Expand Down
26 changes: 13 additions & 13 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions test/cron-job/__snapshots__/cron-job.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ exports[`CronJob > Props > All the props 1`] = `
"name": "init-container",
},
],
"priorityClassName": "high-priority-nonpreempting",
"restartPolicy": "OnFailure",
"volumes": [
{
Expand Down Expand Up @@ -185,6 +186,7 @@ exports[`CronJob > Props > Minimal required props 1`] = `
},
},
],
"priorityClassName": "job",
"restartPolicy": "OnFailure",
},
},
Expand Down
1 change: 1 addition & 0 deletions test/cron-job/cron-job.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions test/job/__snapshots__/job.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ exports[`Job > Props > All the props 1`] = `
"name": "init-container",
},
],
"priorityClassName": "high-priority-nonpreempting",
"restartPolicy": "Never",
"volumes": [
{
Expand Down Expand Up @@ -174,6 +175,7 @@ exports[`Job > Props > Minimal required props 1`] = `
},
},
],
"priorityClassName": "job",
"restartPolicy": "Never",
},
},
Expand Down
1 change: 1 addition & 0 deletions test/job/job.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down