kind: Deployment
apiVersion: apps/v1
metadata:
  labels:
    k8s-app: artascope
  name: artascope-app
  namespace: ${ARTASCOPE_NAMESPACE}
spec:
  replicas: 1
  revisionHistoryLimit: 10
  minReadySeconds: 20
  selector:
    matchLabels:
      k8s-app: artascope-app
  template:
    metadata:
      labels:
        k8s-app: artascope-app
    spec:
      volumes:
        - name: tmp-volume
          emptyDir: {}
        - name: redis-data
          persistentVolumeClaim:
            claimName: antascope-redis-pvc
      containers:
        - name: artascope-redis
          image: redis:5.0.6
          ports:
            - containerPort: 6379
              protocol: TCP
          volumeMounts:
            - mountPath: /data
              name: redis-data

        - name: artascope-web
          image: ${ARTASCOPE_DOCKER_REGISTRY}magicqin/icloud-photo-downloader:latest
          command: ["/app/docker-entrypoint.sh", "web"]
          ports:
            - containerPort: 16666
              protocol: TCP
          envFrom:
            - configMapRef:
                name: env-config
          livenessProbe:
            httpGet:
              port: 16666
              path: /user
            initialDelaySeconds: 15
            periodSeconds: 5
          readinessProbe:
            httpGet:
              port: 16666
              path: /user
            initialDelaySeconds: 18
            periodSeconds: 2

        - name: celery-worker-main
          image: ${ARTASCOPE_DOCKER_REGISTRY}magicqin/icloud-photo-downloader:latest
          command: ["/app/docker-entrypoint.sh", "celery_worker_main"]
          env:
            - name: C_FORCE_ROOT
              value: "true"
          envFrom:
            - configMapRef:
                name: env-config
          volumeMounts:
            - mountPath: /tmp
              name: tmp-volume

        - name: celery-worker-upload
          image: ${ARTASCOPE_DOCKER_REGISTRY}magicqin/icloud-photo-downloader:latest
          command: ["/app/docker-entrypoint.sh", "celery_worker_upload"]
          env:
            - name: C_FORCE_ROOT
              value: "true"
          envFrom:
            - configMapRef:
                name: env-config
          volumeMounts:
            - mountPath: /tmp
              name: tmp-volume

        - name: celery-worker-msg
          image: ${ARTASCOPE_DOCKER_REGISTRY}magicqin/icloud-photo-downloader:latest
          command: ["/app/docker-entrypoint.sh", "celery_worker_msg"]
          env:
            - name: C_FORCE_ROOT
              value: "true"
          envFrom:
            - configMapRef:
                name: env-config

        - name: celery-flower
          image: ${ARTASCOPE_DOCKER_REGISTRY}magicqin/icloud-photo-downloader:latest
          command: ["/app/docker-entrypoint.sh", "celery_flower"]
          ports:
            - containerPort: 5555
              protocol: TCP
          env:
            - name: C_FORCE_ROOT
              value: "true"
          envFrom:
            - configMapRef:
                name: env-config

        - name: scheduler
          image: ${ARTASCOPE_DOCKER_REGISTRY}magicqin/icloud-photo-downloader:latest
          command: ["/app/docker-entrypoint.sh", "scheduler"]
          envFrom:
            - configMapRef:
                name: env-config

      serviceAccountName: artascope
