Skip to content

Latest commit

 

History

History
42 lines (29 loc) · 1.57 KB

README.adoc

File metadata and controls

42 lines (29 loc) · 1.57 KB

Periodic Job

Our Cron Job example builds on top of the Batch Job example above.

This example assumes a Kubernetes installation is available. In this case, it’s best played with Minikube, as we need some support for PVs. Check the INSTALL documentation for installing Minikube.

To access the PersistentVolume used in this demo, let’s mount a local directory into the Minikube VM that we later then use for a PersistentVolume that is mounted into the Pod:

minikube start --mount --mount-string="$(pwd)/logs:/tmp/example"

Then create the PersistentVolume and PersistentVolumeClaim with

kubectl apply -f https://k8spatterns.io/PeriodicJob/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 https://k8spatterns.io/PeriodicJob/cron-job.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.