# SPDX-License-Identifier: Apache-2.0
# Copyright 2022 The HuggingFace Authors.

# --- common parameters ---
global:
  huggingface:
    ingress:
      domain: us.dev.moon.huggingface.tech
      # ^ the domain contains "dev", not "staging". We don't change for now.
      subdomains:
        datasetsServer: datasets-server

images:
  pullPolicy: IfNotPresent
  pullSecrets: []
  reverseProxy:
    useGlobalRegistry: false
    registry: docker.io
    repository: nginx
    tag: "1.20"
  jobs:
    mongodbMigration:
      registry: huggingface
      useGlobalRegistry: false
      repository: datasets-server-jobs-mongodb_migration
      tag: sha-fb3399a
    cacheMaintenance:
      registry: huggingface
      useGlobalRegistry: false
      repository: datasets-server-jobs-cache_maintenance
      tag: sha-fb3399a
  services:
    admin:
      registry: huggingface
      useGlobalRegistry: false
      repository: datasets-server-services-admin
      tag: sha-fb3399a
    api:
      registry: huggingface
      useGlobalRegistry: false
      repository: datasets-server-services-api
      tag: sha-fb3399a
    rows:
      registry: huggingface
      useGlobalRegistry: false
      repository: datasets-server-services-rows
      tag: sha-fb3399a
    worker:
      registry: huggingface
      useGlobalRegistry: false
      repository: datasets-server-services-worker
      tag: sha-fb3399a

secrets:
  externalSecret:
    enabled: true
    secretName: "datasets-server-staging-secrets"
    secretStoreName: "datasets-server-ephemeral-secretstore"
    parameters:
      MONGO_URL: "hub-ephemeral-datasets-server-mongo-url"
      HF_TOKEN: "hub-ephemeral-datasets-server-hf-token"
      PARQUET_CONVERTER_HF_TOKEN: "hub-ephemeral-datasets-server-parquet-converter-hf-token"
      WEBHOOK_SECRET: "hub-ephemeral-datasets-server-webhook-secret"
      SPAWNING_TOKEN: "hub-ephemeral-datasets-server-spawning-token"
  mongoUrl:
    fromSecret: true
    secretName: "datasets-server-staging-secrets"
  appHfToken:
    fromSecret: true
    secretName: "datasets-server-staging-secrets"
  appParquetConverterHfToken:
    fromSecret: true
    secretName: "datasets-server-staging-secrets"
  hfWebhookSecret:
    fromSecret: false
    secretName: "datasets-server-staging-secrets"
  spawningToken:
    fromSecret: true
    secretName: "datasets-server-staging-secrets"

persistence:
  existingClaim: "nfs-datasets-server-pvc"

cachePersistence:
  existingClaim: "datasets-server-cache-pvc"

parquetPersistence:
  existingClaim: "datasets-server-parquet-pvc"

duckdbPersistence:
  existingClaim: "datasets-server-duckdb-pvc"

monitoring:
  enabled: false

mongodb:
  enabled: false

common:
  # URL of the HuggingFace Hub
  hfEndpoint: "https://huggingface.co"

log:
  # Log level
  level: "DEBUG"

firstRows:
  maxBytes: "200_000"

parquetAndInfo:
  maxDatasetSize: "500_000_000"

# --- jobs (pre-install/upgrade hooks) ---

mongodbMigration:
  resources:
    requests:
      cpu: 100m
    limits:
      cpu: 1

# --- jobs (post-upgrade hooks) ---

cacheMaintenance:
  action: "skip"
  # ^ allowed values are {skip,backfill,upgrade}
  log:
    level: "debug"
  backfill:
    error_codes_to_retry: ""
  resources:
    requests:
      cpu: 100m
    limits:
      cpu: 1

# --- cron jobs  ---
backfill:
  enabled: false

metricsCollector:
  action: "collect-metrics"
  schedule: "*/2 * * * *"
  # every two minutes
  nodeSelector: {}
  resources:
    requests:
      cpu: 1
    limits:
      cpu: 1
      memory: "512Mi"
  tolerations: []

# --- storage admin (to manually inspect the storage, in /data) ---

storageAdmin:
  replicas: 1
  resources:
    requests:
      cpu: 50m
      memory: "64Mi"
    limits:
      cpu: 1
      memory: "256Mi"

# --- reverse proxy ---

reverseProxy:
  replicas: 1
  resources:
    requests:
      cpu: 100m
      memory: "64Mi"
    limits:
      cpu: 1
      memory: "256Mi"
  service:
    type: NodePort
  tolerations:
    - key: CriticalAddonsOnly
      operator: Equal

ingress:
  tls:
    - hosts:
      - "datasets-server.us.dev.moon.huggingface.tech"
  annotations:
    # Link to Route53 - we could set any subdomain to us.dev.moon.huggingface.tech (common zone to the k8s cluster)
    external-dns.alpha.kubernetes.io/hostname: "datasets-server.us.dev.moon.huggingface.tech"
    alb.ingress.kubernetes.io/load-balancer-name: "hub-datasets-server-staging"
    alb.ingress.kubernetes.io/tags: "Env=staging,Project=datasets-server,Terraform=true"
    alb.ingress.kubernetes.io/healthcheck-path: "/healthcheck"
    alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80, "HTTPS": 443}]'
    alb.ingress.kubernetes.io/scheme: "internet-facing"
    alb.ingress.kubernetes.io/group.name: "datasets-server"
    kubernetes.io/ingress.class: "alb"

# --- services ---

admin:
  uvicornNumWorkers: "1"

  replicas: 1
  service:
    type: NodePort
  resources:
    requests:
      cpu: 100m
      memory: "512Mi"
    limits:
      cpu: 1
      memory: "4Gi"

api:
  uvicornNumWorkers: "1"

  replicas: 1
  service:
    type: NodePort
  resources:
    requests:
      cpu: 100m
      memory: "512Mi"
    limits:
      cpu: 1
      memory: "4Gi"

rows:
  uvicornNumWorkers: "1"

  replicas: 1
  service:
    type: NodePort
  resources:
    requests:
      cpu: 100m
      memory: "512Mi"
    limits:
      cpu: 1
      memory: "4Gi"

workers:
  -
    deployName: "all"
    workerDifficultyMax: 100
    workerDifficultyMin: 0
    workerJobTypesBlocked: ""
    workerJobTypesOnly: ""
    nodeSelector: {}
    replicas: 1
    resources:
      requests:
        cpu: 100m
        memory: "512Mi"
      limits:
        cpu: 1
        memory: "4Gi"
    tolerations: []
  -
    deployName: "light"
    workerDifficultyMax: 40
    workerDifficultyMin: 0
    workerJobTypesBlocked: ""
    workerJobTypesOnly: ""
    nodeSelector: {}
    replicas: 1
    resources:
      requests:
        cpu: 100m
        memory: "512Mi"
      limits:
        cpu: 1
        memory: "4Gi"
    tolerations: []
