Run kubectl command after CronJob is scheduled but before it runs

Viewed 27

I have multiple CronJobs scheduled to run on some days. I deploy them with Helm charts, and I need to test them - therefore, I'm looking for a solution to run cronjob once right after it gets deployed with Helm.

I have already tried using Helm post-hooks to create a job from CronJob kubectl create job --from=cronjob/mycronjobname mycronjob-run-0 but for this I have to create a separate container with kubectl docker image, which is not a good option for me. (Another time, it waited till CronJob is executed to run the Job, maybe it was my mistake of some sort)

I also tried creating a separate Job to execute this command, but Helm deploys Job and only then CronJob, so it's also not an option.

I also tried having a postStart lifecycle in the CronJob container, however it also waits for the CronJob to be executed according to it's schedule.

Is there any way to do this?

0 Answers
Related