version: 1
kind: UniDeskHostK8sDeployment
metadata:
  name: unidesk-host
  owner: unidesk

target:
  id: NC01
  kubeContext: local-k3s
  namespace: unidesk

runtime:
  environment: prod
  deployRef: config/unidesk-host-k8s.yaml
  repository: https://github.com/pikasTech/unidesk
  commit: local-host-k8s
  publicHost: 152.53.229.148
  noProxy: localhost,127.0.0.1,::1,.svc,.svc.cluster.local,hyueapi.com,.hyueapi.com

delivery:
  enabled: true
  changeDetection:
    sharedImagePaths:
      - src/components/shared
  services:
    - id: todo-note
      serviceRef: services.todoNote
      imagePaths:
        - src/components/microservices/todo-note/Dockerfile
        - src/components/microservices/todo-note/bun.lock
        - src/components/microservices/todo-note/package.json
        - src/components/microservices/todo-note/src
        - src/components/microservices/todo-note/tsconfig.json
      image:
        repository: 127.0.0.1:5000/unidesk/todo-note
      gitops:
        manifestPath: deploy/gitops/unidesk-host/todo-note.yaml
        releaseStatePath: deploy/gitops-state/unidesk-host/todo-note.json
    - id: decision-center
      serviceRef: services.decisionCenter
      imagePaths:
        - src/components/microservices/decision-center/Dockerfile
        - src/components/microservices/decision-center/package.json
        - src/components/microservices/decision-center/src
        - src/components/microservices/decision-center/tsconfig.json
      image:
        repository: 127.0.0.1:5000/unidesk/decision-center
      gitops:
        manifestPath: deploy/gitops/unidesk-host/decision-center.yaml
        releaseStatePath: deploy/gitops-state/unidesk-host/decision-center.json
  build:
    networkMode: host
    proxy:
      http: http://127.0.0.1:10808
      https: http://127.0.0.1:10808
      all: http://127.0.0.1:10808
      noProxy:
        - localhost
        - 127.0.0.1
        - "::1"
        - 127.0.0.1:5000
        - localhost:5000
        - .svc
        - .svc.cluster.local
        - .cluster.local
  gitops:
    readUrl: http://git-mirror-http.devops-infra.svc.cluster.local:8080/pikasTech/unidesk.git
    writeUrl: http://git-mirror-write.devops-infra.svc.cluster.local:8080/pikasTech/unidesk.git
    branch: unidesk-host-gitops
    resources:
      - id: hwlab-nc01-v03-runtime-gitops-scripts
        renderer: hwlab-runtime-gitops-scripts
        configRef: config/hwlab-node-lanes.yaml#lanes.v03.targets.NC01
        manifestPath: deploy/gitops/unidesk-host/hwlab-nc01-v03-runtime-gitops-scripts.yaml
        namespace: hwlab-ci
      - id: hwlab-nc01-production-runtime-gitops-scripts
        renderer: hwlab-runtime-gitops-scripts
        configRef: config/hwlab-node-lanes.yaml#lanes.production.targets.NC01
        manifestPath: deploy/gitops/unidesk-host/hwlab-nc01-production-runtime-gitops-scripts.yaml
        namespace: hwlab-ci
    author:
      name: UniDesk Host CI
      email: unidesk-host-ci@unidesk.local

images:
  postgres: postgres:16-alpine
  backendCore: unidesk-backend-core:host-k8s
  frontend: unidesk-frontend:host-k8s
  decisionCenter: unidesk-decision-center:host-k8s
  todoNote: unidesk-todo-note:host-k8s

database:
  mode: host-native
  host: 10.42.0.1
  serviceName: database
  pvcName: unidesk-postgres-data
  storageSize: 15Gi
  storageClassName: local-path
  port: 5432
  resources:
    requests:
      cpu: 100m
      memory: 256Mi
    limits:
      cpu: 500m
      memory: 512Mi

