apiVersion: apps/v1
kind: Deployment
metadata:
  name: backend-celery-worker
  namespace: hotpocket-development
  labels:
    app.kubernetes.io/app: backend-celery-worker
spec:
  minReadySeconds: 30
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 1
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
    type: RollingUpdate
  selector:
    matchLabels:
      app.kubernetes.io/app: backend-celery-worker
  template:
    metadata:
      labels:
        app.kubernetes.io/app: backend-celery-worker
    spec:
      containers:
        - name: app
          image: hotpocket-backend:latest
          args:
            - "/srv/venv/bin/celery"
            - "-A"
            - "hotpocket_backend.celery:app"
            - "worker"
            - "-l"
            - "INFO"
            - "-Q"
            - "celery,webapp"
            - "-c"
            - "2"
          envFrom:
            - configMapRef:
                name: backend-base-config
            - configMapRef:
                name: backend-webapp-config
          env:
            - name: VAULT_URL
              valueFrom:
                secretKeyRef:
                  name: backend-vault
                  key: url
            - name: VAULT_ROLE_ID
              valueFrom:
                secretKeyRef:
                  name: backend-vault
                  key: role_id
            - name: VAULT_SECRET_ID
              valueFrom:
                secretKeyRef:
                  name: backend-vault
                  key: secret_id
          volumeMounts:
            - mountPath: /dev/shm
              name: shm
            - mountPath: /srv/run
              name: backend-celery-worker-srv-run
            - mountPath: /srv/uploads
              name: backend-celery-worker-srv-uploads
            - name: backend-admin-local-deps
              mountPath: "/srv/lib/requirements.txt"
              subPath: "requirements.txt"
            - name: backend-admin-local-deps
              mountPath: "/srv/etc/entrypoint.d/01-install-extra-deps.sh"
              subPath: "01-install-extra-deps.sh"
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      volumes:
        - name: shm
          emptyDir:
            medium: Memory
        - name: backend-celery-worker-srv-run
          emptyDir: {}
        - name: backend-celery-worker-srv-uploads
          persistentVolumeClaim:
            claimName: backend-uploads
        - name: backend-admin-local-deps
          configMap:
            name: "backend-local-deps"
            defaultMode: 0755
