Skip to content

Commit

Permalink
fix: enable affinity on cronjob
Browse files Browse the repository at this point in the history
  • Loading branch information
devthejo committed Jun 4, 2024
1 parent 1d4756b commit df2c188
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions plugins/contrib/patches/40-add-jobs-affinity-and-tolerations.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
module.exports = (manifests, options) => {
const { affinityToAdd = {}, tolerationsToAdd = [] } = options
const {
affinityToAdd = {},
tolerationsToAdd = [],
cronjobEnabled = true,
} = options
for (const manifest of manifests) {
if (manifest.kind !== "Job") {
const { kind } = manifest
if (!(kind === "Job" || (kind === "CronJob" && cronjobEnabled))) {
continue
}

manifest.spec.template.spec = manifest.spec.template.spec || {}
const templateSpec = manifest.spec.template.spec
const parentSpec = kind === "CronJob" ? manifest.spec.jobTemplate : manifest

parentSpec.spec.template.spec = parentSpec.spec.template.spec || {}
const templateSpec = parentSpec.spec.template.spec

// Add or merge affinity
templateSpec.affinity = templateSpec.affinity || {}
Expand Down

0 comments on commit df2c188

Please sign in to comment.