How to to schedule a Job (not a CronJob) to an future date?

53 Views Asked by At

I need that a Job on Kubernetes run in an future date. Its important to be a Job, not a CronJob, because it needs to run only once.

For example, after creating this Job, it is ran immediately. How i schedule it to run on some date in the future?

apiVersion: batch/v1
kind: Job
metadata:
  name: do-something
spec:
  template:
    spec:
      containers:
      - name: do-something
        image: do-something
        command: ["python",  "/app/do-something.py"]
      restartPolicy: Never
  backoffLimit: 4
1

There are 1 best solutions below

0
On

Well this is not the way one should use Job, for scheduled jobs you should use cronjobs.

A CronJob creates Jobs on a repeating schedule. docs

however you can use a job and trigger it with other CRDs like argoCD. For example we trigger a job with each argocd sync. Please provide more information so we can tailor something for your specific need : )