1 {{- $customUser := include "postgresql.username" . }}
2 apiVersion: {{ include "common.capabilities.statefulset.apiVersion" . }}
5 name: {{ include "postgresql.primary.fullname" . }}
6 namespace: {{ .Release.Namespace | quote }}
7 labels: {{- include "common.labels.standard" . | nindent 4 }}
8 app.kubernetes.io/component: primary
9 {{- if .Values.commonLabels }}
10 {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
12 {{- if .Values.primary.labels }}
13 {{- include "common.tplvalues.render" ( dict "value" .Values.primary.labels "context" $ ) | nindent 4 }}
16 {{- if .Values.commonAnnotations }}
17 {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
19 {{- if .Values.primary.annotations }}
20 {{- include "common.tplvalues.render" ( dict "value" .Values.primary.annotations "context" $ ) | nindent 4 }}
24 serviceName: {{ include "postgresql.primary.svc.headless" . }}
25 {{- if .Values.primary.updateStrategy }}
26 updateStrategy: {{- toYaml .Values.primary.updateStrategy | nindent 4 }}
29 matchLabels: {{- include "common.labels.matchLabels" . | nindent 6 }}
30 app.kubernetes.io/component: primary
33 name: {{ include "postgresql.primary.fullname" . }}
34 labels: {{- include "common.labels.standard" . | nindent 8 }}
35 app.kubernetes.io/component: primary
36 {{- if .Values.commonLabels }}
37 {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 8 }}
39 {{- if .Values.primary.podLabels }}
40 {{- include "common.tplvalues.render" ( dict "value" .Values.primary.podLabels "context" $ ) | nindent 8 }}
43 {{- if (include "postgresql.primary.createConfigmap" .) }}
44 checksum/configuration: {{ include (print $.Template.BasePath "/primary/configmap.yaml") . | sha256sum }}
46 {{- if (include "postgresql.primary.createExtendedConfigmap" .) }}
47 checksum/extended-configuration: {{ include (print $.Template.BasePath "/primary/extended-configmap.yaml") . | sha256sum }}
49 {{- if .Values.primary.podAnnotations }}
50 {{- include "common.tplvalues.render" ( dict "value" .Values.primary.podAnnotations "context" $ ) | nindent 8 }}
53 {{- if .Values.primary.extraPodSpec }}
54 {{- include "common.tplvalues.render" (dict "value" .Values.primary.extraPodSpec "context" $) | nindent 6 }}
56 serviceAccountName: {{ include "postgresql.serviceAccountName" . }}
57 {{- include "postgresql.imagePullSecrets" . | nindent 6 }}
58 {{- if .Values.primary.hostAliases }}
59 hostAliases: {{- include "common.tplvalues.render" (dict "value" .Values.primary.hostAliases "context" $) | nindent 8 }}
61 {{- if .Values.primary.affinity }}
62 affinity: {{- include "common.tplvalues.render" (dict "value" .Values.primary.affinity "context" $) | nindent 8 }}
65 podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.primary.podAffinityPreset "component" "primary" "context" $) | nindent 10 }}
66 podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.primary.podAntiAffinityPreset "component" "primary" "context" $) | nindent 10 }}
67 nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.primary.nodeAffinityPreset.type "key" .Values.primary.nodeAffinityPreset.key "values" .Values.primary.nodeAffinityPreset.values) | nindent 10 }}
69 {{- if .Values.primary.nodeSelector }}
70 nodeSelector: {{- include "common.tplvalues.render" (dict "value" .Values.primary.nodeSelector "context" $) | nindent 8 }}
72 {{- if .Values.primary.tolerations }}
73 tolerations: {{- include "common.tplvalues.render" (dict "value" .Values.primary.tolerations "context" $) | nindent 8 }}
75 {{- if .Values.primary.topologySpreadConstraints }}
76 topologySpreadConstraints: {{- include "common.tplvalues.render" (dict "value" .Values.primary.topologySpreadConstraints "context" .) | nindent 8 }}
78 {{- if .Values.primary.priorityClassName }}
79 priorityClassName: {{ .Values.primary.priorityClassName }}
81 {{- if .Values.primary.schedulerName }}
82 schedulerName: {{ .Values.primary.schedulerName | quote }}
84 {{- if .Values.primary.terminationGracePeriodSeconds }}
85 terminationGracePeriodSeconds: {{ .Values.primary.terminationGracePeriodSeconds }}
87 {{- if .Values.primary.podSecurityContext.enabled }}
88 securityContext: {{- omit .Values.primary.podSecurityContext "enabled" | toYaml | nindent 8 }}
90 hostNetwork: {{ .Values.primary.hostNetwork }}
91 hostIPC: {{ .Values.primary.hostIPC }}
93 {{- if and .Values.tls.enabled (not .Values.volumePermissions.enabled) }}
95 image: {{ include "postgresql.volumePermissions.image" . }}
96 imagePullPolicy: {{ .Values.volumePermissions.image.pullPolicy | quote }}
97 {{- if .Values.primary.resources }}
98 resources: {{- toYaml .Values.primary.resources | nindent 12 }}
100 # We don't require a privileged container in this case
101 {{- if .Values.primary.containerSecurityContext.enabled }}
102 securityContext: {{- omit .Values.primary.containerSecurityContext "enabled" | toYaml | nindent 12 }}
108 cp /tmp/certs/* /opt/bitnami/postgresql/certs/
109 chmod 600 {{ include "postgresql.tlsCertKey" . }}
111 - name: raw-certificates
112 mountPath: /tmp/certs
113 - name: postgresql-certificates
114 mountPath: /opt/bitnami/postgresql/certs
115 {{- else if and .Values.volumePermissions.enabled (or .Values.primary.persistence.enabled .Values.shmVolume.enabled) }}
116 - name: init-chmod-data
117 image: {{ include "postgresql.volumePermissions.image" . }}
118 imagePullPolicy: {{ .Values.volumePermissions.image.pullPolicy | quote }}
119 {{- if .Values.volumePermissions.resources }}
120 resources: {{- toYaml .Values.volumePermissions.resources | nindent 12 }}
126 {{- if .Values.primary.persistence.enabled }}
127 {{- if eq ( toString ( .Values.volumePermissions.containerSecurityContext.runAsUser )) "auto" }}
128 chown `id -u`:`id -G | cut -d " " -f2` {{ .Values.primary.persistence.mountPath }}
130 chown {{ .Values.primary.containerSecurityContext.runAsUser }}:{{ .Values.primary.podSecurityContext.fsGroup }} {{ .Values.primary.persistence.mountPath }}
132 mkdir -p {{ .Values.primary.persistence.mountPath }}/data {{- if (include "postgresql.mountConfigurationCM" .) }} {{ .Values.primary.persistence.mountPath }}/conf {{- end }}
133 chmod 700 {{ .Values.primary.persistence.mountPath }}/data {{- if (include "postgresql.mountConfigurationCM" .) }} {{ .Values.primary.persistence.mountPath }}/conf {{- end }}
134 find {{ .Values.primary.persistence.mountPath }} -mindepth 1 -maxdepth 1 {{- if not (include "postgresql.mountConfigurationCM" .) }} -not -name "conf" {{- end }} -not -name ".snapshot" -not -name "lost+found" | \
135 {{- if eq ( toString ( .Values.volumePermissions.containerSecurityContext.runAsUser )) "auto" }}
136 xargs -r chown -R `id -u`:`id -G | cut -d " " -f2`
138 xargs -r chown -R {{ .Values.primary.containerSecurityContext.runAsUser }}:{{ .Values.primary.podSecurityContext.fsGroup }}
141 {{- if .Values.shmVolume.enabled }}
142 chmod -R 777 /dev/shm
144 {{- if .Values.tls.enabled }}
145 cp /tmp/certs/* /opt/bitnami/postgresql/certs/
146 {{- if eq ( toString ( .Values.volumePermissions.containerSecurityContext.runAsUser )) "auto" }}
147 chown -R `id -u`:`id -G | cut -d " " -f2` /opt/bitnami/postgresql/certs/
149 chown -R {{ .Values.primary.containerSecurityContext.runAsUser }}:{{ .Values.primary.podSecurityContext.fsGroup }} /opt/bitnami/postgresql/certs/
151 chmod 600 {{ include "postgresql.tlsCertKey" . }}
153 {{- if eq ( toString ( .Values.volumePermissions.containerSecurityContext.runAsUser )) "auto" }}
154 securityContext: {{- omit .Values.volumePermissions.containerSecurityContext "runAsUser" | toYaml | nindent 12 }}
156 securityContext: {{- .Values.volumePermissions.containerSecurityContext | toYaml | nindent 12 }}
159 {{- if .Values.primary.persistence.enabled }}
161 mountPath: {{ .Values.primary.persistence.mountPath }}
162 {{- if .Values.primary.persistence.subPath }}
163 subPath: {{ .Values.primary.persistence.subPath }}
166 {{- if .Values.shmVolume.enabled }}
170 {{- if .Values.tls.enabled }}
171 - name: raw-certificates
172 mountPath: /tmp/certs
173 - name: postgresql-certificates
174 mountPath: /opt/bitnami/postgresql/certs
177 {{- if .Values.primary.initContainers }}
178 {{- include "common.tplvalues.render" ( dict "value" .Values.primary.initContainers "context" $ ) | nindent 8 }}
182 image: {{ include "postgresql.image" . }}
183 imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
184 {{- if .Values.primary.containerSecurityContext.enabled }}
185 securityContext: {{- omit .Values.primary.containerSecurityContext "enabled" | toYaml | nindent 12 }}
187 {{- if .Values.diagnosticMode.enabled }}
188 command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }}
189 {{- else if .Values.primary.command }}
190 command: {{- include "common.tplvalues.render" (dict "value" .Values.primary.command "context" $) | nindent 12 }}
192 {{- if .Values.diagnosticMode.enabled }}
193 args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }}
194 {{- else if .Values.primary.args }}
195 args: {{- include "common.tplvalues.render" (dict "value" .Values.primary.args "context" $) | nindent 12 }}
198 - name: BITNAMI_DEBUG
199 value: {{ ternary "true" "false" (or .Values.image.debug .Values.diagnosticMode.enabled) | quote }}
200 - name: POSTGRESQL_PORT_NUMBER
201 value: {{ .Values.containerPorts.postgresql | quote }}
202 - name: POSTGRESQL_VOLUME_DIR
203 value: {{ .Values.primary.persistence.mountPath | quote }}
204 {{- if .Values.primary.persistence.mountPath }}
206 value: {{ .Values.postgresqlDataDir | quote }}
209 {{- if and (not (empty $customUser)) (ne $customUser "postgres") }}
210 - name: POSTGRES_USER
211 value: {{ $customUser | quote }}
212 {{- if .Values.auth.enablePostgresUser }}
213 {{- if .Values.auth.usePasswordFiles }}
214 - name: POSTGRES_POSTGRES_PASSWORD_FILE
215 value: "/opt/bitnami/postgresql/secrets/postgres-password"
217 - name: POSTGRES_POSTGRES_PASSWORD
220 name: {{ include "postgresql.secretName" . }}
221 key: {{ include "postgresql.adminPasswordKey" . }}
225 {{- if .Values.auth.usePasswordFiles }}
226 - name: POSTGRES_PASSWORD_FILE
227 value: {{ printf "/opt/bitnami/postgresql/secrets/%s" (ternary "password" "postgres-password" (and (not (empty $customUser)) (ne $customUser "postgres"))) }}
229 - name: POSTGRES_PASSWORD
232 name: {{ include "postgresql.secretName" . }}
233 key: {{ include "postgresql.userPasswordKey" . }}
235 {{- if (include "postgresql.database" .) }}
237 value: {{ (include "postgresql.database" .) | quote }}
240 {{- if or (eq .Values.architecture "replication") .Values.primary.standby.enabled }}
241 - name: POSTGRES_REPLICATION_MODE
242 value: {{ ternary "slave" "master" .Values.primary.standby.enabled | quote }}
243 - name: POSTGRES_REPLICATION_USER
244 value: {{ .Values.auth.replicationUsername | quote }}
245 {{- if .Values.auth.usePasswordFiles }}
246 - name: POSTGRES_REPLICATION_PASSWORD_FILE
247 value: "/opt/bitnami/postgresql/secrets/replication-password"
249 - name: POSTGRES_REPLICATION_PASSWORD
252 name: {{ include "postgresql.secretName" . }}
253 key: {{ include "postgresql.replicationPasswordKey" . }}
255 {{- if not (eq .Values.replication.synchronousCommit "off") }}
256 - name: POSTGRES_SYNCHRONOUS_COMMIT_MODE
257 value: {{ .Values.replication.synchronousCommit | quote }}
258 - name: POSTGRES_NUM_SYNCHRONOUS_REPLICAS
259 value: {{ .Values.replication.numSynchronousReplicas | quote }}
261 - name: POSTGRES_CLUSTER_APP_NAME
262 value: {{ .Values.replication.applicationName }}
265 {{- if .Values.primary.initdb.args }}
266 - name: POSTGRES_INITDB_ARGS
267 value: {{ .Values.primary.initdb.args | quote }}
269 {{- if .Values.primary.initdb.postgresqlWalDir }}
270 - name: POSTGRES_INITDB_WALDIR
271 value: {{ .Values.primary.initdb.postgresqlWalDir | quote }}
273 {{- if .Values.primary.initdb.user }}
274 - name: POSTGRESQL_INITSCRIPTS_USERNAME
275 value: {{ .Values.primary.initdb.user }}
277 {{- if .Values.primary.initdb.password }}
278 - name: POSTGRESQL_INITSCRIPTS_PASSWORD
279 value: {{ .Values.primary.initdb.password | quote }}
282 {{- if .Values.primary.standby.enabled }}
283 - name: POSTGRES_MASTER_HOST
284 value: {{ .Values.primary.standby.primaryHost }}
285 - name: POSTGRES_MASTER_PORT_NUMBER
286 value: {{ .Values.primary.standby.primaryPort | quote }}
289 - name: POSTGRESQL_ENABLE_LDAP
290 value: {{ ternary "yes" "no" .Values.ldap.enabled | quote }}
291 {{- if .Values.ldap.enabled }}
292 {{- if or .Values.ldap.url .Values.ldap.uri }}
293 - name: POSTGRESQL_LDAP_URL
294 value: {{ coalesce .Values.ldap.url .Values.ldap.uri }}
296 - name: POSTGRESQL_LDAP_SERVER
297 value: {{ .Values.ldap.server }}
298 - name: POSTGRESQL_LDAP_PORT
299 value: {{ .Values.ldap.port | quote }}
300 - name: POSTGRESQL_LDAP_SCHEME
301 value: {{ .Values.ldap.scheme }}
302 {{- if (include "postgresql.ldap.tls.enabled" .) }}
303 - name: POSTGRESQL_LDAP_TLS
306 - name: POSTGRESQL_LDAP_PREFIX
307 value: {{ .Values.ldap.prefix | quote }}
308 - name: POSTGRESQL_LDAP_SUFFIX
309 value: {{ .Values.ldap.suffix | quote }}
310 - name: POSTGRESQL_LDAP_BASE_DN
311 value: {{ coalesce .Values.ldap.baseDN .Values.ldap.basedn }}
312 - name: POSTGRESQL_LDAP_BIND_DN
313 value: {{ coalesce .Values.ldap.bindDN .Values.ldap.binddn}}
314 {{- if or (not (empty .Values.ldap.bind_password)) (not (empty .Values.ldap.bindpw)) }}
315 - name: POSTGRESQL_LDAP_BIND_PASSWORD
318 name: {{ include "postgresql.secretName" . }}
321 - name: POSTGRESQL_LDAP_SEARCH_ATTR
322 value: {{ coalesce .Values.ldap.search_attr .Values.ldap.searchAttribute }}
323 - name: POSTGRESQL_LDAP_SEARCH_FILTER
324 value: {{ coalesce .Values.ldap.search_filter .Values.ldap.searchFilter }}
328 - name: POSTGRESQL_ENABLE_TLS
329 value: {{ ternary "yes" "no" .Values.tls.enabled | quote }}
330 {{- if .Values.tls.enabled }}
331 - name: POSTGRESQL_TLS_PREFER_SERVER_CIPHERS
332 value: {{ ternary "yes" "no" .Values.tls.preferServerCiphers | quote }}
333 - name: POSTGRESQL_TLS_CERT_FILE
334 value: {{ include "postgresql.tlsCert" . }}
335 - name: POSTGRESQL_TLS_KEY_FILE
336 value: {{ include "postgresql.tlsCertKey" . }}
337 {{- if .Values.tls.certCAFilename }}
338 - name: POSTGRESQL_TLS_CA_FILE
339 value: {{ include "postgresql.tlsCACert" . }}
341 {{- if .Values.tls.crlFilename }}
342 - name: POSTGRESQL_TLS_CRL_FILE
343 value: {{ include "postgresql.tlsCRL" . }}
347 - name: POSTGRESQL_LOG_HOSTNAME
348 value: {{ .Values.audit.logHostname | quote }}
349 - name: POSTGRESQL_LOG_CONNECTIONS
350 value: {{ .Values.audit.logConnections | quote }}
351 - name: POSTGRESQL_LOG_DISCONNECTIONS
352 value: {{ .Values.audit.logDisconnections | quote }}
353 {{- if .Values.audit.logLinePrefix }}
354 - name: POSTGRESQL_LOG_LINE_PREFIX
355 value: {{ .Values.audit.logLinePrefix | quote }}
357 {{- if .Values.audit.logTimezone }}
358 - name: POSTGRESQL_LOG_TIMEZONE
359 value: {{ .Values.audit.logTimezone | quote }}
361 {{- if .Values.audit.pgAuditLog }}
362 - name: POSTGRESQL_PGAUDIT_LOG
363 value: {{ .Values.audit.pgAuditLog | quote }}
365 - name: POSTGRESQL_PGAUDIT_LOG_CATALOG
366 value: {{ .Values.audit.pgAuditLogCatalog | quote }}
368 - name: POSTGRESQL_CLIENT_MIN_MESSAGES
369 value: {{ .Values.audit.clientMinMessages | quote }}
370 - name: POSTGRESQL_SHARED_PRELOAD_LIBRARIES
371 value: {{ .Values.postgresqlSharedPreloadLibraries | quote }}
372 {{- if .Values.primary.extraEnvVars }}
373 {{- include "common.tplvalues.render" (dict "value" .Values.primary.extraEnvVars "context" $) | nindent 12 }}
375 {{- if or .Values.primary.extraEnvVarsCM .Values.primary.extraEnvVarsSecret }}
377 {{- if .Values.primary.extraEnvVarsCM }}
379 name: {{ .Values.primary.extraEnvVarsCM }}
381 {{- if .Values.primary.extraEnvVarsSecret }}
383 name: {{ .Values.primary.extraEnvVarsSecret }}
387 - name: tcp-postgresql
388 containerPort: {{ .Values.containerPorts.postgresql }}
389 {{- if not .Values.diagnosticMode.enabled }}
390 {{- if .Values.primary.customStartupProbe }}
391 startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.primary.customStartupProbe "context" $) | nindent 12 }}
392 {{- else if .Values.primary.startupProbe.enabled }}
393 startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.primary.startupProbe "enabled") "context" $) | nindent 12 }}
398 {{- if (include "postgresql.database" .) }}
399 - exec pg_isready -U {{ default "postgres" $customUser | quote }} -d "dbname={{ include "postgresql.database" . }} {{- if and .Values.tls.enabled .Values.tls.certCAFilename }} sslcert={{ include "postgresql.tlsCert" . }} sslkey={{ include "postgresql.tlsCertKey" . }}{{- end }}" -h 127.0.0.1 -p {{ .Values.containerPorts.postgresql }}
401 - exec pg_isready -U {{ default "postgres" $customUser | quote }} {{- if and .Values.tls.enabled .Values.tls.certCAFilename }} -d "sslcert={{ include "postgresql.tlsCert" . }} sslkey={{ include "postgresql.tlsCertKey" . }}"{{- end }} -h 127.0.0.1 -p {{ .Values.containerPorts.postgresql }}
404 {{- if .Values.primary.customLivenessProbe }}
405 livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.primary.customLivenessProbe "context" $) | nindent 12 }}
406 {{- else if .Values.primary.livenessProbe.enabled }}
407 livenessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.primary.livenessProbe "enabled") "context" $) | nindent 12 }}
412 {{- if (include "postgresql.database" .) }}
413 - exec pg_isready -U {{ default "postgres" $customUser | quote }} -d "dbname={{ include "postgresql.database" . }} {{- if and .Values.tls.enabled .Values.tls.certCAFilename }} sslcert={{ include "postgresql.tlsCert" . }} sslkey={{ include "postgresql.tlsCertKey" . }}{{- end }}" -h 127.0.0.1 -p {{ .Values.containerPorts.postgresql }}
415 - exec pg_isready -U {{ default "postgres" $customUser | quote }} {{- if and .Values.tls.enabled .Values.tls.certCAFilename }} -d "sslcert={{ include "postgresql.tlsCert" . }} sslkey={{ include "postgresql.tlsCertKey" . }}"{{- end }} -h 127.0.0.1 -p {{ .Values.containerPorts.postgresql }}
418 {{- if .Values.primary.customReadinessProbe }}
419 readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.primary.customReadinessProbe "context" $) | nindent 12 }}
420 {{- else if .Values.primary.readinessProbe.enabled }}
421 readinessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.primary.readinessProbe "enabled") "context" $) | nindent 12 }}
427 {{- include "postgresql.readinessProbeCommand" . | nindent 16 }}
430 {{- if .Values.primary.resources }}
431 resources: {{- toYaml .Values.primary.resources | nindent 12 }}
433 {{- if .Values.primary.lifecycleHooks }}
434 lifecycle: {{- include "common.tplvalues.render" (dict "value" .Values.primary.lifecycleHooks "context" $) | nindent 12 }}
437 {{- if or .Values.primary.initdb.scriptsConfigMap .Values.primary.initdb.scripts }}
438 - name: custom-init-scripts
439 mountPath: /docker-entrypoint-initdb.d/
441 {{- if .Values.primary.initdb.scriptsSecret }}
442 - name: custom-init-scripts-secret
443 mountPath: /docker-entrypoint-initdb.d/secret
445 {{- if or .Values.primary.extendedConfiguration .Values.primary.existingExtendedConfigmap }}
446 - name: postgresql-extended-config
447 mountPath: /bitnami/postgresql/conf/conf.d/
449 {{- if .Values.auth.usePasswordFiles }}
450 - name: postgresql-password
451 mountPath: /opt/bitnami/postgresql/secrets/
453 {{- if .Values.tls.enabled }}
454 - name: postgresql-certificates
455 mountPath: /opt/bitnami/postgresql/certs
458 {{- if .Values.shmVolume.enabled }}
462 {{- if .Values.primary.persistence.enabled }}
464 mountPath: {{ .Values.primary.persistence.mountPath }}
465 {{- if .Values.primary.persistence.subPath }}
466 subPath: {{ .Values.primary.persistence.subPath }}
469 {{- if or .Values.primary.configuration .Values.primary.pgHbaConfiguration .Values.primary.existingConfigmap }}
470 - name: postgresql-config
471 mountPath: /bitnami/postgresql/conf
473 {{- if .Values.primary.extraVolumeMounts }}
474 {{- include "common.tplvalues.render" (dict "value" .Values.primary.extraVolumeMounts "context" $) | nindent 12 }}
476 {{- if .Values.metrics.enabled }}
478 image: {{ include "postgresql.metrics.image" . }}
479 imagePullPolicy: {{ .Values.metrics.image.pullPolicy | quote }}
480 {{- if .Values.metrics.containerSecurityContext.enabled }}
481 securityContext: {{- omit .Values.metrics.containerSecurityContext "enabled" | toYaml | nindent 12 }}
483 {{- if .Values.diagnosticMode.enabled }}
484 command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }}
485 args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }}
486 {{- else if .Values.metrics.customMetrics }}
487 args: ["--extend.query-path", "/conf/custom-metrics.yaml"]
490 {{- $database := required "In order to enable metrics you need to specify a database (.Values.auth.database or .Values.global.postgresql.auth.database)" (include "postgresql.database" .) }}
491 - name: DATA_SOURCE_URI
492 value: {{ printf "127.0.0.1:%d/%s?sslmode=disable" (int (include "postgresql.service.port" .)) $database }}
493 {{- if .Values.auth.usePasswordFiles }}
494 - name: DATA_SOURCE_PASS_FILE
495 value: {{ printf "/opt/bitnami/postgresql/secrets/%s" (ternary "password" "postgres-password" (and (not (empty $customUser)) (ne $customUser "postgres"))) }}
497 - name: DATA_SOURCE_PASS
500 name: {{ include "postgresql.secretName" . }}
501 key: {{ include "postgresql.userPasswordKey" . }}
503 - name: DATA_SOURCE_USER
504 value: {{ default "postgres" $customUser | quote }}
505 {{- if .Values.metrics.extraEnvVars }}
506 {{- include "common.tplvalues.render" (dict "value" .Values.metrics.extraEnvVars "context" $) | nindent 12 }}
510 containerPort: {{ .Values.metrics.containerPorts.metrics }}
511 {{- if not .Values.diagnosticMode.enabled }}
512 {{- if .Values.metrics.customStartupProbe }}
513 startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.metrics.customStartupProbe "context" $) | nindent 12 }}
514 {{- else if .Values.metrics.startupProbe.enabled }}
515 startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.metrics.startupProbe "enabled") "context" $) | nindent 12 }}
519 {{- if .Values.metrics.customLivenessProbe }}
520 livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.metrics.customLivenessProbe "context" $) | nindent 12 }}
521 {{- else if .Values.metrics.livenessProbe.enabled }}
522 livenessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.metrics.livenessProbe "enabled") "context" $) | nindent 12 }}
527 {{- if .Values.metrics.customReadinessProbe }}
528 readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.metrics.customReadinessProbe "context" $) | nindent 12 }}
529 {{- else if .Values.metrics.readinessProbe.enabled }}
530 readinessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.metrics.readinessProbe "enabled") "context" $) | nindent 12 }}
537 {{- if .Values.auth.usePasswordFiles }}
538 - name: postgresql-password
539 mountPath: /opt/bitnami/postgresql/secrets/
541 {{- if .Values.metrics.customMetrics }}
542 - name: custom-metrics
546 {{- if .Values.metrics.resources }}
547 resources: {{- toYaml .Values.metrics.resources | nindent 12 }}
550 {{- if .Values.primary.sidecars }}
551 {{- include "common.tplvalues.render" ( dict "value" .Values.primary.sidecars "context" $ ) | nindent 8 }}
554 {{- if or .Values.primary.configuration .Values.primary.pgHbaConfiguration .Values.primary.existingConfigmap }}
555 - name: postgresql-config
557 name: {{ include "postgresql.primary.configmapName" . }}
559 {{- if or .Values.primary.extendedConfiguration .Values.primary.existingExtendedConfigmap }}
560 - name: postgresql-extended-config
562 name: {{ include "postgresql.primary.extendedConfigmapName" . }}
564 {{- if .Values.auth.usePasswordFiles }}
565 - name: postgresql-password
567 secretName: {{ include "postgresql.secretName" . }}
569 {{- if or .Values.primary.initdb.scriptsConfigMap .Values.primary.initdb.scripts }}
570 - name: custom-init-scripts
572 name: {{ include "postgresql.initdb.scriptsCM" . }}
574 {{- if .Values.primary.initdb.scriptsSecret }}
575 - name: custom-init-scripts-secret
577 secretName: {{ tpl .Values.primary.initdb.scriptsSecret $ }}
579 {{- if .Values.tls.enabled }}
580 - name: raw-certificates
582 secretName: {{ include "postgresql.tlsSecretName" . }}
583 - name: postgresql-certificates
586 {{- if .Values.primary.extraVolumes }}
587 {{- include "common.tplvalues.render" ( dict "value" .Values.primary.extraVolumes "context" $ ) | nindent 8 }}
589 {{- if and .Values.metrics.enabled .Values.metrics.customMetrics }}
590 - name: custom-metrics
592 name: {{ printf "%s-metrics" (include "common.names.fullname" .) }}
594 {{- if .Values.shmVolume.enabled }}
598 {{- if .Values.shmVolume.sizeLimit }}
599 sizeLimit: {{ .Values.shmVolume.sizeLimit }}
602 {{- if and .Values.primary.persistence.enabled .Values.primary.persistence.existingClaim }}
604 persistentVolumeClaim:
605 claimName: {{ tpl .Values.primary.persistence.existingClaim $ }}
606 {{- else if not .Values.primary.persistence.enabled }}
610 volumeClaimTemplates:
613 {{- if .Values.primary.persistence.annotations }}
614 annotations: {{- include "common.tplvalues.render" (dict "value" .Values.primary.persistence.annotations "context" $) | nindent 10 }}
616 {{- if .Values.primary.persistence.labels }}
617 labels: {{- include "common.tplvalues.render" (dict "value" .Values.primary.persistence.labels "context" $) | nindent 10 }}
621 {{- range .Values.primary.persistence.accessModes }}
624 {{- if .Values.primary.persistence.dataSource }}
625 dataSource: {{- include "common.tplvalues.render" (dict "value" .Values.primary.persistence.dataSource "context" $) | nindent 10 }}
629 storage: {{ .Values.primary.persistence.size | quote }}
630 {{- if .Values.primary.persistence.selector }}
631 selector: {{- include "common.tplvalues.render" (dict "value" .Values.primary.persistence.selector "context" $) | nindent 10 }}
633 {{- include "common.storage.class" (dict "persistence" .Values.primary.persistence "global" .Values.global) | nindent 8 }}