apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: rmt-mirror-cronjob
  labels:
    app: rmt-server
    tier: rmt-mirror-cronjob
spec:
  schedule: "30 2 * * *"
  jobTemplate:
    spec:
      template:
        spec:
          restartPolicy: OnFailure
          volumes:
          - name: rmt-persistent-storage
            persistentVolumeClaim:
              claimName: rmt-pv-claim
          containers:
          - name: rmt-mirror-cronjob
            image: registry.opensuse.org/opensuse/rmt-server:latest
            imagePullPolicy: Always
            args:
            - /usr/share/rmt/bin/rmt-cli
            - mirror
            env:
            - name: MYSQL_HOST
              value: rmt-mariadb-svc
            - name: MYSQL_DATABASE
              value: rmt
            - name: MYSQL_USER
              value: rmt
            - name: MYSQL_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: rmt-mariadb-rmt-pass
                  key: password
            - name: SCC_USERNAME
              valueFrom:
                secretKeyRef:
                  name: rmt-scc-account
                  key: username
            - name: SCC_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: rmt-scc-account
                  key: password
            volumeMounts:
            - name: rmt-persistent-storage
              mountPath: /var/lib/rmt
