Skip to content

Commit 66375db

Browse files
authored
Merge pull request #2 from mastodon/pgbouncer-improvements
INF-246: Add additional settings to pgbouncer
2 parents e4bdd4c + 721b57a commit 66375db

File tree

4 files changed

+40
-20
lines changed

4 files changed

+40
-20
lines changed

charts/pgbouncer/Chart.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type: application
1515
# This is the chart version. This version number should be incremented each time you make changes
1616
# to the chart and its templates, including the app version.
1717
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18-
version: 1.1.1
18+
version: 1.2.0
1919

2020
# This is the version number of the application being deployed. This version number should be
2121
# incremented each time you make changes to the application. Versions are not expected to

charts/pgbouncer/templates/_pgbouncer.ini.tpl

+7-4
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ listen_port = 6432
2323
; unix_socket_dir = var/run/postgresql
2424
;unix_socket_mode = 0777
2525
;unix_socket_group =
26-
;client_tls_sslmode = disable
26+
client_tls_sslmode = {{ .Values.settings.tls.clientMode }}
2727
;client_tls_ca_file = <system default>
2828
;client_tls_key_file =
2929
;client_tls_cert_file =
3030
;client_tls_ciphers = fast
3131
;client_tls_protocols = all
3232
;client_tls_dheparams = auto
3333
;client_tls_ecdhcurve = auto
34-
;server_tls_sslmode = disable
34+
server_tls_sslmode = {{ .Values.settings.tls.serverMode }}
3535
;server_tls_ca_file = <system default>
3636
;server_tls_key_file =
3737
;server_tls_cert_file =
@@ -41,9 +41,12 @@ listen_port = 6432
4141

4242
;;; Authentication settings
4343

44-
auth_type = md5
45-
;auth_file = /8.0/main/global/pg_auth
44+
auth_type = {{ .Values.settings.authType }}
45+
{{- if and .Values.authFile.secretRef.name .Values.authFile.secretRef.key }}
4646
auth_file = /etc/pgbouncer/userlist.txt
47+
{{- else }}
48+
;auth_file =
49+
{{- end }}
4750
;auth_hba_file =
4851

4952
{{ .Values.settings.auth_query }}

charts/pgbouncer/templates/deployment.yaml

+14-10
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,16 @@ spec:
5050
resources:
5151
{{- toYaml .Values.resources | nindent 12 }}
5252
volumeMounts:
53-
- name: userssecret
54-
mountPath: /etc/pgbouncer/userlist.txt
55-
subPath: {{ .Values.usersSecretRef.key }}
56-
readOnly: true
5753
- name: config
5854
mountPath: /etc/pgbouncer/pgbouncer.ini
5955
subPath: pgbouncer.ini
6056
readOnly: true
57+
{{- if and .Values.authFile.secretRef.name .Values.authFile.secretRef.key }}
58+
- name: auth-file
59+
mountPath: /etc/pgbouncer/userlist.txt
60+
subPath: {{ .Values.authFile.secretRef.key }}
61+
readOnly: true
62+
{{- end }}
6163
lifecycle:
6264
preStop:
6365
exec:
@@ -99,15 +101,17 @@ spec:
99101
{{- end }}
100102
terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }}
101103
volumes:
102-
- name: userssecret
103-
secret:
104-
secretName: {{ .Values.usersSecretRef.name }}
105-
items:
106-
- key: {{ .Values.usersSecretRef.key }}
107-
path: userlist.txt
108104
- name: config
109105
configMap:
110106
name: {{ template "pgbouncer.fullname" . }}-config
111107
items:
112108
- key: pgbouncer.ini
113109
path: pgbouncer.ini
110+
{{- if and .Values.authFile.secretRef.name .Values.authFile.secretRef.key }}
111+
- name: auth-file
112+
secret:
113+
secretName: {{ .Values.authFile.secretRef.name }}
114+
items:
115+
- key: {{ .Values.authFile.secretRef.key }}
116+
path: userlist.txt
117+
{{- end }}

charts/pgbouncer/values.yaml

+18-5
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,15 @@ fullnameOverride: ""
2121

2222
podAnnotations: {}
2323

24+
# List of users written in key=value lines like:
25+
# user1: settings
26+
users: {}
27+
2428
# The secret containing the userlist.txt to deploy
25-
usersSecretRef:
26-
name: pgbouncer-conf-users
27-
key: userlist.txt
29+
authFile:
30+
secretRef:
31+
name:
32+
key:
2833

2934
databases:
3035
# name:
@@ -34,8 +39,13 @@ databases:
3439
# dbname:
3540

3641
settings:
42+
authType: scram-sha-256
3743
adminUsers: []
38-
statsUsers: [pgbouncer_exporter]
44+
statsUsers: []
45+
46+
tls:
47+
clientMode: disable
48+
serverMode: require
3949

4050
poolMode: transaction
4151
serverResetQuery: DISCARD ALL
@@ -67,8 +77,11 @@ settings:
6777
# but will wait until all transactions end, or this amount of time
6878
terminationGracePeriodSeconds: 120
6979

80+
# Sidecar configuration for prometheus exporter.
81+
# This sidecar needs an additional user "pgbouncer_exporter" to be configured in
82+
# the auth_file if enabled.
7083
prometheusExporter:
71-
enabled: true
84+
enabled: false
7285
statsPgUser: pgbouncer_exporter
7386
statsPgPasswordSecretRef:
7487
name: pgbouncer-exporter-password

0 commit comments

Comments
 (0)