apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: nightly-cluster-script
spec:
# https://crontab.guru/
  schedule: "0 8 * * *"
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: cluster-rebuild
            image: nibalizer/alpine-ibmcloudcli:latest
            imagePullPolicy: Always
            args:
            - /bin/bash
            - /etc/scripts/nightly_cluster.sh
            volumeMounts:
            - name: nightly-cluster-script
              mountPath: /etc/scripts
            env:
              - name: API_KEY
                valueFrom:
                  secretKeyRef:
                    name: nightly-cluster-script-secret
                    key: API_KEY
          volumes :
            - name: nightly-cluster-script
              configMap:
                # Provide the name of the ConfigMap containing the files you want
                # to add to the container
                name: nightly-cluster-script
          restartPolicy: Never

