apiVersion: batch/v1
kind: CronJob
metadata:
  name: sip-backuper-cronjob
spec:
  #          Backup the database every day at 2AM
  #          ┌───────────── minute (0 - 59)
  #          │ ┌───────────── hour (0 - 23)
  #          │ │ ┌───────────── day of the month (1 - 31)
  #          │ │ │ ┌───────────── month (1 - 12)
  #          │ │ │ │ ┌───────────── day of the week (0 - 6) (Sunday to Saturday;
  #          │ │ │ │ │                                   7 is also Sunday on some systems)
  #          │ │ │ │ │                                   OR sun, mon, tue, wed, thu, fri, sat
  #          │ │ │ │ │
  schedule: "0 * * * *" # => hourly
  jobTemplate:
    spec:
      template:
        metadata:
          labels:
            cj2job: cronjob
        spec:
          restartPolicy: OnFailure
          containers:
            - name: sip-backuper-cronjob
              image: gcr.io/sip-unlu-2022-353303/sip-backuper:latest
              imagePullPolicy: Always
              env:
                - name: client_id
                  valueFrom:
                    configMapKeyRef:
                      name: sip-backuper-configmap
                      key: client_id

                - name: client_email
                  valueFrom:
                    configMapKeyRef:
                      name: sip-backuper-configmap
                      key: client_email

                - name: private_key_id
                  valueFrom:
                    configMapKeyRef:
                      name: sip-backuper-configmap
                      key: private_key_id

                - name: private_key
                  valueFrom:
                    configMapKeyRef:
                      name: sip-backuper-configmap
                      key: private_key
                      optional: false

                - name: bucket_name
                  valueFrom:
                    configMapKeyRef:
                      name: sip-backuper-configmap
                      key: bucket_name

                - name: db_name
                  valueFrom:
                    configMapKeyRef:
                      name: sip-backuper-configmap
                      key: db_name

                - name: db_username
                  valueFrom:
                    configMapKeyRef:
                      name: sip-backuper-configmap
                      key: db_username

                - name: db_password
                  valueFrom:
                    configMapKeyRef:
                      name: sip-backuper-configmap
                      key: db_password

                - name: db_host
                  valueFrom:
                    configMapKeyRef:
                      name: sip-backuper-configmap
                      key: db_host

                - name: db_port
                  valueFrom:
                    configMapKeyRef:
                      name: sip-backuper-configmap
                      key: db_port
