Our Cron Job example builds on top of the Batch Job example above, to the basic setup is the same:
-
A Minikube installation available, ideally with Minikube
-
Minikube started with
minikube start --mount --mount-string="$(pwd)/logs:/example"
to mount the locallogs/
into the Minikube VM
Then create the PersistentVolume and PersistentVolumeClaim with
kubectl create -f pv-and-pvc.yml
but you don’t have to do it, if you already have your Minikube still running from the Batch Job example [1]
Now create the CronJob which fires every three minutes:
kubectl create -f cron-jobs.yml
In this example we only use only one completion per Job (i.e. the default for a Job).
You can check the logs/random.log
for the numbers generated, and also of course the Pods that are run on behalf of the job.
1. If you reuse the Batch Job example, don’t forget that the
random.log
is generated in the logs/
directory over there.