apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
  name: trino
  namespace: trino
spec:
  interval: 5m
  timeout: 20m
  chart:
    spec:
      chart: trino-contour
      version: "0.33.1"
  postRenderers:
    - kustomize:
        patches:
          - target:
              group: apps
              version: v1
              kind: Deployment
              name: trino-worker
            patch: |
              - op: replace
                path: /spec/template/spec/nodeSelector
                value:
                  kubernetes.io/hostname: um-sarex-k8s-worker-04
              - op: add
                path: /spec/template/spec/tolerations
                value:
                  - key: dedicated.processing
                    operator: Equal
                    value: processing
                    effect: NoExecute
  values:
    nameOverride: trino
    coordinatorNameOverride: trino-coordinator
    workerNameOverride: trino-worker
    imagePullSecrets:
      - name: regcred
    image:
      registry: cr.yandex
      repository: crp3ccidau046kdj8g9q/contour/trino/trino
      tag: "432"
    serviceAccount:
      create: true
      name: trino
    gateway:
      enabled: false
    virtualService:
      enabled: false
    vault:
      enabled: true
      role: trino
      authPath: auth/kubernetes
      kvVersion: 2
      secrets:
        - env: TRINO_POSTGRES_HOST
          path: secrets/data/vault/apps/trino
          key: TRINO_POSTGRES_HOST
        - env: TRINO_POSTGRES_PORT
          path: secrets/data/vault/apps/trino
          key: TRINO_POSTGRES_PORT
        - env: TRINO_POSTGRES_USER
          path: secrets/data/vault/apps/trino
          key: TRINO_POSTGRES_USER
        - env: TRINO_POSTGRES_PASSWORD
          path: secrets/data/vault/apps/trino
          key: TRINO_POSTGRES_PASSWORD
        - env: TRINO_INTERNAL_SHARED_SECRET
          path: secrets/data/vault/apps/trino
          key: TRINO_INTERNAL_SHARED_SECRET
    stronghold:
      enabled: false
    server:
      workers: 1
      log:
        trino:
          level: INFO
      config:
        authenticationType: ""
        query:
          maxMemory: 20GB
      autoscaling:
        enabled: false
    additionalLogProperties: []
    auth:
      passwordAuthSecret: ""
    env: []
    envFrom: []
    catalogs:
      sarex_db: |
        connector.name=postgresql
        connection-url=jdbc:postgresql://${ENV:TRINO_POSTGRES_HOST}:${ENV:TRINO_POSTGRES_PORT}/sarex_db?sslmode=disable
        connection-user=${ENV:TRINO_POSTGRES_USER}
        connection-password=${ENV:TRINO_POSTGRES_PASSWORD}
        postgresql.array-mapping=AS_JSON
      flows_db: |
        connector.name=postgresql
        connection-url=jdbc:postgresql://${ENV:TRINO_POSTGRES_HOST}:${ENV:TRINO_POSTGRES_PORT}/flows_db?sslmode=disable
        connection-user=${ENV:TRINO_POSTGRES_USER}
        connection-password=${ENV:TRINO_POSTGRES_PASSWORD}
        postgresql.array-mapping=AS_JSON
      issues_db: |
        connector.name=postgresql
        connection-url=jdbc:postgresql://${ENV:TRINO_POSTGRES_HOST}:${ENV:TRINO_POSTGRES_PORT}/issues_db?sslmode=disable
        connection-user=${ENV:TRINO_POSTGRES_USER}
        connection-password=${ENV:TRINO_POSTGRES_PASSWORD}
        postgresql.array-mapping=AS_JSON
      workspaces_db: |
        connector.name=postgresql
        connection-url=jdbc:postgresql://${ENV:TRINO_POSTGRES_HOST}:${ENV:TRINO_POSTGRES_PORT}/workspaces_db?sslmode=disable
        connection-user=${ENV:TRINO_POSTGRES_USER}
        connection-password=${ENV:TRINO_POSTGRES_PASSWORD}
        postgresql.array-mapping=AS_JSON
      resources_db: |
        connector.name=postgresql
        connection-url=jdbc:postgresql://${ENV:TRINO_POSTGRES_HOST}:${ENV:TRINO_POSTGRES_PORT}/resources_db?sslmode=disable
        connection-user=${ENV:TRINO_POSTGRES_USER}
        connection-password=${ENV:TRINO_POSTGRES_PASSWORD}
        postgresql.array-mapping=AS_JSON
      pm_db: |
        connector.name=postgresql
        connection-url=jdbc:postgresql://${ENV:TRINO_POSTGRES_HOST}:${ENV:TRINO_POSTGRES_PORT}/pm_db?sslmode=disable
        connection-user=${ENV:TRINO_POSTGRES_USER}
        connection-password=${ENV:TRINO_POSTGRES_PASSWORD}
        postgresql.array-mapping=AS_JSON
      eav_db: |
        connector.name=postgresql
        connection-url=jdbc:postgresql://${ENV:TRINO_POSTGRES_HOST}:${ENV:TRINO_POSTGRES_PORT}/eav_db?sslmode=disable
        connection-user=${ENV:TRINO_POSTGRES_USER}
        connection-password=${ENV:TRINO_POSTGRES_PASSWORD}
        postgresql.array-mapping=AS_JSON
      inspections_db: |
        connector.name=postgresql
        connection-url=jdbc:postgresql://${ENV:TRINO_POSTGRES_HOST}:${ENV:TRINO_POSTGRES_PORT}/inspections_db?sslmode=disable
        connection-user=${ENV:TRINO_POSTGRES_USER}
        connection-password=${ENV:TRINO_POSTGRES_PASSWORD}
        postgresql.array-mapping=AS_JSON
      documentations_db: |
        connector.name=postgresql
        connection-url=jdbc:postgresql://${ENV:TRINO_POSTGRES_HOST}:${ENV:TRINO_POSTGRES_PORT}/documentations_db?sslmode=disable
        connection-user=${ENV:TRINO_POSTGRES_USER}
        connection-password=${ENV:TRINO_POSTGRES_PASSWORD}
        postgresql.array-mapping=AS_JSON
      clickhouse_db: |
        connector.name=tpch
        tpch.splits-per-node=4
      hive: |
        connector.name=tpch
        tpch.splits-per-node=4
    coordinator:
      jvm:
        maxHeapSize: 6G
      config:
        memory:
          heapHeadroomPerNode: 1GB
        query:
          maxMemoryPerNode: 4GB
      resources:
        requests:
          cpu: 500m
          memory: 6Gi
        limits:
          memory: 8Gi
      nodeSelector: null
      tolerations: []
    worker:
      jvm:
        maxHeapSize: 24G
      config:
        memory:
          heapHeadroomPerNode: 4GB
        query:
          maxMemoryPerNode: 20GB
      resources:
        requests:
          cpu: 500m
          memory: 24Gi
        limits:
          memory: 32Gi
      nodeSelector:
        kubernetes.io/hostname: um-sarex-k8s-worker-04
      tolerations:
        - key: dedicated.processing
          operator: Equal
          value: processing
          effect: NoExecute
