---
# PgBouncer pooler in front of the cheeztv-postgres cluster. Jellyfin connects
# here (cheeztv-postgres-pooler:5432) rather than the -rw service so EF Core's
# connection churn is absorbed by the pool.
apiVersion: postgresql.cnpg.io/v1
kind: Pooler
metadata:
  name: cheeztv-postgres-pooler
  namespace: cheeztv
spec:
  cluster:
    name: cheeztv-postgres
  instances: 2
  pgbouncer:
    parameters:
      default_pool_size: "50"
      max_client_conn: "200"
    paused: false
    poolMode: session
  template:
    metadata:
      labels:
        app: cheeztv-pooler
    spec:
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            - labelSelector:
                matchExpressions:
                  - key: app
                    operator: In
                    values:
                      - cheeztv-pooler
              topologyKey: kubernetes.io/hostname
      containers: []
  type: rw
