1

I have to implement a feature in an existing application, which requires calling an API every minute. My app's microservices runs in Kubernetes environment.

To achieve this, my first thought is Kubernetes cron job. But thinking little deep it occurred to me that a Kubernetes cron job, every minute will pull an image from a container registry, spin up that image, check for many validation if job has failed and it requires re-run etc etc...just to call one API.

Is it an over-kill?

Is there a way in Kubernetes to run a scheduler (like Google Cloud Scheduler) which simply calls an API (which is configurable)?

Thanks in advance!!!

theinsaneone
  • 210
  • 1
  • 6

2 Answers2

4

I'd probably just create a very minimal Docker image that runs continuously and calls APIs according to a schedule. There are various cron containers in the Docker registry which could be used as starting point, or you could write a very simple scheduler yourself in Python or some other readily available language.

Hans-Martin Mosner
  • 14,638
  • 1
  • 27
  • 35
  • yes that was I thought I could write a scheduler myself which can run inside a pod continuously and also serve my other scheduling requirements (if any). – theinsaneone Jul 07 '20 at 05:26
2

If having a low resource task running every minutes, indeed it is not efficient to start a pod all the time, bug for big tasks, low frequency, run for long time and consumes a lot of resources then using k8s cronjob makes more sense. And you can avoid pulling image every time by setting imagePullPolicy: IfNotPresent.

Tin Pham
  • 21
  • 1