---
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
  name: documentations-hasher
  namespace: documentations
spec:
  interval: 10m
  chart:
    spec:
      chart: universal-chart
      version: "0.1.9"
      sourceRef:
        kind: HelmRepository
        name: yc-oci-charts
        namespace: flux-system
      interval: 10m
  install:
    remediation:
      retries: 3
  upgrade:
    remediation:
      retries: 3
  values:
    global:
      env: _default
    services:
      backend:
        enabled: true
        serviceAccount:
          enabled:
            _default: true
          name:
            _default: documentations-vault
        deployment:
          enabled: true
          name:
            _default: hasher
          replicaCount:
            _default: 1
          port:
            _default: 8080
          command:
            _default: ["/bin/sh", "-ec"]
          args:
            _default:
              - |
                set -a
                [ -f /vault/secrets/documentations-hasher-rabbitmq ] && . /vault/secrets/documentations-hasher-rabbitmq
                [ -f /vault/secrets/documentations-hasher-s3 ] && . /vault/secrets/documentations-hasher-s3
                set +a
                run-amqp-server
          resources:
            requests:
              cpu:
                _default: 25m
              memory:
                _default: 128Mi
          probes:
            liveness:
              enabled: false
            readiness:
              enabled: false
        image:
          name:
            _default: cr.yandex/crp3ccidau046kdj8g9q/hasher:production_3f853d3a
          pullPolicy:
            _default: IfNotPresent
        service:
          enabled: true
          name:
            _default: hasher-service
          type:
            _default: ClusterIP
          port:
            _default: 8080
          targetPort:
            _default: 8080
          portName:
            _default: http
        imagePullSecrets:
          enabled:
            _default: true
          name:
            _default: regcred
        envs:
          - name: HASHER_APP__LOG_LEVEL
            value:
              _default: INFO

          - name: HASHER_APP__NUM_WORKERS
            value:
              _default: "4"

          - name: HASHER_AMQP__HOST
            value:
              _default: rabbitmq.rabbitmq.svc.cluster.local

          - name: HASHER_AMQP__PORT
            value:
              _default: "5672"

          - name: HASHER_AMQP__ROUTING__TASK_INPUT_QUEUE
            value:
              _default: hash.compute.normal.tasks

          - name: HASHER_AMQP__ROUTING__TASK_INPUT_EXCHANGE
            value:
              _default: hash.compute

          - name: HASHER_AMQP__ROUTING__TASK_INPUT_EXCHANGE_TYPE
            value:
              _default: direct

          - name: HASHER_AMQP__ROUTING__TASK_INPUT_ROUTING_KEY
            value:
              _default: hash.compute.normal

          - name: HASHER_S3__MAX_POOL_CONNECTIONS
            value:
              _default: "10"

          - name: HASHER_S3__CONNECT_TIMEOUT
            value:
              _default: "10"

          - name: HASHER_S3__READ_TIMEOUT
            value:
              _default: "30"

          - name: HASHER_S3__REGION_NAME
            value:
              _default: ru-central1

          - name: HASHER_S3__USE_SSL
            value:
              _default: "true"

          - name: HASHER_S3__VERIFY
            value:
              _default: "true"

        podAnnotations:
          _default:
            traffic.sidecar.istio.io/excludeOutboundPorts: "4317,4318,9411,8200"
            vault.hashicorp.com/agent-init-first: "true"
            vault.hashicorp.com/agent-inject: "true"
            vault.hashicorp.com/agent-pre-populate-only: "true"
            vault.hashicorp.com/auth-path: auth/kubernetes
            vault.hashicorp.com/role: documentations
            vault.hashicorp.com/agent-inject-secret-documentations-hasher-rabbitmq: secrets/data/rabbitmq/apps/cde
            vault.hashicorp.com/agent-inject-template-documentations-hasher-rabbitmq: |-
              {{- with secret "secrets/data/rabbitmq/apps/cde" -}}
              HASHER_AMQP__USERNAME={{ index .Data.data "username" }}
              HASHER_AMQP__PASSWORD={{ index .Data.data "password" }}
              HASHER_AMQP__VHOST={{ index .Data.data "vhost" }}
              {{- end -}}
            vault.hashicorp.com/agent-inject-secret-documentations-hasher-s3: secrets/data/minio/apps/documentations
            vault.hashicorp.com/agent-inject-template-documentations-hasher-s3: |-
              {{- with secret "secrets/data/minio/apps/documentations" -}}
              HASHER_S3__ENDPOINT={{ index .Data.data.client "endpoint" }}
              HASHER_S3__ACCESS_KEY={{ index .Data.data "access_key" }}
              HASHER_S3__SECRET_KEY={{ index .Data.data "secret_key" }}
              {{- end -}}

        commitSha: ""
        gitlabUri: ""
        gitlabJobUrl: ""
        owner: ""
