---
# ConfigMap for RAG Service Configuration
apiVersion: v1
kind: ConfigMap
metadata:
  name: provisioning-rag-config
  namespace: provisioning-rag
  labels:
    app: provisioning-rag
    component: config
data:
  # Logging
  PROVISIONING_LOG_LEVEL: "info"
  RUST_LOG: "info"

  # API Configuration
  PROVISIONING_API_HOST: "0.0.0.0"
  PROVISIONING_API_PORT: "9090"

  # Cache Configuration
  PROVISIONING_CACHE_SIZE: "10000"
  PROVISIONING_CACHE_TTL_SECS: "3600"

  # Database Configuration (SurrealDB)
  PROVISIONING_DB_HOST: "surrealdb"
  PROVISIONING_DB_PORT: "8000"
  PROVISIONING_DB_NAMESPACE: "provisioning"
  PROVISIONING_DB_DATABASE: "rag"

  # Orchestrator Configuration
  PROVISIONING_ORCHESTRATOR_MAX_CONCURRENT_TASKS: "100"
  PROVISIONING_ORCHESTRATOR_TASK_TIMEOUT_SECS: "300"

  # Batch Processing
  PROVISIONING_BATCH_MAX_SIZE: "1000"
  PROVISIONING_BATCH_TIMEOUT_SECS: "600"

  # Search Configuration
  PROVISIONING_SEMANTIC_SEARCH_TOP_K: "10"
  PROVISIONING_KEYWORD_SEARCH_TOP_K: "10"
  PROVISIONING_HYBRID_SEARCH_ALPHA: "0.5"

  # Monitoring
  PROVISIONING_METRICS_ENABLED: "true"
  PROVISIONING_METRICS_PORT: "8888"
  PROVISIONING_HEALTH_CHECK_INTERVAL_SECS: "30"

  # Timeouts (in seconds)
  PROVISIONING_REQUEST_TIMEOUT: "30"
  PROVISIONING_CONNECTION_TIMEOUT: "10"

---
# Prometheus Configuration
apiVersion: v1
kind: ConfigMap
metadata:
  name: prometheus-config
  namespace: provisioning-rag
  labels:
    app: prometheus
data:
  prometheus.yml: |
    global:
      scrape_interval: 15s
      evaluation_interval: 15s
      external_labels:
        cluster: 'provisioning-rag'
        environment: 'kubernetes'

    alerting:
      alertmanagers:
        - static_configs:
            - targets: []

    scrape_configs:
      - job_name: 'provisioning-rag'
        static_configs:
          - targets: ['provisioning-rag:8888']
        scrape_interval: 10s
        scrape_timeout: 5s

      - job_name: 'kubernetes-apiservers'
        kubernetes_sd_configs:
          - role: endpoints
        scheme: https
        tls_config:
          ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token

      - job_name: 'kubernetes-nodes'
        kubernetes_sd_configs:
          - role: node
        scheme: https
        tls_config:
          ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
