#
# To start this job, do
#    kubectl create -f ./cronjob.yaml
# https://kubernetes.io/docs/tasks/job/automated-tasks-with-cron-jobs/
# TODO: sync with prime.yaml

apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: transaction-check
spec:
  schedule: "0 */2 * * *"
  jobTemplate:
    spec:
      template:
        spec:
          containers:
            - name: payment-transaction-check
              image: gcr.io/gcp-runtimes/ubuntu_18_0_4
              env:
                - name: INTERVAL
                  value: "7500"        # Time interval in seconds (must be > than schedule)
              command: ["/bin/sh", "-c"]
              args:
                - echo Checking payment transaction/purchase records;
                  date;
                  echo "Mismatch payment transactions/purchase records last $INTERVAL seconds:";
                  curl -sS --stderr - -w "\n%{http_code}\n" http://prime-monitor-service:8080/payment/check?start=$(expr $(date --utc +"%s") - $INTERVAL);
                  echo Checks completed;
          restartPolicy: OnFailure
