Member-only story

How to run kubernetes cronjob as a job

Create a job from a cronjob

kubectl create job --from=cronjob/my-cron test-job -n my-ns

Troubleshooting

  1. Job creation fails with the following error:
error: unknown object type *v1beta1.CronJob

Install kubectl client version 1.16

curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.16.0/bin/darwin/amd64/kubectlchmod +x ./kubectl

Now, run again

./kubectl create job --from=cronjob/my-cron test-job -n my-ns

2. Job creation happens multiple times on failure, despite restartPolicy set to Never.

restartPolicy is meant for a pod, not a job. So, change backoff to zero for not allowing job to re-run.

References

--

--

Simplify Complexity
Simplify Complexity

Written by Simplify Complexity

Golang, Distributed Systems, File Systems, Python, C/C++, Linux

No responses yet