<p>distributed CRON in Kubernetes is still a work in progress (<a href="https://github.com/kubernetes/kubernetes/issues/2156" rel="nofollow">https://github.com/kubernetes/kubernetes/issues/2156</a>).</p>

<p>What do you use for CRON jobs in Kubernetes today?</p>

<p>Do you recommend any solution that works well with Spring/JVM-based services? Spring/JVM startup time is quite high and if CRON scheduler started a new JVM for each job, startup time might be much higher than time of actual work - is there any solution that could run the job in existing JVM?</p>

<p>Thank you,
Jakub</p>

<p>I wrote a small <a href="https://github.com/IanLewis/homepage/blob/master/deploy/gocron/main.go" rel="nofollow">Go app</a> that functions like cron but writes log info to stdout (no email!) and can be built into a static binary for easy containerization.</p>

<p>I built kubectl from source as a static binary and included it in the image (it may be a static binary in the most recent releases). Kubectl will automatically look for the service account token/certs in /var/run/secrets/kubernetes.io/serviceaccount/ so you should be good to go unless you're not using the default service account.</p>

<p>I then set up a <a href="https://github.com/IanLewis/homepage/blob/master/deploy/gocron/crontab-prod" rel="nofollow">crontab</a> to run kubectl to create a <a href="https://github.com/IanLewis/homepage/blob/master/deploy/backup/backup.yaml" rel="nofollow">job</a> at the period that I wanted. The crontab and yaml files for the jobs can be mounted as a secret. You can either use <a href="https://github.com/kelseyhightower/conf2kube" rel="nofollow">conf2kube</a> or some other way of generating the secrets. I wrote a simple <a href="https://github.com/IanLewis/homepage/blob/master/deploy/gocron/create_secrets.pyhttps://github.com/IanLewis/homepage/blob/master/deploy/gocron/create_secrets.py" rel="nofollow">python script</a>.</p>

<p>It's totally a workaround until there is proper support but I hope that helps.</p>
