---
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
  name: measurements
  namespace: measurements
spec:
  interval: 5m
  timeout: 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

        # в yc-ecp S3-настройки приходят из Secret, а не через Vault Agent,
        # поэтому serviceAccount, vault-аннотации и обёртка entrypoint не нужны
        serviceAccount:
          enabled:
            _default: false

        image:
          name:
            _default: cr.yandex/crp3ccidau046kdj8g9q/measurements:prod_6070cd4d
          pullPolicy:
            _default: Always

        deployment:
          enabled: true

          name:
            _default: measurement

          replicaCount:
            _default: 2

          port:
            _default: 8000

          # entrypoint.sh запускает gunicorn без --access-logfile, поэтому
          # запросы не попадают в лог; подменяем команду целиком
          command:
            _default: ["/bin/bash", "-ec"]
          args:
            _default:
              - gunicorn -w 4 -k uvicorn.workers.UvicornWorker -b 0.0.0.0:8000 --timeout 240 --access-logfile - --access-logformat '%(h)s "%(r)s" %(s)s %(b)s %(M)sms' measurements.main:app

          resources:
            requests:
              cpu:
                _default: 25m
              memory:
                _default: 128Mi

          probes:
            liveness:
              enabled: false
            readiness:
              enabled: false

        service:
          enabled: true

          name:
            _default: measurement-service

          type:
            _default: ClusterIP

          port:
            _default: 8000

          targetPort:
            _default: 8000

          portName:
            _default: http

        imagePullSecrets:
          enabled:
            _default: true
          name:
            _default: dockerhub


        secretEnvs:
          - name: S3_JSON_SETTINGS
            secretName:
              _default: "s3-json-settings"
            secretKey: "S3_JSON_SETTINGS"
