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:v26.2.3
          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:v26.2.3
          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/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
