---
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
  name: backend
  namespace: drawings

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: drawings-vault

        image:
          name:
            _default: cr.yandex/crp3ccidau046kdj8g9q/drawings-api:015e68e1b2a3dcc13f0b405e1f761b154a825d24
          pullPolicy:
            _default: IfNotPresent

        deployment:
          enabled: true

          name:
            _default: backend

          replicaCount:
            _default: 1

          port:
            _default: 8080

          command:
            _default: ["/bin/sh", "-ec"]
          args:
            _default:
              - |
                set -a
                [ -f /vault/secrets/drawings-db ] && . /vault/secrets/drawings-db
                set +a
                exec ./entrypoint.sh

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

        service:
          enabled: true

          name:
            _default: backend-service

          type:
            _default: ClusterIP

          port:
            _default: 8000

          targetPort:
            _default: 8000

          portName:
            _default: http

        imagePullSecrets:
          enabled:
            _default: true
          name:
            _default: regcred

        envs:
          - name: POSTGRES_POOL_SIZE
            value:
              _default: "3"

          - name: API_ADDRESS
            value:
              _default: "0.0.0.0:8000"

          - name: ENABLE_SSL
            value:
              _default: "0"

        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: drawings
            vault.hashicorp.com/agent-inject-secret-drawings-db: secrets/data/apps/drawings/postgres
            vault.hashicorp.com/agent-inject-template-drawings-db: |-
              {{- with secret "secrets/data/apps/drawings/postgres" -}}
              POSTGRES_ADDRESS={{ index .Data.data "host" }}:{{ index .Data.data "port" }}
              POSTGRES_DB={{ index .Data.data "database" }}
              POSTGRES_USER={{ index .Data.data "username" }}
              POSTGRES_PASSWORD={{ index .Data.data "password" }}
              {{- end -}}

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