Fix issue with applying postgresql.conf to PostgreSQL

This commit is contained in:
wbsong111
2025-01-06 11:01:31 +09:00
parent 4b898f8634
commit 6108c65b0c
2 changed files with 27 additions and 2 deletions
@@ -1,3 +1,14 @@
{{/*
Enable the PostgreSQL configuration automatically
*/}}
{{- define "postgresql-ha.configuration.postgresql.enabled" -}}
{{- if and (or .Values.postgresql.repmgrConfiguration .Values.postgresql.configuration .Values.postgresql.pgHbaConfiguration) (not .Values.postgresql.configurationCM) }}
false
{{- else }}
true
{{- end }}
{{- end }}
{{/*
Return Postgresql - memory
*/}}
@@ -58,6 +69,8 @@ wal_buffers = -1
max_wal_size = 10GB
min_wal_size = 1GB
shared_preload_libraries = '{{ .Values.postgresql.sharedPreloadLibraries }}'
shared_buffers = {{ div $memory 4 }}MB
effective_cache_size = {{ mul (div $memory 4) 3 }}MB
@@ -122,6 +122,9 @@ spec:
chown {{ .Values.postgresql.containerSecurityContext.runAsUser }}:{{ .Values.postgresql.podSecurityContext.fsGroup }} {{ .Values.persistence.mountPath }}
find {{ .Values.persistence.mountPath }} -mindepth 1 -maxdepth 1 -not -name ".snapshot" -not -name "lost+found" | \
xargs -r chown -R {{ .Values.postgresql.containerSecurityContext.runAsUser }}:{{ .Values.postgresql.podSecurityContext.fsGroup }}
{{- if ( include "postgresql-ha.configuration.postgresql.enabled" . ) }}
chmod -R 777 /dev/shm
{{- end }}
securityContext: {{- .Values.volumePermissions.podSecurityContext | toYaml | nindent 12 }}
{{- if .Values.volumePermissions.resources }}
resources: {{- toYaml .Values.volumePermissions.resources | nindent 12 }}
@@ -129,6 +132,10 @@ spec:
volumeMounts:
- name: data
mountPath: {{ .Values.persistence.mountPath }}
{{- if ( include "postgresql-ha.configuration.postgresql.enabled" . ) }}
- name: dshm
mountPath: /dev/shm
{{- end }}
{{- 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 }}
@@ -458,7 +465,9 @@ spec:
{{- if .Values.postgresql.extraVolumeMounts }}
{{- include "common.tplvalues.render" (dict "value" .Values.postgresql.extraVolumeMounts "context" $) | nindent 12 }}
{{- end }}
{{- if ( include "postgresql-ha.configuration.postgresql.sharedMemory" . ) }}
{{- if ( include "postgresql-ha.configuration.postgresql.enabled" . ) }}
- name: postgresql-config
mountPath: /bitnami/repmgr/conf
- name: dshm
mountPath: /dev/shm
{{- end }}
@@ -602,7 +611,10 @@ spec:
- name: postgresql-certificates
emptyDir: {}
{{- end }}
{{- if ( include "postgresql-ha.configuration.postgresql.sharedMemory" . ) }}
{{- if ( include "postgresql-ha.configuration.postgresql.enabled" . ) }}
- name: postgresql-config
configMap:
name: {{ include "postgresql-ha.postgresqlConfigurationCM" . }}
- name: dshm
emptyDir:
medium: Memory