10.2.2 Scheduling tasks with CronJobs

View in the book. Buy the book.
10.4 Object composition of CronJob
Figure 10.4 Object composition of CronJob

Create the CronJob

$ kubectl create -f Chapter10/10.2.2_CronJob/cronjob_addwork.yaml
cronjob.batch/addwork created

$ kubectl get cronjob,job
NAME                    SCHEDULE      SUSPEND   ACTIVE   LAST SCHEDULE   AGE
cronjob.batch/addwork   */5 * * * *   False     0        <none>          5s

After 5 minutes you should see that it has spawned a Job.

$ kubectl get cronjob,job,pods
NAME                    SCHEDULE      SUSPEND   ACTIVE   LAST SCHEDULE   AGE
cronjob.batch/addwork   */5 * * * *   False     0        46s             104s

NAME                         COMPLETIONS   DURATION   AGE
job.batch/addwork-28330610   1/1           5s         46s

NAME                             READY   STATUS        RESTARTS   AGE
pod/addwork-28330610-fkxmq       0/1     Completed     0          46s
pod/pi-worker-674b89665f-299qc   1/1     Running       0          6s
pod/pi-worker-674b89665f-5vg7r   1/1     Running       0          14s
pod/pi-worker-674b89665f-7sfxd   1/1     Running       0          54s
pod/pi-worker-674b89665f-952bj   1/1     Running       0          14s
pod/pi-worker-674b89665f-dtxsc   1/1     Running       0          29s
pod/pi-worker-674b89665f-htlbc   1/1     Terminating   0          14s
pod/pi-worker-674b89665f-jdwtp   1/1     Running       0          6s
pod/pi-worker-674b89665f-mbvnv   1/1     Running       0          29s
pod/pi-worker-674b89665f-q4nbd   1/1     Running       0          6s
pod/pi-worker-674b89665f-rgrkm   1/1     Running       0          14s
pod/pi-worker-674b89665f-rvsxp   1/1     Running       0          54s
pod/pi-worker-674b89665f-x469p   1/1     Terminating   0          11s
pod/pi-worker-674b89665f-xgph5   1/1     Terminating   0          11s
pod/redis-0                      1/1     Running       0          24m
pod/redis-1                      1/1     Running       0          22m
pod/redis-2                      1/1     Running       0          20m