Vlad Tanase
Vlad Tanase

Reputation: 77

Google Kubernetes Api Cron Job

I have a cluster in Google Kubernetes Engine, in that cluster there is a workload which runs every 4 hours, its a cron job that was set up by someone. I want to make that run whenever I need it. I am trying to achieve this by using the google Kubernetes API, sending requests from my app whenever a button is clicked to run that cron job, unfortunately the API has no apparent way to do that, or does not have a way at all. What would be some good advice to achieve my goal?

Upvotes: 1

Views: 306

Answers (1)

mario
mario

Reputation: 11138

This is a Community Wiki answer, posted for better visibility, so feel free to edit it and add any additional details you consider important.

CronJob resource in kubernetes is not meant to be used one-off tasks, that are run on demand. It is rather configured to run on a regular schedule.

Manuel Polacek has already mentioned that in his comment:

For this scenario you don't need a cron job. A simple bare pod or a job would be enough, i would say. You can apply a resource on button push, for example with kubectl – Manuel Polacek Apr 24 at 19:25

So rather than trying to find a way to run your CronJobs on demand, regardless of how they are originally scheduled (usually to be repeated at regular intervals), you should copy the code of such CronJob and find a different way of running it. A Job fits ideally to such use case as it is designed to run one-off tasks.

Upvotes: 2

Related Questions