# =============================================================================
# KM Vectorize CronJob - ADR-073 Phase 4-3 飛輪學習固化
# =============================================================================
# 每日 03:00 台北 (19:00 UTC 前一天) 自動向量化新增 KM 條目
# 確保 RAG 查詢可存取最新知識，完成飛輪「學習固化」節點
#
# 2026-04-12 ogt (ADR-073 Phase 4-3)
# =============================================================================

apiVersion: batch/v1
kind: CronJob
metadata:
  name: km-vectorize
  namespace: awoooi-prod
  labels:
    app: awoooi
    component: km-vectorize
    phase: "4-3"
spec:
  # 每日 19:00 UTC = 03:00 台北
  schedule: "0 19 * * *"
  timeZone: "Asia/Taipei"
  concurrencyPolicy: Forbid
  successfulJobsHistoryLimit: 3
  failedJobsHistoryLimit: 3
  startingDeadlineSeconds: 300
  jobTemplate:
    spec:
      backoffLimit: 2
      activeDeadlineSeconds: 300
      template:
        metadata:
          labels:
            app: awoooi
            component: km-vectorize
        spec:
          restartPolicy: OnFailure
          containers:
            - name: km-vectorize
              image: 192.168.0.110:5000/awoooi-api:latest
              imagePullPolicy: Always
              command:
                - python
                - /app/scripts/cron_km_vectorize.py
              env:
                - name: TZ
                  value: "Asia/Taipei"
                - name: INTERNAL_API_URL
                  value: "http://awoooi-api.awoooi-prod.svc.cluster.local:8000"
              resources:
                requests:
                  cpu: "50m"
                  memory: "64Mi"
                limits:
                  cpu: "200m"
                  memory: "128Mi"
          serviceAccountName: awoooi-api
