Files
charts/bitnami/postgresql-ha/templates/postgresql/statefulset.yaml
2021-05-03 08:37:58 +02:00

498 lines
26 KiB
YAML

apiVersion: {{ include "common.capabilities.statefulset.apiVersion" . }}
kind: StatefulSet
metadata:
name: {{ include "postgresql-ha.postgresql" . }}
labels: {{- include "common.labels.standard" . | nindent 4 }}
app.kubernetes.io/component: postgresql
{{- if .Values.postgresql.labels }}
{{- include "common.tplvalues.render" (dict "value" .Values.postgresql.labels "context" $) | nindent 4 }}
{{- end }}
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
serviceName: {{ include "postgresql-ha.postgresql" . }}-headless
replicas: {{ .Values.postgresql.replicaCount }}
updateStrategy:
type: {{ .Values.postgresql.updateStrategyType }}
{{- if (eq "Recreate" .Values.postgresql.updateStrategyType) }}
rollingUpdate: null
{{- end }}
podManagementPolicy: Parallel
selector:
matchLabels: {{- include "common.labels.matchLabels" . | nindent 6 }}
app.kubernetes.io/component: postgresql
template:
metadata:
labels: {{- include "common.labels.standard" . | nindent 8 }}
app.kubernetes.io/component: postgresql
{{- if .Values.postgresql.podLabels }}
{{- include "common.tplvalues.render" (dict "value" .Values.postgresql.podLabels "context" $) | nindent 8 }}
{{- end }}
{{- if or .Values.postgresql.podAnnotations (and .Values.metrics.enabled .Values.metrics.annotations) }}
annotations:
{{- if .Values.postgresql.podAnnotations }}
{{- include "common.tplvalues.render" (dict "value" .Values.postgresql.podAnnotations "context" $) | nindent 8 }}
{{- end }}
{{- if and .Values.metrics.enabled .Values.metrics.annotations }}
{{- include "common.tplvalues.render" (dict "value" .Values.metrics.annotations "context" $) | nindent 8 }}
{{- end }}
{{- end }}
spec:
{{- include "postgresql-ha.imagePullSecrets" . | nindent 6 }}
{{- if .Values.postgresql.hostAliases }}
hostAliases: {{- include "common.tplvalues.render" (dict "value" .Values.postgresql.hostAliases "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.postgresql.affinity }}
affinity: {{- include "common.tplvalues.render" (dict "value" .Values.postgresql.affinity "context" $) | nindent 8 }}
{{- else }}
affinity:
podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.postgresql.podAffinityPreset "component" "postgresql" "context" $) | nindent 10 }}
podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.postgresql.podAntiAffinityPreset "component" "postgresql" "context" $) | nindent 10 }}
nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.postgresql.nodeAffinityPreset.type "key" .Values.postgresql.nodeAffinityPreset.key "values" .Values.postgresql.nodeAffinityPreset.values) | nindent 10 }}
{{- end }}
{{- if .Values.postgresql.nodeSelector }}
nodeSelector: {{- include "common.tplvalues.render" (dict "value" .Values.postgresql.nodeSelector "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.postgresql.tolerations }}
tolerations: {{- include "common.tplvalues.render" (dict "value" .Values.postgresql.tolerations "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.postgresql.priorityClassName }}
priorityClassName: {{ .Values.postgresql.priorityClassName }}
{{- end }}
{{- if .Values.postgresql.securityContext.enabled }}
securityContext: {{- omit .Values.postgresql.securityContext "enabled" | toYaml | nindent 8 }}
{{- end }}
{{- if .Values.serviceAccount.enabled }}
serviceAccountName: {{ default (include "common.names.fullname" . ) .Values.serviceAccount.name}}
{{- end }}
initContainers:
{{- if and .Values.persistence.enabled (or (or (not (empty .Values.postgresql.extendedConf)) (not (empty .Values.postgresql.extendedConfCM)) ) .Values.volumePermissions.enabled) }}
- name: init-chmod-data
image: {{ include "postgresql-ha.volumePermissionsImage" . }}
imagePullPolicy: {{ .Values.volumePermissionsImage.pullPolicy | quote }}
command:
- sh
- -c
- |
mkdir -p {{ .Values.persistence.mountPath }}/conf {{ .Values.persistence.mountPath }}/data {{ .Values.persistence.mountPath }}/lock
chmod 700 {{ .Values.persistence.mountPath }}/conf {{ .Values.persistence.mountPath }}/data {{ .Values.persistence.mountPath }}/lock
find {{ .Values.persistence.mountPath }} -mindepth 1 -maxdepth 1 -not -name ".snapshot" -not -name "lost+found" | \
xargs chown -R {{ .Values.postgresql.containerSecurityContext.runAsUser }}:{{ .Values.postgresql.securityContext.fsGroup }}
securityContext: {{- .Values.volumePermissions.securityContext | toYaml | nindent 12 }}
{{- if .Values.volumePermissions.resources }}
resources: {{- toYaml .Values.volumePermissions.resources | nindent 12 }}
{{- end }}
volumeMounts:
- name: data
mountPath: {{ .Values.persistence.mountPath }}
{{- end }}
{{- if or .Values.postgresql.initContainers .Values.postgresql.extraInitContainers }}
{{- include "common.tplvalues.render" ( dict "value" (coalesce .Values.postgresql.initContainers .Values.postgresql.extraInitContainers) "context" $ ) | nindent 8 }}
{{- end }}
containers:
- name: postgresql
{{- if .Values.postgresql.lifecycleHooks }}
lifecycle: {{- include "common.tplvalues.render" (dict "value" .Values.postgresql.lifecycleHooks "context" $) | nindent 12 }}
{{- else }}
lifecycle:
preStop:
exec:
command:
- /pre-stop.sh
{{- end }}
{{- if .Values.postgresql.command }}
command: {{- include "common.tplvalues.render" (dict "value" .Values.postgresql.command "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.postgresql.args }}
args: {{- include "common.tplvalues.render" (dict "value" .Values.postgresql.args "context" $) | nindent 12 }}
{{- end }}
image: {{ include "postgresql-ha.postgresqlImage" . }}
imagePullPolicy: {{ .Values.postgresqlImage.pullPolicy | quote }}
{{- if .Values.postgresql.containerSecurityContext.enabled }}
securityContext: {{- omit .Values.postgresql.containerSecurityContext "enabled" | toYaml | nindent 12 }}
{{- end }}
# Auxiliary vars to populate environment variables
{{- $postgresqlReplicaCount := int .Values.postgresql.replicaCount }}
{{- $postgresqlFullname := include "postgresql-ha.postgresql" . }}
{{- $postgresqlHeadlessServiceName := printf "%s-headless" (include "postgresql-ha.postgresql" .) }}
{{- $clusterDomain:= .Values.clusterDomain }}
env:
- name: BITNAMI_DEBUG
value: {{ ternary "true" "false" .Values.postgresqlImage.debug | quote }}
# PostgreSQL configuration
- name: POSTGRESQL_VOLUME_DIR
value: {{ .Values.persistence.mountPath | quote }}
- name: PGDATA
value: {{ printf "%s/%s" .Values.persistence.mountPath "data" | quote }}
{{- if and (or (not (include "postgresql-ha.postgresqlCreateSecret" .)) (include "postgresql-ha.postgresqlPasswordProvided" .)) (not (eq (include "postgresql-ha.postgresqlUsername" .) "postgres")) }}
{{- if .Values.postgresql.usePasswordFile }}
- name: POSTGRES_POSTGRES_PASSWORD_FILE
value: "/opt/bitnami/postgresql/secrets/postgresql-postgres-password"
{{- else }}
- name: POSTGRES_POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: {{ template "postgresql-ha.postgresqlSecretName" . }}
key: postgresql-postgres-password
{{- end }}
{{- end }}
- name: POSTGRES_USER
value: {{ (include "postgresql-ha.postgresqlUsername" .) | quote }}
{{- if .Values.postgresql.usePasswordFile }}
- name: POSTGRES_PASSWORD_FILE
value: "/opt/bitnami/postgresql/secrets/postgresql-password"
{{- else }}
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "postgresql-ha.postgresqlSecretName" . }}
key: postgresql-password
{{- end }}
{{- if not (empty (include "postgresql-ha.postgresqlDatabase" .)) }}
- name: POSTGRES_DB
value: {{ (include "postgresql-ha.postgresqlDatabase" .) | quote }}
{{- end }}
- name: POSTGRESQL_LOG_HOSTNAME
value: {{ .Values.postgresql.audit.logHostname | quote }}
- name: POSTGRESQL_LOG_CONNECTIONS
value: {{ .Values.postgresql.audit.logConnections | quote }}
- name: POSTGRESQL_LOG_DISCONNECTIONS
value: {{ .Values.postgresql.audit.logDisconnections | quote }}
{{- if .Values.postgresql.audit.logLinePrefix }}
- name: POSTGRESQL_LOG_LINE_PREFIX
value: {{ .Values.postgresql.audit.logLinePrefix | quote }}
{{- end }}
{{- if .Values.postgresql.audit.logTimezone }}
- name: POSTGRESQL_LOG_TIMEZONE
value: {{ .Values.postgresql.audit.logTimezone | quote }}
{{- end }}
{{- if .Values.postgresql.audit.pgAuditLog }}
- name: POSTGRESQL_PGAUDIT_LOG
value: {{ .Values.postgresql.audit.pgAuditLog | quote }}
{{- end }}
- name: POSTGRESQL_PGAUDIT_LOG_CATALOG
value: {{ .Values.postgresql.audit.pgAuditLogCatalog | quote }}
- name: POSTGRESQL_CLIENT_MIN_MESSAGES
value: {{ .Values.postgresql.audit.clientMinMessages | quote }}
- name: POSTGRESQL_SHARED_PRELOAD_LIBRARIES
value: {{ .Values.postgresql.sharedPreloadLibraries | quote }}
{{- if .Values.postgresql.maxConnections }}
- name: POSTGRESQL_MAX_CONNECTIONS
value: {{ .Values.postgresql.maxConnections | quote }}
{{- end }}
{{- if .Values.postgresql.postgresConnectionLimit }}
- name: POSTGRESQL_POSTGRES_CONNECTION_LIMIT
value: {{ .Values.postgresql.postgresConnectionLimit | quote }}
{{- end }}
{{- if .Values.postgresql.dbUserConnectionLimit }}
- name: POSTGRESQL_USERNAME_CONNECTION_LIMIT
value: {{ .Values.postgresql.dbUserConnectionLimit | quote }}
{{- end }}
{{- if .Values.postgresql.tcpKeepalivesInterval }}
- name: POSTGRESQL_TCP_KEEPALIVES_INTERVAL
value: {{ .Values.postgresql.tcpKeepalivesInterval | quote }}
{{- end }}
{{- if .Values.postgresql.tcpKeepalivesIdle }}
- name: POSTGRESQL_TCP_KEEPALIVES_IDLE
value: {{ .Values.postgresql.tcpKeepalivesIdle | quote }}
{{- end }}
{{- if .Values.postgresql.tcpKeealivesCount }}
- name: POSTGRESQL_TCP_KEEPALIVES_COUNT
value: {{ .Values.postgresql.tcpKeealivesCount | quote }}
{{- end }}
{{- if .Values.postgresql.statementTimeout }}
- name: POSTGRESQL_STATEMENT_TIMEOUT
value: {{ .Values.postgresql.statementTimeout | quote }}
{{- end }}
{{- if .Values.postgresql.pghbaRemoveFilters }}
- name: POSTGRESQL_PGHBA_REMOVE_FILTERS
value: {{ .Values.postgresql.pghbaRemoveFilters | quote }}
{{- end }}
# Repmgr configuration
- name: MY_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: REPMGR_UPGRADE_EXTENSION
value: {{ ternary "yes" "no" .Values.postgresql.upgradeRepmgrExtension | quote }}
- name: REPMGR_PGHBA_TRUST_ALL
value: {{ ternary "yes" "no" .Values.postgresql.pgHbaTrustAll | quote }}
- name: REPMGR_MOUNTED_CONF_DIR
value: "/bitnami/repmgr/conf"
- name: REPMGR_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: REPMGR_PARTNER_NODES
value: {{range $e, $i := until $postgresqlReplicaCount }}{{ $postgresqlFullname }}-{{ $i }}.{{ $postgresqlHeadlessServiceName }}.$(REPMGR_NAMESPACE).svc.{{ $clusterDomain }},{{ end }}
- name: REPMGR_PRIMARY_HOST
value: {{ printf "%s-0.%s.$(REPMGR_NAMESPACE).svc.%s" $postgresqlFullname $postgresqlHeadlessServiceName $clusterDomain | quote }}
- name: REPMGR_NODE_NAME
value: "$(MY_POD_NAME)"
- name: REPMGR_NODE_NETWORK_NAME
value: "$(MY_POD_NAME).{{ $postgresqlHeadlessServiceName }}.$(REPMGR_NAMESPACE).svc.{{ $clusterDomain }}"
- name: REPMGR_LOG_LEVEL
value: {{ .Values.postgresql.repmgrLogLevel | quote }}
- name: REPMGR_CONNECT_TIMEOUT
value: {{ .Values.postgresql.repmgrConnectTimeout | quote }}
- name: REPMGR_RECONNECT_ATTEMPTS
value: {{ .Values.postgresql.repmgrReconnectAttempts | quote }}
- name: REPMGR_RECONNECT_INTERVAL
value: {{ .Values.postgresql.repmgrReconnectInterval | quote }}
- name: REPMGR_USERNAME
value: {{ (include "postgresql-ha.postgresqlRepmgrUsername" .) | quote }}
{{- if .Values.postgresql.usePasswordFile }}
- name: REPMGR_PASSWORD_FILE
value: "/opt/bitnami/postgresql/secrets/repmgr-password"
{{- else }}
- name: REPMGR_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "postgresql-ha.postgresqlSecretName" . }}
key: repmgr-password
{{- end }}
{{- if .Values.postgresql.repmgrUsePassfile }}
- name: REPMGR_USE_PASSFILE
value: {{ ternary "true" "false" .Values.postgresql.repmgrUsePassfile | quote }}
- name: REPMGR_PASSFILE_PATH
value: {{ default "/opt/bitnami/repmgr/conf/.pgpass" .Values.postgresql.repmgrPassfilePath }}
{{- end }}
{{- if (include "postgresql-ha.repmgrDatabase" .) }}
- name: REPMGR_DATABASE
value: {{ (include "postgresql-ha.repmgrDatabase" .) | quote }}
{{- end }}
{{- if .Values.postgresql.syncReplication }}
- name: POSTGRESQL_NUM_SYNCHRONOUS_REPLICAS
value: {{ sub (int .Values.postgresql.replicaCount) 1 | quote }}
{{- end }}
{{- if .Values.postgresql.extraEnvVars }}
{{- include "common.tplvalues.render" (dict "value" .Values.postgresql.extraEnvVars "context" $) | nindent 12 }}
{{- end }}
envFrom:
{{- if .Values.postgresql.extraEnvVarsCM }}
- configMapRef:
name: {{ .Values.postgresql.extraEnvVarsCM }}
{{- end }}
{{- if .Values.postgresql.extraEnvVarsSecret }}
- secretRef:
name: {{ .Values.postgresql.extraEnvVarsSecret }}
{{- end }}
ports:
- name: postgresql
containerPort: 5432
protocol: TCP
{{- if .Values.postgresql.livenessProbe.enabled }}
livenessProbe:
exec:
command:
- bash
- -ec
- '{{ include "postgresql-ha.pgpassword" . }} psql -w -U {{ include "postgresql-ha.postgresqlUsername" . | quote }} -d {{ (include "postgresql-ha.postgresqlDatabase" .) | quote }} -h 127.0.0.1 -c "SELECT 1"'
initialDelaySeconds: {{ .Values.postgresql.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.postgresql.livenessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.postgresql.livenessProbe.timeoutSeconds }}
successThreshold: {{ .Values.postgresql.livenessProbe.successThreshold }}
failureThreshold: {{ .Values.postgresql.livenessProbe.failureThreshold }}
{{- else if .Values.postgresql.customLivenessProbe }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.postgresql.customLivenessProbe "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.postgresql.readinessProbe.enabled }}
readinessProbe:
exec:
command:
- bash
- -ec
- '{{ include "postgresql-ha.pgpassword" . }} psql -w -U {{ include "postgresql-ha.postgresqlUsername" . | quote }} -d {{ (include "postgresql-ha.postgresqlDatabase" .) | quote }} -h 127.0.0.1 -c "SELECT 1"'
initialDelaySeconds: {{ .Values.postgresql.readinessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.postgresql.readinessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.postgresql.readinessProbe.timeoutSeconds }}
successThreshold: {{ .Values.postgresql.readinessProbe.successThreshold }}
failureThreshold: {{ .Values.postgresql.readinessProbe.failureThreshold }}
{{- else if .Values.postgresql.customReadinessProbe }}
readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.postgresql.customReadinessProbe "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.postgresql.startupProbe.enabled }}
startupProbe:
exec:
command:
- bash
- -ec
- '{{ include "postgresql-ha.pgpassword" . }} psql -w -U {{ include "postgresql-ha.postgresqlUsername" . | quote }} -d {{ (include "postgresql-ha.postgresqlDatabase" .) | quote }} -h 127.0.0.1 -c "SELECT 1"'
initialDelaySeconds: {{ .Values.postgresql.startupProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.postgresql.startupProbe.periodSeconds }}
timeoutSeconds: {{ .Values.postgresql.startupProbe.timeoutSeconds }}
successThreshold: {{ .Values.postgresql.startupProbe.successThreshold }}
failureThreshold: {{ .Values.postgresql.startupProbe.failureThreshold }}
{{- else if .Values.postgresql.customStartupProbe }}
startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.postgresql.customStartupProbe "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.postgresql.resources }}
resources: {{- toYaml .Values.postgresql.resources | nindent 12 }}
{{- end }}
volumeMounts:
{{- if or .Values.postgresql.repmgrConfiguration .Values.postgresql.configuration .Values.postgresql.pgHbaConfiguration .Values.postgresql.configurationCM }}
- name: postgresql-config
mountPath: /bitnami/repmgr/conf
{{- end }}
{{- if or .Values.postgresql.extendedConf .Values.postgresql.extendedConfCM }}
- name: postgresql-extended-config
mountPath: /bitnami/postgresql/conf/conf.d/
{{- end }}
{{- if or .Values.postgresql.initdbScriptsCM .Values.postgresql.initdbScripts }}
- name: custom-init-scripts
mountPath: /docker-entrypoint-initdb.d/
{{- end }}
{{- if .Values.postgresql.initdbScriptsSecret }}
- name: custom-init-scripts-secret
mountPath: /docker-entrypoint-initdb.d/secret
{{- end }}
{{- if .Values.postgresql.usePasswordFile }}
- name: postgresql-password
mountPath: /opt/bitnami/postgresql/secrets/
{{- end }}
- name: data
mountPath: {{ .Values.persistence.mountPath }}
- name: hooks-scripts
mountPath: /pre-stop.sh
subPath: pre-stop.sh
{{- if .Values.postgresql.extraVolumeMounts }}
{{- include "common.tplvalues.render" (dict "value" .Values.postgresql.extraVolumeMounts "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.metrics.enabled }}
- name: metrics
image: {{ include "postgresql-ha.metricsImage" . }}
imagePullPolicy: {{ .Values.metricsImage.pullPolicy | quote }}
{{- if .Values.metrics.securityContext.enabled }}
securityContext: {{- omit .Values.metrics.securityContext "enabled" | toYaml | nindent 12 }}
{{- end }}
env:
- name: DATA_SOURCE_URI
value: {{ printf "127.0.0.1:5432/%s?sslmode=disable" (include "postgresql-ha.postgresqlDatabase" .) | quote }}
{{- if .Values.postgresql.usePasswordFile }}
- name: DATA_SOURCE_PASS_FILE
value: "/opt/bitnami/postgresql/secrets/postgresql-password"
{{- else }}
- name: DATA_SOURCE_PASS
valueFrom:
secretKeyRef:
name: {{ include "postgresql-ha.postgresqlSecretName" . }}
key: postgresql-password
{{- end }}
- name: DATA_SOURCE_USER
value: {{ (include "postgresql-ha.postgresqlUsername" .) | quote }}
ports:
- name: metrics
containerPort: 9187
protocol: TCP
{{- if .Values.metrics.livenessProbe.enabled }}
livenessProbe:
httpGet:
path: /
port: metrics
initialDelaySeconds: {{ .Values.metrics.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.metrics.livenessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.metrics.livenessProbe.timeoutSeconds }}
successThreshold: {{ .Values.metrics.livenessProbe.successThreshold }}
failureThreshold: {{ .Values.metrics.livenessProbe.failureThreshold }}
{{- end }}
{{- if .Values.metrics.readinessProbe.enabled }}
readinessProbe:
httpGet:
path: /
port: metrics
initialDelaySeconds: {{ .Values.metrics.readinessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.metrics.readinessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.metrics.readinessProbe.timeoutSeconds }}
successThreshold: {{ .Values.metrics.readinessProbe.successThreshold }}
failureThreshold: {{ .Values.metrics.readinessProbe.failureThreshold }}
{{- end }}
{{- if .Values.metrics.startupProbe.enabled }}
startupProbe:
httpGet:
path: /
port: metrics
initialDelaySeconds: {{ .Values.metrics.startupProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.metrics.startupProbe.periodSeconds }}
timeoutSeconds: {{ .Values.metrics.startupProbe.timeoutSeconds }}
successThreshold: {{ .Values.metrics.startupProbe.successThreshold }}
failureThreshold: {{ .Values.metrics.startupProbe.failureThreshold }}
{{- end }}
{{- if .Values.metrics.resources }}
resources: {{- toYaml .Values.metrics.resources | nindent 12 }}
{{- end }}
volumeMounts:
{{- if .Values.postgresql.usePasswordFile }}
- name: postgresql-password
mountPath: /opt/bitnami/postgresql/secrets/
{{- end }}
{{- end }}
{{- if .Values.postgresql.sidecars }}
{{- include "common.tplvalues.render" (dict "value" .Values.postgresql.sidecars "context" $) | nindent 8 }}
{{- end }}
volumes:
{{- if .Values.postgresql.extraVolumes }}
{{- include "common.tplvalues.render" (dict "value" .Values.postgresql.extraVolumes "context" $) | nindent 8 }}
{{- end }}
- name: hooks-scripts
configMap:
name: {{ printf "%s-hooks-scripts" (include "postgresql-ha.postgresql" .) }}
defaultMode: 0755
{{- if or .Values.postgresql.repmgrConfiguration .Values.postgresql.configuration .Values.postgresql.pgHbaConfiguration .Values.postgresql.configurationCM }}
- name: postgresql-config
configMap:
name: {{ include "postgresql-ha.postgresqlConfigurationCM" . }}
{{- end }}
{{- if or .Values.postgresql.extendedConf .Values.postgresql.extendedConfCM }}
- name: postgresql-extended-config
configMap:
name: {{ template "postgresql-ha.postgresqlExtendedConfCM" . }}
{{- end }}
{{- if .Values.postgresql.initdbScriptsSecret }}
- name: custom-init-scripts-secret
secret:
secretName: {{ template "postgresql-ha.postgresqlInitdbScriptsSecret" . }}
{{- end }}
{{- if .Values.postgresql.usePasswordFile }}
- name: postgresql-password
secret:
secretName: {{ include "postgresql-ha.postgresqlSecretName" . }}
{{- end }}
{{- if or .Values.postgresql.initdbScriptsCM .Values.postgresql.initdbScripts }}
- name: custom-init-scripts
configMap:
name: {{ template "postgresql-ha.postgresqlInitdbScriptsCM" . }}
{{- end }}
{{- if and .Values.persistence.enabled .Values.persistence.existingClaim }}
- name: data
persistentVolumeClaim:
{{- with .Values.persistence.existingClaim }}
claimName: {{ tpl . $ }}
{{- end }}
{{- else if not .Values.persistence.enabled }}
- name: data
emptyDir: {}
{{- else if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }}
volumeClaimTemplates:
- metadata:
name: data
{{- if .Values.persistence.annotations }}
annotations: {{- include "common.tplvalues.render" (dict "value" .Values.persistence.annotations "context" $) | nindent 10 }}
{{- end }}
spec:
accessModes:
{{- range .Values.persistence.accessModes }}
- {{ . | quote }}
{{- end }}
resources:
requests:
storage: {{ .Values.persistence.size | quote }}
{{- if .Values.persistence.selector }}
selector: {{- include "common.tplvalues.render" (dict "value" .Values.persistence.selector "context" $) | nindent 10 }}
{{- end -}}
{{- include "common.storage.class" (dict "persistence" .Values.persistence "global" .Values.global) | nindent 8 }}
{{- end }}