apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
  name: postgresql
  namespace: postgresql
spec:
  interval: 5m
  timeout: 2h

  install:
    timeout: 2h
    remediation:
      retries: 3

  upgrade:
    timeout: 2h
    remediation:
      retries: 3

  values:
    global:
      security:
        allowInsecureImages: true
      defaultStorageClass: nfs01
      postgresql:
        auth:
          username: ""
          database: ""
          secretKeys:
            userPasswordKey: "postgres-password"
    auth:
      username: ""
      database: ""
      secretKeys:
        userPasswordKey: "postgres-password"
    image:
      registry: cr.yandex/crp3ccidau046kdj8g9q
      repository: contour/postgresql
      tag: 17.0.7
      pullPolicy: Always
    metrics:
      enabled: false
      prometheusRule:
        enabled: false
    primary:
      automountServiceAccountToken: true
      containerSecurityContext:
        readOnlyRootFilesystem: false
      persistence:
        storageClass: nfs01
        size: 20Gi
      customLivenessProbe:
        exec:
          command:
            - /bin/sh
            - -c
            - exec pg_isready -U "postgres" -d postgres -h 127.0.0.1 -p 5432
        initialDelaySeconds: 30
        periodSeconds: 10
        timeoutSeconds: 5
        successThreshold: 1
        failureThreshold: 6
      customReadinessProbe:
        exec:
          command:
            - /bin/sh
            - -c
            - exec pg_isready -U "postgres" -d postgres -h 127.0.0.1 -p 5432
        initialDelaySeconds: 5
        periodSeconds: 10
        timeoutSeconds: 5
        successThreshold: 1
        failureThreshold: 6
      customStartupProbe:
        exec:
          command:
            - /bin/sh
            - -c
            - exec pg_isready -U "postgres" -d postgres -h 127.0.0.1 -p 5432
        initialDelaySeconds: 30
        periodSeconds: 10
        timeoutSeconds: 5
        successThreshold: 1
        failureThreshold: 6
      nodeSelector:
        dedicated: null
        node.deckhouse.io/group: generic
      tolerations:
        - key: dedicated.deckhouse.io
          operator: Equal
          value: generic
    contour:
      enabled: true
      adminUser: "postgres"
      vault:
        enabled: true
        role: postgresql
        authPath: auth/kubernetes
        secretPath: secrets/data/postgresql/admin
        secretKey: postgres-password
        usersSecretPath: secrets/data/postgresql/users
      sharedPreloadLibraries: "timescaledb,pg_stat_statements"
      databases:
        - name: zitadel
          user: zitadel
          passwordKey: zitadel
          extensions: []
          restoreFromDump: false
