Skip to content

Commit bee88b8

Browse files
committed
chore: fix pgbouncer manifest
Bitnami's Docker image for PgBouncer has some unclear default settings, which caused my incorrect manifest to work. This has been fixed now.
1 parent 9fec423 commit bee88b8

File tree

4 files changed

+48
-18
lines changed

4 files changed

+48
-18
lines changed

manifests/components/pgbouncer/deployment.yaml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ spec:
1919
image: bitnami/pgbouncer:latest
2020
envFrom:
2121
- configMapRef:
22-
name: pgbouncer
22+
name: pgbouncer-bitnami
2323
- secretRef:
24-
name: pgbouncer
24+
name: pgbouncer-bitnami
2525
ports:
2626
- containerPort: 5432
2727
name: session-prt
@@ -31,13 +31,20 @@ spec:
3131
cpu: 50m
3232
memory: 50Mi
3333
volumeMounts:
34-
- name: auth-file
35-
mountPath: /etc/pgbouncer/auth_file
34+
- name: config-vol
35+
mountPath: /bitnami/pgbouncer/conf/
3636
readOnly: true
3737
volumes:
38-
- name: auth-file
39-
secret:
40-
secretName: auth-file
38+
- name: config-vol # cannot name it to 'config' or kubernetes will not be able to find it.
39+
projected:
40+
sources:
41+
- configMap:
42+
name: pgbouncer
43+
- secret:
44+
name: pgbouncer
45+
items:
46+
- key: auth_file
47+
path: userlist.txt
4148
# assign pods to nodes with the postgres primary
4249
affinity:
4350
podAffinity:

manifests/components/pgbouncer/kustomization.yaml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,21 @@ resources:
77

88
configMapGenerator:
99
- name: pgbouncer
10+
files:
11+
- pgbouncer.ini
12+
# The bitnami pgbouncer image requires some environment variables to work, although they are overridden by the config file
13+
- name: pgbouncer-bitnami
1014
envs:
1115
- params.env
1216

1317
secretGenerator:
1418
- name: pgbouncer
15-
envs:
16-
- secret-params.env
17-
- name: auth-file
1819
files:
1920
- auth_file
21+
# The bitnami pgbouncer image requires some environment variables to work, although they are overridden by the config file
22+
- name: pgbouncer-bitnami
23+
envs:
24+
- secret-params.env
2025

2126
images:
2227
- name: bitnami/pgbouncer
Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,2 @@
11
POSTGRESQL_HOST=postgres.postgres-shared.svc.cluster.local
22
PGBOUNCER_PORT=5432
3-
PGBOUNCER_DEFAULT_POOL_SIZE=100
4-
PGBOUNCER_MAX_CLIENT_CONN=100
5-
PGBOUNCER_POOL_MODE=session
6-
PGBOUNCER_IGNORE_STARTUP_PARAMETERS=extra_float_digits,search_path
7-
# PgBouncer exposed database. This is the database that clients can connect to.
8-
PGBOUNCER_DATABASE=chatbot
9-
PGBOUNCER_AUTH_USER=chatbot
10-
PGBOUNCER_AUTH_TYPE=scram-sha-256
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
; This file is modified on a base generated by <https://hub.docker.com/r/bitnami/pgbouncer>
2+
; The source code of the base image can be found at <https://github.com/bitnami/containers/tree/main/bitnami/pgbouncer>
3+
4+
[databases]
5+
chatbot = host=postgres.postgres-shared.svc.cluster.local port=5432 dbname=chatbot auth_user=chatbot pool_size=200
6+
chatbot-standby = host=postgres-replica.postgres-shared.svc.cluster.local port=5432 dbname=chatbot auth_user=chatbot pool_size=200
7+
* = host=postgres.postgres-shared.svc.cluster.local
8+
9+
[pgbouncer]
10+
listen_port=5432
11+
listen_addr=0.0.0.0
12+
unix_socket_dir=/tmp/
13+
unix_socket_mode=0777
14+
auth_file=/opt/bitnami/pgbouncer/conf/userlist.txt
15+
auth_type=scram-sha-256
16+
pidfile=/opt/bitnami/pgbouncer/tmp/pgbouncer.pid
17+
admin_users=chatbot
18+
client_tls_sslmode=disable
19+
server_tls_sslmode=disable
20+
pool_mode=session
21+
max_client_conn=400
22+
default_pool_size=100
23+
ignore_startup_parameters=extra_float_digits
24+
stats_period=60
25+
server_round_robin=0
26+
server_fast_close=0

0 commit comments

Comments
 (0)