Skip to content

Commit 57c7636

Browse files
leonardocephiscogbartolinimnenciafcanovai
authored
feat: add Pooler resource and controller for PgBouncer
Add a new `Pooler` API and the relative controller, enabling the user to create a PgBouncer deployment to be used as a connection pooler for a local PostgreSQL `Cluster`. The PgBouncer controller supports: - logging in JSON format - Prometheus exporter for stats, pools, and lists. - TLS connections with clients and the server - integration with the Cluster TLS authentication for the `auth_user` connections - password authentication for clients - High Availability - PodTemplates - control of `PAUSE` and `RESUME` through declarative configuration Details in `docs/src/connection_pooling.md` Co-authored-by: Philippe Scorsolini <philippe.scorsolini@enterprisedb.com> Co-authored-by: Gabriele Bartolini <gabriele.bartolini@enterprisedb.com> Co-authored-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com> Co-authored-by: Francesco Canovai <francesco.canovai@enterprisedb.com>
1 parent 2f04ac6 commit 57c7636

File tree

84 files changed

+12348
-113
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+12348
-113
lines changed

.wordlist-en-custom.txt

+31-1
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@ AdditionalPodAffinity
66
AdditionalPodAntiAffinity
77
AffinityConfiguration
88
Anand
9+
AuthQuery
10+
AuthQuerySecret
911
Autoscaler
1012
AzureCredentials
1113
Azurite
14+
BDR
1215
BackupConfiguration
1316
BackupList
1417
BackupPhase
@@ -17,7 +20,6 @@ BackupStatus
1720
BarmanObjectStoreConfiguration
1821
Bartolini
1922
Battiato
20-
BDR
2123
BootstrapConfiguration
2224
BootstrapInitDB
2325
BootstrapPgBaseBackup
@@ -87,6 +89,7 @@ Gi
8789
Golang
8890
GolangCI
8991
Grafana
92+
HH
9093
IfNotPresent
9194
InfoSec
9295
JSON
@@ -132,13 +135,26 @@ PVCs
132135
Patroni
133136
PersistentVolumeClaim
134137
PersistentVolumeClaimSpec
138+
PgBouncer's
139+
PgBouncerPoolMode
140+
PgBouncerSpec
141+
PgbouncerIntegrationStatus
135142
Philippe
136143
PodAffinity
137144
PodAntiAffinity
138145
PodAntiAffinityType
139146
PodDisruptionBudget
147+
PodMeta
140148
PodMonitor
149+
PodSpec
141150
PodStatus
151+
PodTemplateSpec
152+
Pooler
153+
PoolerIntegrations
154+
PoolerList
155+
PoolerSpec
156+
PoolerStatus
157+
PoolerType
142158
Postgres
143159
PostgresConfiguration
144160
PrimaryUpdateStrategy
@@ -200,6 +216,7 @@ WALs
200216
Wadle
201217
WalBackupConfiguration
202218
YXBw
219+
YYYY
203220
accessKeyId
204221
accessModes
205222
adc
@@ -274,10 +291,12 @@ commandOutput
274291
conf
275292
config
276293
config's
294+
configMap
277295
configmap
278296
configmapkeyselector
279297
configmaps
280298
configs
299+
conn
281300
connectionParameters
282301
containerPort
283302
coreos
@@ -309,6 +328,7 @@ ddl
309328
de
310329
declaratively
311330
defaultMode
331+
defaultPoolSize
312332
destinationPath
313333
dev
314334
devel
@@ -332,6 +352,7 @@ externalClusters
332352
facto
333353
failover
334354
fastpath
355+
fd
335356
ffd
336357
filesystem
337358
fio
@@ -409,6 +430,7 @@ malcolm
409430
mallocs
410431
matchExpressions
411432
matchLabels
433+
maxClientConnections
412434
maxSyncReplicas
413435
mcache
414436
md
@@ -450,6 +472,8 @@ openshift
450472
operatorframework
451473
operatorgroups
452474
operatorhub
475+
parseable
476+
passwd
453477
pc
454478
pdf
455479
persistentvolumeclaim
@@ -459,6 +483,7 @@ pgaudit
459483
pgbarman
460484
pgbasebackup
461485
pgbench
486+
pgbouncer
462487
pgdata
463488
pgpass
464489
pgstatstatements
@@ -472,6 +497,9 @@ podAntiAffinity
472497
podAntiAffinityType
473498
podMetricsEndpoints
474499
podmonitor
500+
poolMode
501+
pooler
502+
poolers
475503
pos
476504
postInitSQL
477505
postgres
@@ -492,6 +520,7 @@ pvc
492520
pvcCount
493521
pvcTemplate
494522
quantile
523+
queryable
495524
quickstart
496525
rbac
497526
readService
@@ -548,6 +577,7 @@ sslrootcert
548577
sso
549578
startDelay
550579
startedAt
580+
stderr
551581
stdout
552582
stopDelay
553583
stoppedAt

