apiVersion: batch/v1
kind: CronJob
metadata:
  name: twhelp-job-sync-data
spec:
  schedule: 0 * * * *
  successfulJobsHistoryLimit: 3
  failedJobsHistoryLimit: 3
  concurrencyPolicy: Forbid
  jobTemplate:
    spec:
      parallelism: 1
      template:
        spec:
          restartPolicy: Never
          containers:
            - name: twhelp-job-sync-data
              image: twhelp
              args: [job, sync, data]
              env:
                - name: APP_MODE
                  value: development
                - name: LOG_LEVEL
                  value: debug
                - name: DB_CONNECTION_STRING
                  valueFrom:
                    secretKeyRef:
                      name: twhelp-secret
                      key: db-connection-string
                - name: DB_MAX_OPEN_CONNS
                  value: "1"
                - name: DB_MAX_IDLE_CONNS
                  value: "1"
                - name: RABBITMQ_CONNECTION_STRING
                  valueFrom:
                    secretKeyRef:
                      name: twhelp-secret
                      key: rabbitmq-connection-string
              resources:
                requests:
                  cpu: 50m
                  memory: 64Mi
                limits:
                  cpu: 100m
                  memory: 128Mi
---
apiVersion: batch/v1
kind: CronJob
metadata:
  name: twhelp-job-sync-ennoblements
spec:
  schedule: "* * * * *"
  successfulJobsHistoryLimit: 3
  failedJobsHistoryLimit: 3
  concurrencyPolicy: Forbid
  jobTemplate:
    spec:
      parallelism: 1
      template:
        spec:
          restartPolicy: Never
          containers:
            - name: twhelp-job-sync-ennoblements
              image: twhelp
              args: [job, sync, ennoblements]
              env:
                - name: APP_MODE
                  value: development
                - name: LOG_LEVEL
                  value: debug
                - name: DB_CONNECTION_STRING
                  valueFrom:
                    secretKeyRef:
                      name: twhelp-secret
                      key: db-connection-string
                - name: DB_MAX_OPEN_CONNS
                  value: "1"
                - name: DB_MAX_IDLE_CONNS
                  value: "1"
                - name: RABBITMQ_CONNECTION_STRING
                  valueFrom:
                    secretKeyRef:
                      name: twhelp-secret
                      key: rabbitmq-connection-string
              resources:
                requests:
                  cpu: 50m
                  memory: 64Mi
                limits:
                  cpu: 100m
                  memory: 128Mi
---
apiVersion: batch/v1
kind: CronJob
metadata:
  name: twhelp-job-create-snapshots
spec:
  schedule: 30 * * * *
  successfulJobsHistoryLimit: 3
  failedJobsHistoryLimit: 3
  concurrencyPolicy: Forbid
  jobTemplate:
    spec:
      parallelism: 1
      template:
        spec:
          restartPolicy: Never
          containers:
            - name: twhelp-job-create-snapshots
              image: twhelp
              args: [job, create, snapshots]
              env:
                - name: APP_MODE
                  value: development
                - name: LOG_LEVEL
                  value: debug
                - name: DB_CONNECTION_STRING
                  valueFrom:
                    secretKeyRef:
                      name: twhelp-secret
                      key: db-connection-string
                - name: DB_MAX_OPEN_CONNS
                  value: "1"
                - name: DB_MAX_IDLE_CONNS
                  value: "1"
                - name: RABBITMQ_CONNECTION_STRING
                  valueFrom:
                    secretKeyRef:
                      name: twhelp-secret
                      key: rabbitmq-connection-string
              resources:
                requests:
                  cpu: 50m
                  memory: 64Mi
                limits:
                  cpu: 100m
                  memory: 128Mi
---
apiVersion: batch/v1
kind: Job
metadata:
  name: twhelp-migrations-job
spec:
  template:
    spec:
      containers:
        - name: twhelp-migrations
          image: twhelp
          args: [db, migrate]
          env:
            - name: APP_MODE
              value: development
            - name: LOG_LEVEL
              value: debug
            - name: DB_CONNECTION_STRING
              valueFrom:
                secretKeyRef:
                  name: twhelp-secret
                  key: db-connection-string
            - name: DB_MAX_OPEN_CONNS
              value: "1"
            - name: DB_MAX_IDLE_CONNS
              value: "1"
            - name: DB_READ_TIMEOUT
              value: 60s
          resources:
            requests:
              cpu: 50m
              memory: 64Mi
            limits:
              cpu: 100m
              memory: 128Mi
      restartPolicy: Never
