apiVersion: apps/v1
kind: Deployment
metadata:
  name: celery-logo-worker
  labels:
    app: celery-logo-worker
    component: backend
    queue: logo-detection
spec:
  replicas: 2  # Dedicated workers for logo detection
  selector:
    matchLabels:
      app: celery-logo-worker
  template:
    metadata:
      labels:
        app: celery-logo-worker
        component: backend
        queue: logo-detection
    spec:
      containers:
      - name: celery-logo-worker
        image: media-analyzer-backend:latest
        # DEDICATED QUEUE: Only process logo detection tasks
        command: ["celery", "-A", "media_analyzer", "worker", "-l", "info", "-Q", "logo_detection", "--concurrency=2"]
        env:
        - name: DEBUG
          value: "false"
        - name: DB_HOST
          value: "postgres-service"
        - name: DB_NAME
          value: "media_analyzer"
        - name: DB_USER
          valueFrom:
            secretKeyRef:
              name: postgres-secrets
              key: username
        - name: DB_PASSWORD
          valueFrom:
            secretKeyRef:
              name: postgres-secrets
              key: password
        - name: REDIS_SERVICE_HOST
          value: "redis-service"
        - name: REDIS_SERVICE_PORT
          value: "6379"
        - name: GOOGLE_APPLICATION_CREDENTIALS
          value: "/var/secrets/google/credentials.json"
        - name: GCP_BUCKET_NAME
          value: "media-analyzer-segments"
        - name: GCP_PROJECT_ID
          valueFrom:
            configMapKeyRef:
              name: gcp-config
              key: project-id
        - name: USE_CLOUD_VISION
          valueFrom:
            configMapKeyRef:
              name: app-config
              key: use-cloud-vision
        - name: USE_CLOUD_STORAGE
          valueFrom:
            configMapKeyRef:
              name: app-config
              key: use-cloud-storage
        - name: LOGO_CONFIDENCE_THRESHOLD
          valueFrom:
            configMapKeyRef:
              name: app-config
              key: logo-confidence-threshold
        volumeMounts:
        - name: gcp-credentials
          mountPath: /var/secrets/google
          readOnly: true
        - name: media-storage
          mountPath: /app/media
        resources:
          requests:
            memory: "1Gi"    # More memory for AI processing
            cpu: "500m"
          limits:
            memory: "2Gi"
            cpu: "1000m"
      volumes:
      - name: gcp-credentials
        secret:
          secretName: gcp-credentials
      - name: media-storage
        persistentVolumeClaim:
          claimName: media-pvc