---
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
  name: pdm-api
  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: pdm-api
          replicaCount:
            _default: 1
          port:
            _default: 8080
          command:
            _default: ["/bin/sh", "-ec"]
          args:
            _default:
              - |
                set -a
                [ -f /vault/secrets/documentations-postgresql ] && . /vault/secrets/documentations-postgresql
                [ -f /vault/secrets/documentations-common ] && . /vault/secrets/documentations-common
                [ -f /vault/secrets/documentations-rsa-public ] && export PUBLIC_KEY="$(cat /vault/secrets/documentations-rsa-public)"
                set +a
                exec ./httpserver
          resources:
            requests:
              cpu:
                _default: 25m
              memory:
                _default: 128Mi
          probes:
            liveness:
              enabled: false
            readiness:
              enabled: false
        image:
          name:
            _default: cr.yandex/crp3ccidau046kdj8g9q/pdmv2:prod_38958427
          pullPolicy:
            _default: IfNotPresent
        service:
          enabled: true
          name:
            _default: pdm-svc
          type:
            _default: ClusterIP
          port:
            _default: 80
          targetPort:
            _default: 8080
          portName:
            _default: http
        imagePullSecrets:
          enabled:
            _default: true
          name:
            _default: regcred
        envs:
          - name: USE_EXPERIMENTAL
            value:
              _default: "true"
          - name: POSTGRES_POOL_SIZE
            value:
              _default: "20"
          - name: TRANSMITTALS_BASE_URL
            value:
              _default: mock
          - name: API_ADDRESS
            value:
              _default: 0.0.0.0:8080
          - name: API_ADDRESS_FILE
            value:
              _default: 0.0.0.0:8080
          - name: BUCKET_NAME
            value:
              _default: attachments-storage
          - name: API_HOST_PREFIX
            value:
              _default: /
          - name: APP_NAME
            value:
              _default: pdm_v2
          - name: APP_VERSION
            value:
              _default: "0.0.1"
          - name: ENABLE_PERMISSIONS_FILTER
            value:
              _default: "1"
          - name: PERMISSIONS_FILTER_COMPANIES
            value:
              _default: "[1]"
          - name: TRANSMITTALS_ENABLE
            value:
              _default: "false"
          - name: DRAWINGS_INTERNAL_URL
            value:
              _default: http://drawings-api-service.drawings.svc.cluster.local:80
          - name: ATTACHMENTS_URL
            value:
              _default: http://attachments-service.attachments.svc.cluster.local:8000
          - name: BIM_API_V2_URL
            value:
              _default: http://backend-svc.bim.svc.cluster.local:80/
          - name: BIM_V2_HOST
            value:
              _default: http://backend-svc.bim.svc.cluster.local:80/
          - name: CACHE_CLEANUP_INTERVAL
            value:
              _default: 60s
          - name: CACHE_DEFAULT_EXPIRATION
            value:
              _default: 60s
          - name: DJANGO_HOST
            value:
              _default: http://backend-svc.django.svc.cluster.local:80
          - name: DJANGO_ORIGINATOR
            value:
              _default: docs_prod
          - name: DOCUMENTATION_URL
            value:
              _default: http://backend-api-svc.documentations.svc.cluster.local:80/
          - name: EAV_URL
            value:
              _default: http://backend-svc.eav.svc.cluster.local:80
          - name: ENABLE_OBSERVABILITY
            value:
              _default: "false"
          - name: ENABLE_S3
            value:
              _default: "1"
          - name: ENABLE_SSL
            value:
              _default: "0"
          - name: ENVIRONMENT
            value:
              _default: prod
          - name: FLOWS_URL
            value:
              _default: http://backend-svc.flows.svc.cluster.local:80
          - name: HEIGHT_THUMB_ATTACHMENTS
            value:
              _default: "300"
          - name: HEIGHT_THUMB_STATES
            value:
              _default: "73"
          - name: HTTP_PORT
            value:
              _default: "8080"
          - name: INSPECTIONS_URL
            value:
              _default: http://inspections-service.inspections.svc.cluster.local:80
          - name: LOG_LEVEL
            value:
              _default: INFO
          - name: NOTES_URL
            value:
              _default: ""
          - name: OBSERVABILITY_COLLECTOR_ENDPOINT
            value:
              _default: temp
          - name: READ_WRITE_TIMEOUT_FILE_STREAM
            value:
              _default: 6h
          - name: RELEASES_URL
            value:
              _default: https://gitlab.com
          - name: REMARKS_URL
            value:
              _default: http://remarks-static-service.remarks.svc.cluster.local:8080/remarks
          - name: RESOURCES_URL
            value:
              _default: http://iam-backend.iam.svc.cluster.local:8000
          - name: S3_SERVICE_ACCOUNT
            value:
              _default: /vault/secrets/documentations-s3-account-json
          - name: STATES_URL
            value:
              _default: http://backend-svc.workspaces.svc.cluster.local:80/
          - name: SUBSCRIPTIONS_URL
            value:
              _default: http://backend-svc.subscriptions.svc.cluster.local:80
          - name: SYSTEM_LOG_URL
            value:
              _default: http://api-service.system-log.svc.cluster.local:80
          - name: TARGET_URL
            value:
              _default: http://backend-svc.django.svc.cluster.local:80
          - name: USE_CACHE_IN_FILE_STREAMER
            value:
              _default: "1"
          - name: USE_SUBSCRIPTIONS
            value:
              _default: "false"
          - name: WIDTH_THUMB_ATTACHMENTS
            value:
              _default: "300"
          - name: WIDTH_THUMB_STATES
            value:
              _default: "120"
          - name: WORKFLOWS_IMAGES_VERSION
            value:
              _default: master
          - name: WORKFLOW_IMAGES_VERSION
            value:
              _default: master
          - name: RELEASES_TOKEN
            value:
              _default: "mock"
          - name: WORKFLOW_URL
            value:
              _default: http://backend-svc.processing.svc.cluster.local:80/
          - name: WORKSPACE_BUNDLE_VERSION
            value:
              _default: v1
          - name: WORKSPACE_URL
            value:
              _default: http://backend-svc.workspaces.svc.cluster.local:80/
        podAnnotations:
          _default:
            traffic.sidecar.istio.io/excludeOutboundPorts: "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-postgresql: secrets/data/apps/documentations/postgres
            vault.hashicorp.com/agent-inject-template-documentations-postgresql: |-
              {{- with secret "secrets/data/apps/documentations/postgres" -}}
              POSTGRES_ADDRESS={{ index .Data.data "host" }}
              POSTGRES_PORT={{ index .Data.data "port" }}
              POSTGRES_DB={{ index .Data.data "database" }}
              POSTGRES_USER={{ index .Data.data "username" }}
              POSTGRES_PASSWORD={{ index .Data.data "password" }}
              {{- end -}}
            vault.hashicorp.com/agent-inject-secret-documentations-common: secrets/data/vault/common/django_auth
            vault.hashicorp.com/agent-inject-template-documentations-common: |-
              {{- with secret "secrets/data/vault/common/django_auth" -}}
              DJANGO_BASIC_AUTH={{ index .Data.data "key" }}
              {{- end -}}
            vault.hashicorp.com/agent-inject-secret-documentations-s3-account-json: secrets/data/vault/common/django_auth
            vault.hashicorp.com/agent-inject-template-documentations-s3-account-json: |-
              {{- with secret "secrets/data/vault/common/django_auth" -}}
              {{ index .Data.data "documentations_s3_service_account_json" }}
              {{- end -}}
            vault.hashicorp.com/agent-inject-secret-documentations-rsa-public: secrets/data/vault/common/rsa_keys
            vault.hashicorp.com/agent-inject-template-documentations-rsa-public: |-
              {{- with secret "secrets/data/vault/common/rsa_keys" -}}
              {{ index .Data.data "public_key" }}
              {{- end -}}
