apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: random-generator
spec:
  # Every three minutes
  schedule: "*/3 * * * *"
  jobTemplate:
    spec:
      # Templae for the job to generate
      template:
        spec:
          containers:
          - image: k8spatterns/random-generator:1.0
            name: random-generator
            command:
            - java
            # Use / as classpath to pick up the class file
            - -classpath
            - /
            # Class running batch job
            - RandomRunner
            # 1. Arg: File to store data (on a PV)
            - /logs/random.log
            # 2. How many iterations
            - "10000"
            volumeMounts:
            - mountPath: /logs
              name: log-volume
          restartPolicy: OnFailure
          volumes:
          - name: log-volume
            persistentVolumeClaim:
              claimName: random-generator-log
