<p>I have a program that executes some code, sleeps for 10 minutes, then repeats. This continues in an infinite loop. I'm wondering if theres a way to let Kubernetes/GKE handle this scheduling.</p>

<p>I see that GKE offers cron scheduling. I could schedule a pod to run every 10 minutes. The problem is that in some scenarios the program could take more than 10 minutes to complete.</p>

<p>Ideally, I could let the pod run to completion, schedule it to run in 10 minutes, repeat. Is this possible?</p>

<p>Is this possible on Kubernetes?</p>

sthomps
<p>In K8S there's a specific resource for that goal: <a href="https://kubernetes.io/docs/tasks/job/automated-tasks-with-cron-jobs/" rel="noreferrer">CronJob</a></p>

<p>In the following example you see a <code>schedule</code> section with the tipical cron notation:</p>

<pre><code>apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: your-cron
spec:
  schedule: "*/20 8-19 * * 1-5"
  concurrencyPolicy: Forbid
  jobTemplate:
    spec:
      template:
        metadata:
          labels:
            app: your-periodic-batch-job
        spec:
          containers:
          - name: redmine-cron
            image: your_image
            imagePullPolicy: IfNotPresent
          restartPolicy: OnFailure
</code></pre>
