-2

I have a kubernetes job. I want to execute this job continuously . Like 1st will run, it will take around 10 or 15 minutes to complete. Then it will wait for 2 minutes. again same job will be triggered. like that it continue.

Is there any to way to achieve this via cronjob or job ..

Baitanik
  • 63
  • 1
  • 7
  • "job continuously" - did you want a job? this sounds more like a service that is doing things continuously in a loop. – Jonas Jul 03 '20 at 15:26
  • Yeah. if we put loop it will work. But the thing that Job is used by many components.. this particular use case. we need that job operation to be executed at regular interval. In my use case it is kind of monitoring/metric sending job… So after job gets triggered, it will collect some metric from one cluster, and will send those data to a different server. Then wait for 5 minutes after completion of the 1st Job, then again trigger the Job Again do the same exercise… So i was trying to make it work with k8 job, without impacting the running codes. – Baitanik Jul 04 '20 at 01:52

1 Answers1

1

I don't know your use-case but this is how I would do it without using external client or API:

You can set-up a cronjob every 2 minutes, and set: Concurrent Policy to Forbid. It will check every 2 min and start a job only if the previous one has been completed.

Of course, you can end-up with cases where the last job finished few seconds before the cronjob.

Best,

François
  • 1,793
  • 14
  • 19
  • yeah that is what i am doing now.. as you mentioned there might be a scenario, when previous job gets finished, some few seconds the the next trigger.. Wanted to avoid that. thanks for your answers – Baitanik Jul 03 '20 at 14:05