# =============================================================================
# WOOO TECH - Momo Pro System
# GCP Scheduler Deployment
# 特點: 使用本地映像，不需要 Registry Pull
# =============================================================================
apiVersion: apps/v1
kind: Deployment
metadata:
  name: momo-scheduler
  namespace: momo
  labels:
    app: momo-scheduler
    env: production
spec:
  replicas: 1
  selector:
    matchLabels:
      app: momo-scheduler
  template:
    metadata:
      labels:
        app: momo-scheduler
    spec:
      containers:
        - name: scheduler
          # 使用本地構建的映像
          image: docker.io/library/momo-pro-system:latest
          # 關鍵: 設為 Never，使用本地映像
          imagePullPolicy: Never
          command: ["python", "run_scheduler.py"]
          envFrom:
            - configMapRef:
                name: momo-config
          env:
            - name: DATABASE_URL
              valueFrom:
                secretKeyRef:
                  name: momo-secrets
                  key: DATABASE_URL
            - name: POSTGRES_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: momo-secrets
                  key: POSTGRES_PASSWORD
            - name: TELEGRAM_BOT_TOKEN
              valueFrom:
                secretKeyRef:
                  name: momo-secrets
                  key: TELEGRAM_BOT_TOKEN
            - name: LINE_CHANNEL_ACCESS_TOKEN
              valueFrom:
                secretKeyRef:
                  name: momo-secrets
                  key: LINE_CHANNEL_ACCESS_TOKEN
            - name: GEMINI_API_KEY
              valueFrom:
                secretKeyRef:
                  name: momo-secrets
                  key: GEMINI_API_KEY
          volumeMounts:
            - name: momo-data
              mountPath: /app/data
            - name: momo-logs
              mountPath: /app/logs
          resources:
            requests:
              memory: "256Mi"
              cpu: "100m"
            limits:
              memory: "2Gi"
              cpu: "1000m"
      volumes:
        - name: momo-data
          persistentVolumeClaim:
            claimName: momo-data-pvc
        - name: momo-logs
          emptyDir: {}
      # GCP 使用本地映像，不需要 imagePullSecrets
