@@ -22,45 +22,70 @@ spec:
2222 app : {{ template "sentry.fullname" . }}-pgbouncer
2323 {{- include "sentry.component.labels" (dict "component" "pgbouncer" "ctx" .) | nindent 8 }}
2424 spec :
25+ initContainers :
26+ - name : config
27+ image : busybox
28+ command : ["sh", "-c"]
29+ args :
30+ - |
31+ cat <<EOF > /etc/pgbouncer/pgbouncer.ini
32+ [databases]
33+ ${PGBOUNCER_DATABASE}=host=${POSTGRESQL_HOST} port=${POSTGRESQL_PORT} dbname=${PGBOUNCER_DATABASE}
34+ [pgbouncer]
35+ listen_port=5432
36+ listen_addr=0.0.0.0
37+ unix_socket_dir=/tmp/
38+ unix_socket_mode=0777
39+ auth_file = /etc/userlist/userlist.txt
40+ server_reset_query = SELECT pg_advisory_unlock_all()
41+ server_reset_query_always = 1
42+ admin_users=${POSTGRESQL_USERNAME}
43+ pool_mode={{ .Values.pgbouncer.poolMode }}
44+ auth_type={{ .Values.pgbouncer.authType }}
45+ default_pool_size={{ .Values.pgbouncer.poolSize }}
46+ max_client_conn={{ .Values.pgbouncer.maxClientConn }}
47+ {{- range $key, $val := .Values.pgbouncer.extraParameters }}
48+ {{ $key }} = {{ $val }}
49+ {{- end }}
50+ EOF
51+ echo "\"${POSTGRESQL_USERNAME}\" \"${POSTGRESQL_PASSWORD}\"" > /etc/userlist/userlist.txt
52+ env :
53+ {{ include "sentry.pgbouncer.env" . | nindent 12 }}
54+ volumeMounts :
55+ - name : config
56+ mountPath : /etc/pgbouncer/
57+ - name : userlist
58+ mountPath : /etc/userlist/
2559 containers :
26- - name : pgbouncer
27- image : {{ .Values.pgbouncer.image.repository }}:{{ .Values.pgbouncer.image.tag }}
28- imagePullPolicy : {{ .Values.pgbouncer.image.pullPolicy }}
29- resources :
30- {{ toYaml .Values.pgbouncer.resources | nindent 10 }}
31- env :
32- {{- if .Values.pgbouncer.env }}
33- {{ toYaml .Values.pgbouncer.env | nindent 10 }}
34- {{- end }}
35- {{ include "sentry.pgbouncer.env" . | nindent 10 }}
36- - name : PGBOUNCER_PORT
37- value : " 5432"
38- - name : PGBOUNCER_AUTH_TYPE
39- value : {{ .Values.pgbouncer.authType | quote }}
40- - name : PGBOUNCER_MAX_CLIENT_CONN
41- value : {{ .Values.pgbouncer.maxClientConn | quote }}
42- - name : PGBOUNCER_DEFAULT_POOL_SIZE
43- value : {{ .Values.pgbouncer.poolSize | quote }}
44- - name : PGBOUNCER_POOL_MODE
45- value : {{ .Values.pgbouncer.poolMode | quote }}
46- ports :
47- - containerPort : 5432
48- name : pgbouncer
49- protocol : TCP
50- {{- if or .Values.pgbouncer.volumeMounts .Values.global.volumeMounts }}
51- volumeMounts :
52- {{- end }}
60+ - name : pgbouncer
61+ image : {{ .Values.pgbouncer.image.repository }}:{{ .Values.pgbouncer.image.tag }}
62+ imagePullPolicy : {{ .Values.pgbouncer.image.pullPolicy }}
63+ resources :
64+ {{ toYaml .Values.pgbouncer.resources | nindent 12 }}
65+ env :
66+ {{- if .Values.pgbouncer.env }}
67+ {{ toYaml .Values.pgbouncer.env | nindent 12 }}
68+ {{- end }}
69+ ports :
70+ - containerPort : 5432
71+ name : pgbouncer
72+ protocol : TCP
73+ volumeMounts :
74+ - name : config
75+ mountPath : /etc/pgbouncer/
76+ - name : userlist
77+ mountPath : /etc/userlist/
5378{{- if .Values.pgbouncer.volumeMounts }}
54- {{ toYaml .Values.pgbouncer.volumeMounts | indent 8 }}
79+ {{ toYaml .Values.pgbouncer.volumeMounts | indent 12 }}
5580{{- end }}
5681{{- if .Values.global.volumeMounts }}
57- {{ toYaml .Values.global.volumeMounts | indent 8 }}
82+ {{ toYaml .Values.global.volumeMounts | indent 12 }}
5883{{- end }}
5984{{- if .Values.pgbouncer.sidecars }}
60- {{ toYaml .Values.pgbouncer.sidecars | indent 6 }}
85+ {{ toYaml .Values.pgbouncer.sidecars | indent 8 }}
6186{{- end }}
6287{{- if .Values.global.sidecars }}
63- {{ toYaml .Values.global.sidecars | indent 6 }}
88+ {{ toYaml .Values.global.sidecars | indent 8 }}
6489{{- end }}
6590 {{- if .Values.pgbouncer.nodeSelector }}
6691 nodeSelector :
@@ -88,13 +113,15 @@ spec:
88113 priorityClassName : " {{ .Values.pgbouncer.priorityClassName }}"
89114 {{- end }}
90115 terminationGracePeriodSeconds : 10
91- {{- if or .Values.pgbouncer.volumes .Values.global.volumes }}
92116 volumes :
93- {{- end }}
117+ - name : config
118+ emptyDir : {}
119+ - name : userlist
120+ emptyDir : {}
94121{{- if .Values.pgbouncer.volumes }}
95- {{ toYaml .Values.pgbouncer.volumes | indent 6 }}
122+ {{ toYaml .Values.pgbouncer.volumes | indent 8 }}
96123{{- end }}
97124{{- if .Values.global.volumes }}
98- {{ toYaml .Values.global.volumes | indent 6 }}
125+ {{ toYaml .Values.global.volumes | indent 8 }}
99126{{- end }}
100127{{- end }}
0 commit comments