apiVersion: apps/v1
kind: Deployment
metadata:
  name: celery-worker
  labels:
    app: celery-worker
spec:
  replicas: 1
  selector:
    matchLabels:
      app: celery-worker
  template:
    metadata:
      labels:
        app: celery-worker
    spec:
      imagePullSecrets:
      - name: cr-pull-secret
      containers:
      - name: celery-worker
        image: ${CI_REGISTRY_IMAGE}/video-backend:latest
        imagePullPolicy: Always
        command: ["celery", "-A", "config", "worker", "--loglevel=info", "--pool=gevent", "--concurrency=200"]
        env: &shared-env
        - name: USE_MYSQL
          value: "true"
        - name: DJANGO_DEBUG
          value: "False"
        - name: DJANGO_ALLOWED_HOSTS
          value: "*"
        - name: DJANGO_SECRET_KEY
          valueFrom:
            secretKeyRef:
              name: video-backend-secrets
              key: DJANGO_SECRET_KEY
        # Redis
        - name: REDIS_URL
          value: "redis://zyc:Zyc188208@redis-shzlsczo52dft8mia.redis.ivolces.com:6379/0"
        # Database (Volcano Engine RDS)
        - name: DB_HOST
          value: "mysql8351f937d637.rds.ivolces.com"
        - name: DB_NAME
          value: "video_auto"
        - name: DB_USER
          value: "zyc"
        - name: DB_PASSWORD
          value: "Zyc188208"
        - name: DB_PORT
          value: "3306"
        # TOS (from Secret)
        - name: TOS_ACCESS_KEY
          valueFrom:
            secretKeyRef:
              name: video-backend-secrets
              key: TOS_ACCESS_KEY
        - name: TOS_SECRET_KEY
          valueFrom:
            secretKeyRef:
              name: video-backend-secrets
              key: TOS_SECRET_KEY
        - name: TOS_BUCKET
          value: "airdrama-media"
        - name: TOS_ENDPOINT
          value: "https://tos-cn-beijing.volces.com"
        - name: TOS_REGION
          value: "cn-beijing"
        - name: TOS_CDN_DOMAIN
          value: "https://airdrama-media.tos-cn-beijing.volces.com"
        # Seedance API (from Secret)
        - name: ARK_API_KEY
          valueFrom:
            secretKeyRef:
              name: video-backend-secrets
              key: ARK_API_KEY
        - name: ARK_ENDPOINT_SEEDANCE
          value: "ep-m-20260315211214-z9dp6"
        - name: ARK_ENDPOINT_SEEDANCE_FAST
          value: "ep-m-20260329211530-68999"
        - name: SEEDANCE_ENABLED
          value: "true"
        resources:
          requests:
            memory: "256Mi"
            cpu: "200m"
          limits:
            memory: "1Gi"
            cpu: "1000m"
      - name: celery-beat
        image: ${CI_REGISTRY_IMAGE}/video-backend:latest
        imagePullPolicy: Always
        command: ["celery", "-A", "config", "beat", "--loglevel=info"]
        env: *shared-env
        resources:
          requests:
            memory: "64Mi"
            cpu: "50m"
          limits:
            memory: "128Mi"
            cpu: "100m"
