apiVersion: batch/v1
kind: CronJob
metadata:
  name: sendgrid-sync-checkjob
  namespace: production
spec:
  schedule: "0 */1 * * *" # every 1 hour
  concurrencyPolicy: Forbid
  jobTemplate:
    spec:
      activeDeadlineSeconds: 3600
      backoffLimit: 1
      template:
        spec:
          containers:
            - name: wavtool-server
              imagePullPolicy: Always
              image: 035363416972.dkr.ecr.us-east-1.amazonaws.com/wavtool-server:$DEPLOY_TAG
              env:
                - name: DATABASE_USER
                  value: "wavtool_app"
                - name: DATABASE_HOST
                  value: "database-2.ctreuprwt6kf.us-east-1.rds.amazonaws.com"
                - name: DATABASE_NAME
                  value: "$DEPLOY_DATABASE_NAME"
                - name: DATABASE_PORT
                  value: "5432"
                - name: PGSSLMODE
                  value: "require"
                - name: ENVIRONMENT
                  value: "$DEPLOY_SERVER_ENVIRONMENT"
                - name: NODE_ENV
                  value: "production"
              envFrom:
                - configMapRef:
                    name: wavtool-server-config-$DEPLOY_SERVER_ENVIRONMENT
                - secretRef:
                    name: wavtool-server-secret
                - secretRef:
                    name: wavtool-server-secret-$DEPLOY_SERVER_ENVIRONMENT
                - secretRef:
                    name: redis-secret
              command:
                - node
                - built/src/cron/checkJob.js
          restartPolicy: Never

---
apiVersion: batch/v1
kind: CronJob
metadata:
  name: sendgrid-sync-pronessupdate
  namespace: production
spec:
  schedule: "0 0 * * *" # once a day
  concurrencyPolicy: Forbid
  jobTemplate:
    spec:
      activeDeadlineSeconds: 3600
      backoffLimit: 1
      template:
        spec:
          containers:
            - name: wavtool-server
              imagePullPolicy: Always
              image: 035363416972.dkr.ecr.us-east-1.amazonaws.com/wavtool-server:$DEPLOY_TAG
              env:
                - name: DATABASE_USER
                  value: "wavtool_app"
                - name: DATABASE_HOST
                  value: "database-2.ctreuprwt6kf.us-east-1.rds.amazonaws.com"
                - name: DATABASE_NAME
                  value: "$DEPLOY_DATABASE_NAME"
                - name: DATABASE_PORT
                  value: "5432"
                - name: PGSSLMODE
                  value: "require"
                - name: ENVIRONMENT
                  value: "$DEPLOY_SERVER_ENVIRONMENT"
                - name: NODE_ENV
                  value: "production"
              envFrom:
                - configMapRef:
                    name: wavtool-server-config-$DEPLOY_SERVER_ENVIRONMENT
                - secretRef:
                    name: wavtool-server-secret
                - secretRef:
                    name: wavtool-server-secret-$DEPLOY_SERVER_ENVIRONMENT
                - secretRef:
                    name: redis-secret
              command:
                - node
                - built/src/cron/pronessUpdate.js
          restartPolicy: Never

---
apiVersion: batch/v1
kind: CronJob
metadata:
  name: sendgrid-sync-staleprojectreengagement
  namespace: production
spec:
  schedule: "0 0 * * *" # once a day
  concurrencyPolicy: Forbid
  jobTemplate:
    spec:
      activeDeadlineSeconds: 3600
      backoffLimit: 1
      template:
        spec:
          containers:
            - name: wavtool-server
              imagePullPolicy: Always
              image: 035363416972.dkr.ecr.us-east-1.amazonaws.com/wavtool-server:$DEPLOY_TAG
              env:
                - name: DATABASE_USER
                  value: "wavtool_app"
                - name: DATABASE_HOST
                  value: "database-2.ctreuprwt6kf.us-east-1.rds.amazonaws.com"
                - name: DATABASE_NAME
                  value: "$DEPLOY_DATABASE_NAME"
                - name: DATABASE_PORT
                  value: "5432"
                - name: PGSSLMODE
                  value: "require"
                - name: ENVIRONMENT
                  value: "$DEPLOY_SERVER_ENVIRONMENT"
                - name: NODE_ENV
                  value: "production"
              envFrom:
                - configMapRef:
                    name: wavtool-server-config-$DEPLOY_SERVER_ENVIRONMENT
                - secretRef:
                    name: wavtool-server-secret
                - secretRef:
                    name: wavtool-server-secret-$DEPLOY_SERVER_ENVIRONMENT
                - secretRef:
                    name: redis-secret
              command:
                - node
                - built/src/cron/staleProjectReengagement.js
          restartPolicy: Never

---
apiVersion: batch/v1
kind: CronJob
metadata:
  name: sendgrid-sync-activityupdate
  namespace: production
spec:
  schedule: "0 0,8,16 * * *" # 3 times a day
  concurrencyPolicy: Forbid
  jobTemplate:
    spec:
      activeDeadlineSeconds: 3600
      backoffLimit: 1
      template:
        spec:
          containers:
            - name: wavtool-server
              imagePullPolicy: Always
              image: 035363416972.dkr.ecr.us-east-1.amazonaws.com/wavtool-server:$DEPLOY_TAG
              env:
                - name: DATABASE_USER
                  value: "wavtool_app"
                - name: DATABASE_HOST
                  value: "database-2.ctreuprwt6kf.us-east-1.rds.amazonaws.com"
                - name: DATABASE_NAME
                  value: "$DEPLOY_DATABASE_NAME"
                - name: DATABASE_PORT
                  value: "5432"
                - name: PGSSLMODE
                  value: "require"
                - name: ENVIRONMENT
                  value: "$DEPLOY_SERVER_ENVIRONMENT"
                - name: NODE_ENV
                  value: "production"
              envFrom:
                - configMapRef:
                    name: wavtool-server-config-$DEPLOY_SERVER_ENVIRONMENT
                - secretRef:
                    name: wavtool-server-secret
                - secretRef:
                    name: wavtool-server-secret-$DEPLOY_SERVER_ENVIRONMENT
                - secretRef:
                    name: redis-secret
              command:
                - node
                - built/src/cron/activityUpdate.js
          restartPolicy: Never
