1 {{- if .Values.replication.enabled }}
2 apiVersion: {{ template "postgresql.statefulset.apiVersion" . }}
5 name: "{{ template "postgresql.fullname" . }}-slave"
7 app: {{ template "postgresql.name" . }}
8 chart: {{ template "postgresql.chart" . }}
9 release: {{ .Release.Name | quote }}
10 heritage: {{ .Release.Service | quote }}
11 {{- with .Values.slave.labels }}
12 {{ toYaml . | indent 4 }}
14 {{- with .Values.slave.annotations }}
16 {{ toYaml . | indent 4 }}
19 serviceName: {{ template "postgresql.fullname" . }}-headless
20 replicas: {{ .Values.replication.slaveReplicas }}
23 app: {{ template "postgresql.name" . }}
24 release: {{ .Release.Name | quote }}
28 name: {{ template "postgresql.fullname" . }}
30 app: {{ template "postgresql.name" . }}
31 chart: {{ template "postgresql.chart" . }}
32 release: {{ .Release.Name | quote }}
33 heritage: {{ .Release.Service | quote }}
35 {{- with .Values.slave.podLabels }}
36 {{ toYaml . | indent 8 }}
38 {{- with .Values.slave.podAnnotations }}
40 {{ toYaml . | indent 8 }}
43 {{- if .Values.schedulerName }}
44 schedulerName: "{{ .Values.schedulerName }}"
46 {{- include "postgresql.imagePullSecrets" . | indent 6 }}
47 {{- if .Values.slave.nodeSelector }}
49 {{ toYaml .Values.slave.nodeSelector | indent 8 }}
51 {{- if .Values.slave.affinity }}
53 {{ toYaml .Values.slave.affinity | indent 8 }}
55 {{- if .Values.slave.tolerations }}
57 {{ toYaml .Values.slave.tolerations | indent 8 }}
59 {{- if .Values.terminationGracePeriodSeconds }}
60 terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }}
62 {{- if .Values.securityContext.enabled }}
64 fsGroup: {{ .Values.securityContext.fsGroup }}
66 {{- if .Values.serviceAccount.enabled }}
67 serviceAccountName: {{ default (include "postgresql.fullname" . ) .Values.serviceAccount.name}}
69 {{- if or .Values.slave.extraInitContainers (and .Values.volumePermissions.enabled .Values.persistence.enabled) .Values.shmVolume.enabled }}
71 {{- if or (and .Values.volumePermissions.enabled .Values.persistence.enabled) .Values.shmVolume.enabled }}
72 - name: init-chmod-data
73 image: {{ template "postgresql.volumePermissions.image" . }}
74 imagePullPolicy: "{{ .Values.volumePermissions.image.pullPolicy }}"
75 {{- if .Values.resources }}
76 resources: {{- toYaml .Values.resources | nindent 12 }}
82 mkdir -p {{ .Values.persistence.mountPath }}/data
83 chmod 700 {{ .Values.persistence.mountPath }}/data
84 find {{ .Values.persistence.mountPath }} -mindepth 0 -maxdepth 1 -not -name ".snapshot" -not -name "lost+found" | \
85 xargs chown -R {{ .Values.securityContext.runAsUser }}:{{ .Values.securityContext.fsGroup }}
86 {{- if .Values.shmVolume.enabled }}
90 runAsUser: {{ .Values.volumePermissions.securityContext.runAsUser }}
93 mountPath: {{ .Values.persistence.mountPath }}
94 subPath: {{ .Values.persistence.subPath }}
95 {{- if .Values.shmVolume.enabled }}
100 {{- if .Values.slave.extraInitContainers }}
101 {{ tpl .Values.slave.extraInitContainers . | indent 8 }}
104 {{- if .Values.slave.priorityClassName }}
105 priorityClassName: {{ .Values.slave.priorityClassName }}
108 - name: {{ template "postgresql.fullname" . }}
109 image: {{ template "postgresql.image" . }}
110 imagePullPolicy: "{{ .Values.image.pullPolicy }}"
111 {{- if .Values.resources }}
112 resources: {{- toYaml .Values.resources | nindent 12 }}
114 {{- if .Values.securityContext.enabled }}
116 runAsUser: {{ .Values.securityContext.runAsUser }}
119 - name: BITNAMI_DEBUG
120 value: {{ ternary "true" "false" .Values.image.debug | quote }}
121 - name: POSTGRESQL_VOLUME_DIR
122 value: "{{ .Values.persistence.mountPath }}"
123 - name: POSTGRESQL_PORT_NUMBER
124 value: "{{ template "postgresql.port" . }}"
125 {{- if .Values.persistence.mountPath }}
127 value: {{ .Values.postgresqlDataDir | quote }}
129 - name: POSTGRES_REPLICATION_MODE
131 - name: POSTGRES_REPLICATION_USER
132 value: {{ include "postgresql.replication.username" . | quote }}
133 {{- if .Values.usePasswordFile }}
134 - name: POSTGRES_REPLICATION_PASSWORD_FILE
135 value: "/opt/bitnami/postgresql/secrets/postgresql-replication-password"
137 - name: POSTGRES_REPLICATION_PASSWORD
140 name: {{ template "postgresql.secretName" . }}
141 key: postgresql-replication-password
143 - name: POSTGRES_CLUSTER_APP_NAME
144 value: {{ .Values.replication.applicationName }}
145 - name: POSTGRES_MASTER_HOST
146 value: {{ template "postgresql.fullname" . }}
147 - name: POSTGRES_MASTER_PORT_NUMBER
148 value: {{ include "postgresql.port" . | quote }}
149 {{- if and .Values.postgresqlPostgresPassword (not (eq .Values.postgresqlUsername "postgres")) }}
150 {{- if .Values.usePasswordFile }}
151 - name: POSTGRES_POSTGRES_PASSWORD_FILE
152 value: "/opt/bitnami/postgresql/secrets/postgresql-postgres-password"
154 - name: POSTGRES_POSTGRES_PASSWORD
157 name: {{ template "postgresql.secretName" . }}
158 key: postgresql-postgres-password
161 {{- if .Values.usePasswordFile }}
162 - name: POSTGRES_PASSWORD_FILE
163 value: "/opt/bitnami/postgresql/secrets/postgresql-password"
165 - name: POSTGRES_PASSWORD
168 name: {{ template "postgresql.secretName" . }}
169 key: postgresql-password
172 - name: tcp-postgresql
173 containerPort: {{ template "postgresql.port" . }}
174 {{- if .Values.livenessProbe.enabled }}
180 {{- if (include "postgresql.database" .) }}
181 - exec pg_isready -U {{ include "postgresql.username" . | quote }} -d {{ (include "postgresql.database" .) | quote }} -h 127.0.0.1 -p {{ template "postgresql.port" . }}
183 - exec pg_isready -U {{ include "postgresql.username" . | quote }} -h 127.0.0.1 -p {{ template "postgresql.port" . }}
185 initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
186 periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
187 timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
188 successThreshold: {{ .Values.livenessProbe.successThreshold }}
189 failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
191 {{- if .Values.readinessProbe.enabled }}
198 {{- include "postgresql.readinessProbeCommand" . | nindent 16 }}
199 initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
200 periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
201 timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
202 successThreshold: {{ .Values.readinessProbe.successThreshold }}
203 failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
206 {{- if .Values.usePasswordFile }}
207 - name: postgresql-password
208 mountPath: /opt/bitnami/postgresql/secrets/
210 {{- if .Values.shmVolume.enabled }}
214 {{- if .Values.persistence.enabled }}
216 mountPath: {{ .Values.persistence.mountPath }}
217 subPath: {{ .Values.persistence.subPath }}
219 {{- if or (.Files.Glob "files/conf.d/*.conf") .Values.postgresqlExtendedConf .Values.extendedConfConfigMap }}
220 - name: postgresql-extended-config
221 mountPath: /bitnami/postgresql/conf/conf.d/
223 {{- if or (.Files.Glob "files/postgresql.conf") (.Files.Glob "files/pg_hba.conf") .Values.postgresqlConfiguration .Values.pgHbaConfiguration .Values.configurationConfigMap }}
224 - name: postgresql-config
225 mountPath: /bitnami/postgresql/conf
227 {{- if .Values.slave.extraVolumeMounts }}
228 {{- toYaml .Values.slave.extraVolumeMounts | nindent 12 }}
231 {{- if .Values.usePasswordFile }}
232 - name: postgresql-password
234 secretName: {{ template "postgresql.secretName" . }}
236 {{- if or (.Files.Glob "files/postgresql.conf") (.Files.Glob "files/pg_hba.conf") .Values.postgresqlConfiguration .Values.pgHbaConfiguration .Values.configurationConfigMap}}
237 - name: postgresql-config
239 name: {{ template "postgresql.configurationCM" . }}
241 {{- if or (.Files.Glob "files/conf.d/*.conf") .Values.postgresqlExtendedConf .Values.extendedConfConfigMap }}
242 - name: postgresql-extended-config
244 name: {{ template "postgresql.extendedConfigurationCM" . }}
246 {{- if .Values.shmVolume.enabled }}
252 {{- if not .Values.persistence.enabled }}
256 {{- if .Values.slave.extraVolumes }}
257 {{- toYaml .Values.slave.extraVolumes | nindent 8 }}
260 type: {{ .Values.updateStrategy.type }}
261 {{- if (eq "Recreate" .Values.updateStrategy.type) }}
264 {{- if .Values.persistence.enabled }}
265 volumeClaimTemplates:
268 {{- with .Values.persistence.annotations }}
270 {{- range $key, $value := . }}
271 {{ $key }}: {{ $value }}
276 {{- range .Values.persistence.accessModes }}
281 storage: {{ .Values.persistence.size | quote }}
282 {{ include "postgresql.storageClass" . }}