apiVersion: apps/v1
kind: Deployment
metadata:
  name: cron
  labels:
    app: cron
spec:
  selector:
    matchLabels:
      app: cron
  template:
    metadata:
      labels:
        app: cron
    spec:
      imagePullSecrets:
        - name: "cr.seqera.io"
      volumes:
        - name: config-volume
          configMap:
            name: tower-yml
      initContainers:
        - name: migrate-db
          image: cr.seqera.io/enterprise/platform/migrate-db:v24.1.8
          command: ["sh", "-c", "/migrate-db.sh"]
          envFrom:
            - configMapRef:
                name: tower-backend-cfg
          volumeMounts:
            - name: config-volume
              mountPath: /tower.yml
              subPath: tower.yml
      containers:
        - name: backend
          image: cr.seqera.io/enterprise/platform/backend:v24.1.8
          envFrom:
            - configMapRef:
                name: tower-backend-cfg
          volumeMounts:
            - name: config-volume
              mountPath: /tower.yml
              subPath: tower.yml
          env:
            - name: MICRONAUT_ENVIRONMENTS
              value: "prod,redis,cron"
            # Configuration to optimize JVM memory settings. See https://docs.seqera.io/platform-enterprise/24.1/enterprise/configuration/overview#backend-memory-requirements
            - name: JAVA_OPTS
              value: "-Xms1000M -Xmx2000M -XX:MaxDirectMemorySize=800m -Dio.netty.maxDirectMemory=0 -Djdk.nio.maxCachedBufferSize=262144"
          ports:
            - containerPort: 8080
          resources:
            requests:
              cpu: "1"
              memory: "4Gi"
            limits:
              memory: "4Gi"
          readinessProbe:
            httpGet:
              path: /health
              port: 8080
            initialDelaySeconds: 5
            timeoutSeconds: 3
          livenessProbe:
            httpGet:
              path: /health
              port: 8080
            initialDelaySeconds: 5
            timeoutSeconds: 3
            failureThreshold: 10
