Files
Homelabv4/apps/gitlab/manifests/pgbouncer-pooler.yaml
T
2026-03-09 20:21:35 -05:00

117 lines
3.0 KiB
YAML

---
# PgBouncer Pooler for GitLab PostgreSQL
# Managed by CloudNativePG Operator
apiVersion: postgresql.cnpg.io/v1
kind: Pooler
metadata:
name: pgbouncer-gitlab
namespace: gitlab
spec:
cluster:
name: pg-gitlab
# Number of PgBouncer instances (keep small; GitLab points directly at CNPG RW service)
instances: 1
# PgBouncer configuration
type: rw # Read-Write pooler (connects to primary)
pgbouncer:
poolMode: transaction
authQuerySecret:
name: pg-gitlab-app
# Use custom user_search function for SCRAM-SHA-256 authentication
# This function is created by gitlab-bootstrap.sh script
authQuery: "SELECT usename, passwd FROM public.user_search($1)"
parameters:
max_client_conn: "2000"
default_pool_size: "50"
reserve_pool_size: "10"
server_idle_timeout: "600" # Keep connections alive for 10 minutes
log_connections: "1"
log_disconnections: "1"
log_pooler_errors: "1"
stats_period: "60"
# Template for PgBouncer pods
template:
metadata:
labels:
app: pgbouncer-gitlab
spec:
containers:
- name: pgbouncer
resources:
requests:
cpu: 25m
memory: 256Mi
limits:
memory: 512Mi
# Anti-affinity to spread PgBouncer pods across nodes
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchLabels:
app: pgbouncer-gitlab
topologyKey: kubernetes.io/hostname
---
# Read-only Pooler for Database Load Balancing
apiVersion: postgresql.cnpg.io/v1
kind: Pooler
metadata:
name: pgbouncer-gitlab-ro
namespace: gitlab
spec:
cluster:
name: pg-gitlab
instances: 3
type: ro # Read-Only pooler (connects to replicas)
pgbouncer:
poolMode: transaction
authQuerySecret:
name: pg-gitlab-app
# Use custom user_search function for SCRAM-SHA-256 authentication
# This function is created by gitlab-bootstrap.sh script
authQuery: "SELECT usename, passwd FROM public.user_search($1)"
parameters:
max_client_conn: "2000"
default_pool_size: "50"
reserve_pool_size: "10"
max_db_connections: "100"
server_idle_timeout: "600" # Keep connections alive for 10 minutes
log_connections: "1"
log_disconnections: "1"
template:
metadata:
labels:
app: pgbouncer-gitlab-ro
spec:
containers:
- name: pgbouncer
resources:
requests:
cpu: 25m
memory: 256Mi
limits:
memory: 512Mi
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchLabels:
app: pgbouncer-gitlab-ro
topologyKey: kubernetes.io/hostname