services:
  backendCore:
    deploymentName: backend-core
    serviceName: backend-core
    providerPublicServiceName: backend-core-provider
    containerPort: 8080
    providerPort: 8081
    providerDataPort: 8082
    providerPublicPort: 18082
    providerDataPublicPort: 18084
    logFile: /var/log/unidesk/backend-core.jsonl
    resources:
      requests:
        cpu: 100m
        memory: 192Mi
      limits:
        memory: 768Mi
  frontend:
    deploymentName: frontend
    serviceName: frontend
    containerPort: 8080
    publicPort: 18081
    logFile: /var/log/unidesk/frontend.jsonl
    resources:
      requests:
        cpu: 80m
        memory: 128Mi
      limits:
        memory: 512Mi
  decisionCenter:
    serviceId: decision-center
    imageRef: images.decisionCenter
    storageEnvPrefix: DECISION_CENTER
    replicas: 1
    deploymentName: decision-center
    serviceName: decision-center
    containerName: decision-center
    containerPort: 4277
    healthPath: /health
    livePath: /live
    logFile: /var/log/unidesk/decision-center.jsonl
    database:
      sourceRef:
        path: /root/.unidesk/.state/secrets/decision-center/nc01-db.env
        key: DATABASE_URL
      secretName: decision-center-runtime-secrets
      secretKey: DATABASE_URL
    storage:
      primary: github-repo
      healthRefreshSeconds: 300
      github:
        repo: pikasTech/decision-center-data
        sshUrl: git@github.com:pikasTech/decision-center-data.git
        branch: main
        basePath: data
        worktreePath: /var/lib/unidesk/decision-center/repo
        commitMessagePrefix: "decision-center:"
        author:
          name: UniDesk Decision Center
          email: decision-center@unidesk.local
        ssh:
          secretName: decision-center-github-ssh
          mountPath: /var/lib/unidesk/decision-center/ssh
          privateKey:
            sourceRef:
              path: /root/.ssh/id_ed25519_github_codex
            secretKey: ssh-privatekey
          knownHosts:
            sourceRef:
              path: /root/.ssh/known_hosts
            secretKey: known_hosts
    repository:
      url: https://github.com/pikasTech/unidesk
      dockerfile: src/components/microservices/decision-center/Dockerfile
      worktreePath: /root/unidesk
    frontend:
      route: /apps/decision-center
      integrated: true
    resources:
      requests:
        cpu: 50m
        memory: 96Mi
      limits:
        memory: 512Mi
  todoNote:
    serviceId: todo-note
    imageRef: images.todoNote
    storageEnvPrefix: TODO_NOTE
    replicas: 1
    deploymentName: todo-note
    serviceName: todo-note
    containerName: todo-note
    containerPort: 4288
    healthPath: /health
    livePath: /live
    logFile: /var/log/unidesk/todo-note.jsonl
    database:
      sourceRef:
        path: /root/.unidesk/.state/secrets/decision-center/nc01-db.env
        key: DATABASE_URL
      secretName: decision-center-runtime-secrets
      secretKey: DATABASE_URL
    storage:
      primary: github-repo
      github:
        repo: pikasTech/decision-center-data
        sshUrl: git@github.com:pikasTech/decision-center-data.git
        branch: main
        basePath: todo-note
        worktreePath: /var/lib/unidesk/todo-note/repo
        commitMessagePrefix: "todo-note:"
        author:
          name: UniDesk Todo Note
          email: todo-note@unidesk.local
        ssh:
          secretName: decision-center-github-ssh
          mountPath: /var/lib/unidesk/todo-note/ssh
          privateKey:
            sourceRef:
              path: /root/.ssh/id_ed25519_github_codex
            secretKey: ssh-privatekey
          knownHosts:
            sourceRef:
              path: /root/.ssh/known_hosts
            secretKey: known_hosts
    repository:
      url: https://github.com/pikasTech/unidesk
      dockerfile: src/components/microservices/todo-note/Dockerfile
      worktreePath: /root/unidesk
    frontend:
      route: /apps/todo-note
      integrated: true
    reminder:
      enabled: true
      leadMinutes: 10
      scanIntervalMs: 30000
      transport:
        type: claudeqq
        baseUrl: http://backend-core:8080/api/microservices/claudeqq/proxy
        targetType: private
        userId: "645275593"
        groupId: ""
        timeoutMs: 15000
        sendAttempts: 3
    resources:
      requests:
        cpu: 50m
        memory: 96Mi
      limits:
        memory: 768Mi

runtimeConfig:
  heartBeatTimeoutMs: "30000"
  taskPendingTimeoutMs: "600000"
  databasePoolMax: "4"
  sessionTtlSeconds: "28800"
  sshClientRouteAllowlist: "*"
  microservicesJson: "[]"

runtimeAuth:
  sourceRef:
    path: /root/.unidesk/.env/unidesk.auth
    format: linePair
    usernameLine: 1
    passwordLine: 2
  target:
    route: NC01:k3s
    namespace: unidesk
    configMapName: unidesk-runtime-config
    usernameKey: AUTH_USERNAME
    secretName: unidesk-runtime-secrets
    passwordKey: AUTH_PASSWORD
    rolloutDeployment: frontend

runtimeSecrets:
  sourceRef:
    path: /root/.unidesk/.state/secrets/unidesk-host-k8s.env
  target:
    name: unidesk-runtime-secrets
    keys:
      postgresUser: POSTGRES_USER
      postgresPassword: POSTGRES_PASSWORD
      postgresDb: POSTGRES_DB
      databaseUrl: DATABASE_URL
      providerToken: PROVIDER_TOKEN
      sshClientToken: UNIDESK_SSH_CLIENT_TOKEN
      authPassword: AUTH_PASSWORD
      sessionSecret: SESSION_SECRET