DEVELOPERS.md

+6
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ export GPG_AGENT_INFO=~/.gnupg/S.gpg-agent::1
6363
export GPG_TTY=$(tty)
6464
```
6565

66+
You also need to set:
67+
68+
```
69+
export GOPATH="${HOME}/go"
70+
```
71+
6672
### Setting your docker engine
6773

6874
Please allow a reasonable amount of memory for Docker.

PROJECT

+3
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,7 @@ resources:
1919
- group: postgresql
2020
kind: ScheduledBackup
2121
version: v1
22+
- group: postgresql
23+
kind: Pooler
24+
version: v1
2225
version: "2"

api/v1/cluster_types.go

+16
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ const (
7777

7878
// PodAntiAffinityTypePreferred is the label for preferred anti-affinity type
7979
PodAntiAffinityTypePreferred = "preferred"
80+
81+
// DefaultPgBouncerPoolerSecretSuffix is the suffix for the default pgbouncer Pooler secret
82+
DefaultPgBouncerPoolerSecretSuffix = "-pooler"
8083
)
8184

8285
// ClusterSpec defines the desired state of Cluster
@@ -300,6 +303,19 @@ type ClusterStatus struct {
300303

301304
// The timestamp when the last request for a new primary has occurred
302305
TargetPrimaryTimestamp string `json:"targetPrimaryTimestamp,omitempty"`
306+
307+
// The integration needed by poolers referencing the cluster
308+
PoolerIntegrations *PoolerIntegrations `json:"poolerIntegrations,omitempty"`
309+
}
310+
311+
// PoolerIntegrations encapsulates the needed integration for the poolers referencing the cluster
312+
type PoolerIntegrations struct {
313+
PgBouncerIntegration PgbouncerIntegrationStatus `json:"pgBouncerIntegration,omitempty"`
314+
}
315+
316+
// PgbouncerIntegrationStatus encapsulates the needed integration for the pgbouncer poolers referencing the cluster
317+
type PgbouncerIntegrationStatus struct {
318+
Secrets []string `json:"secrets,omitempty"`
303319
}
304320

305321
// ReplicaClusterConfiguration encapsulates the configuration of a replica

api/v1/groupversion_info.go

+10
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,22 @@ var (
2525
Resource: "clusters",
2626
}
2727

28+
// PoolerGVK is the triple to reach Pooler resources in k8s
29+
PoolerGVK = schema.GroupVersionResource{
30+
Group: GroupVersion.Group,
31+
Version: GroupVersion.Version,
32+
Resource: "poolers",
33+
}
34+
2835
// ClusterKind is the kind name of Clusters
2936
ClusterKind = "Cluster"
3037

3138
// BackupKind is the kind name of Backups
3239
BackupKind = "Backup"
3340

41+
// PoolerKind is the kind name of Poolers
42+
PoolerKind = "Pooler"
43+
3444
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
3545
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
3646

0 commit comments

Comments
 (0)