1 apiVersion: apps/v1beta2
4 name: {{ template "postgresql.master.fullname" . }}
6 app: {{ template "postgresql.name" . }}
7 chart: {{ template "postgresql.chart" . }}
8 release: {{ .Release.Name | quote }}
9 heritage: {{ .Release.Service | quote }}
11 serviceName: {{ template "postgresql.fullname" . }}-headless
14 type: {{ .Values.updateStrategy.type }}
17 app: {{ template "postgresql.name" . }}
18 release: {{ .Release.Name | quote }}
22 name: {{ template "postgresql.fullname" . }}
24 app: {{ template "postgresql.name" . }}
25 chart: {{ template "postgresql.chart" . }}
26 release: {{ .Release.Name | quote }}
27 heritage: {{ .Release.Service | quote }}
30 {{- if .Values.securityContext.enabled }}
32 fsGroup: {{ .Values.securityContext.fsGroup }}
33 runAsUser: {{ .Values.securityContext.runAsUser }}
35 {{- if or .Values.image.pullSecrets .Values.metrics.image.pullSecrets }}
37 {{- range .Values.image.pullSecrets }}
40 {{- range .Values.metrics.image.pullSecrets }}
44 {{- if .Values.master.nodeSelector }}
46 {{ toYaml .Values.master.nodeSelector | indent 8 }}
48 {{- if .Values.master.affinity }}
50 {{ toYaml .Values.master.affinity | indent 8 }}
52 {{- if .Values.master.tolerations }}
54 {{ toYaml .Values.master.tolerations | indent 8 }}
56 {{- if .Values.terminationGracePeriodSeconds }}
57 terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }}
59 {{- if and .Values.volumePermissions.enabled .Values.persistence.enabled }}
61 - name: init-chmod-data
62 image: {{ template "postgresql.volumePermissions.image" . }}
63 imagePullPolicy: "{{ .Values.volumePermissions.image.pullPolicy }}"
65 {{ toYaml .Values.resources | indent 10 }}
70 chown -R {{ .Values.securityContext.runAsUser }}:{{ .Values.securityContext.fsGroup }} /bitnami
71 if [ -d /bitnami/postgresql/data ]; then
72 chmod 0700 /bitnami/postgresql/data;
75 runAsUser: {{ .Values.volumePermissions.securityContext.runAsUser }}
78 mountPath: /bitnami/postgresql
81 - name: {{ template "postgresql.fullname" . }}
82 image: {{ template "postgresql.image" . }}
83 imagePullPolicy: "{{ .Values.image.pullPolicy }}"
85 {{ toYaml .Values.resources | indent 10 }}
87 {{- if .Values.image.debug}}
93 {{- if .Values.replication.enabled }}
94 - name: POSTGRESQL_REPLICATION_MODE
96 - name: POSTGRESQL_REPLICATION_USER
97 value: {{ .Values.replication.user | quote }}
98 {{- if .Values.usePasswordFile }}
99 - name: POSTGRESQL_REPLICATION_PASSWORD_FILE
100 value: "/opt/bitnami/postgresql/secrets/postgresql-replication-password"
102 - name: POSTGRESQL_REPLICATION_PASSWORD
105 name: {{ template "postgresql.secretName" . }}
106 key: postgresql-replication-password
108 {{- if not (eq .Values.replication.synchronousCommit "off")}}
109 - name: POSTGRESQL_SYNCHRONOUS_COMMIT_MODE
110 value: {{ .Values.replication.synchronousCommit | quote }}
111 - name: POSTGRESQL_NUM_SYNCHRONOUS_REPLICAS
112 value: {{ .Values.replication.numSynchronousReplicas | quote }}
114 - name: POSTGRESQL_CLUSTER_APP_NAME
115 value: {{ .Values.replication.applicationName }}
117 - name: POSTGRESQL_USERNAME
118 value: {{ .Values.postgresqlUsername | quote }}
119 {{- if .Values.usePasswordFile }}
120 - name: POSTGRESQL_PASSWORD_FILE
121 value: "/opt/bitnami/postgresql/secrets/postgresql-password"
123 - name: POSTGRESQL_PASSWORD
126 name: {{ template "postgresql.secretName" . }}
127 key: postgresql-password
129 {{- if .Values.postgresqlDatabase }}
130 - name: POSTGRESQL_DATABASE
131 value: {{ .Values.postgresqlDatabase | quote }}
133 {{- if .Values.extraEnv }}
134 {{ toYaml .Values.extraEnv | indent 8 }}
138 containerPort: {{ .Values.service.port }}
139 {{- if .Values.livenessProbe.enabled }}
145 {{- if .Values.postgresqlDatabase }}
146 - exec pg_isready -U {{ .Values.postgresqlUsername | quote }} -d {{ .Values.postgresqlDatabase | quote }} -h localhost
148 - exec pg_isready -U {{ .Values.postgresqlUsername | quote }} -h localhost
150 initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
151 periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
152 timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
153 successThreshold: {{ .Values.livenessProbe.successThreshold }}
154 failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
156 {{- if .Values.readinessProbe.enabled }}
162 {{- if .Values.postgresqlDatabase }}
163 - exec pg_isready -U {{ .Values.postgresqlUsername | quote }} -d {{ .Values.postgresqlDatabase | quote }} -h localhost
165 - exec pg_isready -U {{ .Values.postgresqlUsername | quote }} -h localhost
167 initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
168 periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
169 timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
170 successThreshold: {{ .Values.readinessProbe.successThreshold }}
171 failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
174 {{- if or (.Files.Glob "files/docker-entrypoint-initdb.d/*.{sh,sql,sql.gz}") .Values.initdbScriptsConfigMap .Values.initdbScripts }}
175 - name: custom-init-scripts
176 mountPath: /docker-entrypoint-initdb.d
178 {{- if or (.Files.Glob "files/conf.d/*.conf") .Values.postgresqlExtendedConf .Values.extendedConfConfigMap }}
179 - name: postgresql-extended-config
180 mountPath: /bitnami/postgresql/conf/conf.d/
182 {{- if .Values.usePasswordFile }}
183 - name: postgresql-password
184 mountPath: /opt/bitnami/postgresql/secrets/
186 {{- if .Values.persistence.enabled }}
188 mountPath: {{ .Values.persistence.mountPath }}
190 {{- if or (.Files.Glob "files/postgresql.conf") (.Files.Glob "files/pg_hba.conf") .Values.postgresqlConfiguration .Values.pgHbaConfiguration .Values.configurationConfigMap }}
191 - name: postgresql-config
192 mountPath: /bitnami/postgresql/conf
194 {{- if .Values.metrics.enabled }}
196 image: {{ template "metrics.image" . }}
197 imagePullPolicy: {{ .Values.metrics.image.pullPolicy | quote }}
199 {{- $database := required "In order to enable metrics you need to specify a database (.Values.postgresqlDatabase)" .Values.postgresqlDatabase }}
200 - name: DATA_SOURCE_URI
201 value: {{ printf "localhost:%d/%s?sslmode=disable" (int .Values.service.port) $database | quote }}
202 {{- if .Values.usePasswordFile }}
203 - name: DATA_SOURCE_PASS_FILE
204 value: "/opt/bitnami/postgresql/secrets/postgresql-password"
206 - name: DATA_SOURCE_PASS
209 name: {{ template "postgresql.secretName" . }}
210 key: postgresql-password
212 - name: DATA_SOURCE_USER
213 value: {{ .Values.postgresqlUsername }}
214 {{- if .Values.livenessProbe.enabled }}
219 initialDelaySeconds: {{ .Values.metrics.livenessProbe.initialDelaySeconds }}
220 periodSeconds: {{ .Values.metrics.livenessProbe.periodSeconds }}
221 timeoutSeconds: {{ .Values.metrics.livenessProbe.timeoutSeconds }}
222 successThreshold: {{ .Values.metrics.livenessProbe.successThreshold }}
223 failureThreshold: {{ .Values.metrics.livenessProbe.failureThreshold }}
225 {{- if .Values.readinessProbe.enabled }}
230 initialDelaySeconds: {{ .Values.metrics.readinessProbe.initialDelaySeconds }}
231 periodSeconds: {{ .Values.metrics.readinessProbe.periodSeconds }}
232 timeoutSeconds: {{ .Values.metrics.readinessProbe.timeoutSeconds }}
233 successThreshold: {{ .Values.metrics.readinessProbe.successThreshold }}
234 failureThreshold: {{ .Values.metrics.readinessProbe.failureThreshold }}
237 {{- if .Values.usePasswordFile }}
238 - name: postgresql-password
239 mountPath: /opt/bitnami/postgresql/secrets/
245 {{ toYaml .Values.metrics.resources | indent 10 }}
248 {{- if or (.Files.Glob "files/postgresql.conf") (.Files.Glob "files/pg_hba.conf") .Values.postgresqlConfiguration .Values.pgHbaConfiguration .Values.configurationConfigMap}}
249 - name: postgresql-config
251 name: {{ template "postgresql.configurationCM" . }}
253 {{- if or (.Files.Glob "files/conf.d/*.conf") .Values.postgresqlExtendedConf .Values.extendedConfConfigMap }}
254 - name: postgresql-extended-config
256 name: {{ template "postgresql.extendedConfigurationCM" . }}
258 {{- if .Values.usePasswordFile }}
259 - name: postgresql-password
261 secretName: {{ template "postgresql.secretName" . }}
263 {{- if or (.Files.Glob "files/docker-entrypoint-initdb.d/*.{sh,sql,sql.gz}") .Values.initdbScriptsConfigMap .Values.initdbScripts }}
264 - name: custom-init-scripts
266 name: {{ template "postgresql.initdbScriptsCM" . }}
268 {{- if and .Values.persistence.enabled .Values.persistence.existingClaim }}
270 persistentVolumeClaim:
271 claimName: {{ .Values.persistence.existingClaim }}
272 {{- else if not .Values.persistence.enabled }}
275 {{- else if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }}
276 volumeClaimTemplates:
279 {{- with .Values.persistence.annotations }}
281 {{- range $key, $value := . }}
282 {{ $key }}: {{ $value }}
287 {{- range .Values.persistence.accessModes }}
292 storage: {{ .Values.persistence.size | quote }}
293 {{- if .Values.persistence.storageClass }}
294 {{- if (eq "-" .Values.persistence.storageClass) }}
297 storageClassName: "{{ .Values.persistence.storageClass }}"