apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease
metadata:
  name: postgresql
  namespace: database
spec:
  interval: 5m
  chart:
    spec:
      chart: postgresql
      version: 12.2.x
      sourceRef:
        kind: HelmRepository
        name: bitnami-charts
        namespace: flux-system
  values:
    auth:
      existingSecret: "pgsql-secrets"
      secretKeys:
        adminPasswordKey: "adminPassword"
        replicationPasswordKey: "replicationPassword"

    serviceMonitor:
      enabled: true
      labels:
        release: kube-prometheus-stack

    volumePermissions:
      enabled: true

    primary:
      persistence:
        existingClaim: "postgresql-pv-claim"

      containerSecurityContext:
        enabled: true
        runAsUser: 10000

      extendedConfiguration: |-
        huge_pages = off
      extraVolumeMounts:
        - name: pg-sample-config
          mountPath: /opt/bitnami/postgresql/share/postgresql.conf.sample
          subPath: postgresql.conf.sample
      extraVolumes:
        - configMap:
            name: pg-sample-config
          name:  pg-sample-config

    extraDeploy:
      - apiVersion: v1
        kind: ConfigMap
        metadata:
          name: pg-sample-config
        data:
          postgresql.conf.sample: |-
            huge_pages = off

    readReplicas:
      containerSecurityContext:
        enabled: true
        runAsUser: 10000