apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
  name: easyai-postgres
  namespace: easyai
  labels:
    app.kubernetes.io/name: easyai-postgres
    app.kubernetes.io/part-of: easyai-ai-gateway
    easyai.io/environment: local-acceptance
spec:
  instances: 2
  imageName: ghcr.io/cloudnative-pg/postgresql:18.4-standard-trixie@sha256:4587df73024408f5b2be9b4dd6ba2ccee8c9e5dc0c9a87c274c292291cc8a68c
  bootstrap:
    initdb:
      database: easyai_ai_gateway
      owner: easyai
      secret:
        name: easyai-postgres-app
      postInitSQL:
        - CREATE EXTENSION IF NOT EXISTS pgcrypto;
  storage:
    storageClass: local-path
    size: 8Gi
  walStorage:
    storageClass: local-path
    size: 2Gi
  affinity:
    enablePodAntiAffinity: true
    podAntiAffinityType: required
    topologyKey: easyai.io/site
    nodeSelector:
      easyai.io/database: "true"
  resources:
    requests:
      cpu: 500m
      memory: 1Gi
    limits:
      cpu: "2"
      memory: 3Gi
  postgresql:
    synchronous:
      method: any
      number: 1
      dataDurability: required
    parameters:
      archive_mode: "off"
      max_connections: "200"
      shared_buffers: 512MB
      wal_compression: "on"
      wal_keep_size: 1GB
  monitoring:
    enablePodMonitor: false
