Add custom postgresql configuration in helm chart
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
global:
|
||||
imageRegistry: "" # paasup.io
|
||||
|
||||
postgresql:
|
||||
# image:
|
||||
# tag: "" # helm 차트의 기본값을 사용. 버전 변경 시에는 차트 변경을 우선 고려하고 변경 불가 상황에서만 변경.
|
||||
username: postgres
|
||||
password: postgres
|
||||
|
||||
repmgrUsername: postgres
|
||||
repmgrPassword: postgres
|
||||
|
||||
maxConnections: "100"
|
||||
sharedPreloadLibraries: "repmgr, pgaudit, pg_stat_statements"
|
||||
|
||||
# initdbScripts:
|
||||
# init.sql: |
|
||||
# CREATE USER gitea WITH PASSWORD 'gitea';
|
||||
# CREATE DATABASE gitea;
|
||||
# GRANT CONNECT ON DATABASE gitea TO gitea;
|
||||
|
||||
# \c gitea
|
||||
# CREATE SCHEMA IF NOT EXISTS gitea AUTHORIZATION gitea;
|
||||
|
||||
# CREATE DATABASE gitea_session;
|
||||
# GRANT CONNECT ON DATABASE gitea_session TO gitea;
|
||||
|
||||
# \c gitea_session
|
||||
# CREATE SCHEMA IF NOT EXISTS gitea AUTHORIZATION gitea;
|
||||
|
||||
# CREATE TABLE IF NOT EXISTS session (
|
||||
# key CHAR(16) NOT NULL,
|
||||
# data bytea,
|
||||
# expiry bigint NOT NULL,
|
||||
# PRIMARY KEY (key)
|
||||
# );
|
||||
# GRANT ALL ON TABLE session TO gitea;
|
||||
# ALTER TABLE session OWNER TO gitea;
|
||||
# ALTER TABLE session SET SCHEMA gitea;
|
||||
|
||||
# CREATE DATABASE keycloak WITH encoding 'UTF8';
|
||||
# CREATE USER keycloak WITH PASSWORD 'keycloak';
|
||||
# GRANT CONNECT ON DATABASE keycloak TO keycloak;
|
||||
|
||||
# \c keycloak
|
||||
# CREATE SCHEMA IF NOT EXISTS keycloak AUTHORIZATION keycloak;
|
||||
|
||||
replicaCount: 1
|
||||
|
||||
extraEnvVars:
|
||||
- name: TZ
|
||||
value: Asia/Seoul
|
||||
|
||||
resources:
|
||||
requests:
|
||||
cpu: 100m
|
||||
memory: 512Mi
|
||||
limits:
|
||||
cpu: 500m
|
||||
memory: 1024Mi
|
||||
|
||||
tolerations: []
|
||||
|
||||
nodeSelector: {}
|
||||
|
||||
pgpool:
|
||||
adminPassword: postgres
|
||||
|
||||
## postgresql.replcaCount가 2 이상일 때 주석
|
||||
replicaCount: 0
|
||||
|
||||
## postgresql.replcaCount가 2 이상일 때 주석 해제
|
||||
# replicaCount: 2
|
||||
# authenticationMethod: ""
|
||||
# maxPool: "4"
|
||||
# numInitChildren: "32"
|
||||
# resources:
|
||||
# requests:
|
||||
# cpu: 100m
|
||||
# memory: 128Mi
|
||||
# limits:
|
||||
# cpu: 100m
|
||||
# memory: 128Mi
|
||||
|
||||
## paasup.enabled : true 일 때 주석 해제
|
||||
# customUsers:
|
||||
# usernames: "gitea;keycloak"
|
||||
# passwords: "gitea;keycloak"
|
||||
|
||||
persistence:
|
||||
enabled: true
|
||||
storageClass: ""
|
||||
size: 1Gi
|
||||
|
||||
volumePermissions:
|
||||
enabled: true
|
||||
podSecurityContext:
|
||||
runAsUser: 0
|
||||
@@ -0,0 +1,88 @@
|
||||
{{/*
|
||||
Return Postgresql - memory
|
||||
*/}}
|
||||
{{- define "postgresql-ha.configuration.postgresql.memory" -}}
|
||||
{{- $memory := required "postgresql.resources.limits.memory is required" .Values.postgresql.resources.limits.memory | trim -}}
|
||||
{{- if hasSuffix "Gi" $memory -}}
|
||||
{{ mul (int (trimSuffix "Gi" $memory)) 1024 }}
|
||||
{{- else if hasSuffix "GB" $memory -}}
|
||||
{{ mul (int (trimSuffix "GB" $memory)) 1000 }}
|
||||
{{- else if hasSuffix "Mi" $memory -}}
|
||||
{{ int (trimSuffix "Mi" $memory) }}
|
||||
{{- else if hasSuffix "MB" $memory -}}
|
||||
{{ int (trimSuffix "MB" $memory) }}
|
||||
{{- else -}}
|
||||
{{ fail "`postgresql.resources.limits.memory` 값이 올바른 형식으로 설정되지 않았습니다. (예: '10Gi', '512Mi')" }}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Return Postgresql - shared memory.
|
||||
*/}}
|
||||
{{- define "postgresql-ha.configuration.postgresql.sharedMemory" -}}
|
||||
{{- $memory := include "postgresql-ha.configuration.postgresql.memory" . | int -}}
|
||||
{{- if gt $memory 256 -}}
|
||||
{{ div $memory 4 }}Mi
|
||||
{{- end }}
|
||||
{{- "" -}}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Return postgres.conf.
|
||||
*/}}
|
||||
{{- define "postgresql-ha.configuration.postgresConf" -}}
|
||||
{{- $memory := include "postgresql-ha.configuration.postgresql.memory" . | int -}}
|
||||
listen_addresses = '*'
|
||||
port = {{ .Values.postgresql.containerPorts.postgresql | quote }}
|
||||
password_encryption = md5
|
||||
|
||||
wal_level = 'replica'
|
||||
archive_mode = 'on'
|
||||
archive_command = '/bin/true'
|
||||
max_wal_senders = {{ add .Values.postgresql.replicaCount 2 }}
|
||||
max_replication_slots = '10'
|
||||
hot_standby = 'on'
|
||||
logging_collector = 'on'
|
||||
log_directory = '/opt/bitnami/postgresql/logs'
|
||||
log_filename = 'postgresql.log'
|
||||
log_connections = 'false'
|
||||
log_disconnections = 'false'
|
||||
log_hostname = 'true'
|
||||
client_min_messages = 'error'
|
||||
pg_stat_statements.max = 10000
|
||||
pg_stat_statements.track = all
|
||||
include_dir = 'conf.d'
|
||||
pgaudit.log_catalog = 'off'
|
||||
|
||||
wal_buffers = -1
|
||||
max_wal_size = 10GB
|
||||
min_wal_size = 1GB
|
||||
|
||||
shared_buffers = {{ div $memory 4 }}MB
|
||||
|
||||
effective_cache_size = {{ mul (div $memory 4) 3 }}MB
|
||||
random_page_cost = 2.0
|
||||
|
||||
{{- if ge $memory 16384 }}
|
||||
maintenance_work_mem = 2GB
|
||||
work_mem = {{ div (subf $memory (div $memory 4) 2048) .Values.postgresql.maxConnections }}MB
|
||||
{{- else if ge $memory 8192 }}
|
||||
maintenance_work_mem = 1GB
|
||||
work_mem = {{ div (subf $memory (div $memory 4) 1024) .Values.postgresql.maxConnections }}MB
|
||||
{{- else }}
|
||||
maintenance_work_mem = 512MB
|
||||
work_mem = {{ div (subf $memory (div $memory 4) 512) .Values.postgresql.maxConnections }}MB
|
||||
{{- end }}
|
||||
|
||||
log_min_duration_statement = 3000
|
||||
|
||||
{{- $tzEnv := "" }}
|
||||
{{- range .Values.postgresql.extraEnvVars -}}
|
||||
{{- if eq "TZ" .name -}}
|
||||
{{- $tzEnv = .value -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- if $tzEnv }}
|
||||
timezone={{ $tzEnv }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
@@ -27,4 +27,18 @@ data:
|
||||
pg_hba.conf: |-
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.postgresql.pgHbaConfiguration "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: {{ printf "%s-configuration" (include "postgresql-ha.postgresql" .) }}
|
||||
namespace: {{ include "common.names.namespace" . | quote }}
|
||||
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||
app.kubernetes.io/component: postgresql
|
||||
{{- if .Values.commonAnnotations }}
|
||||
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
data:
|
||||
postgresql.conf: |-
|
||||
{{- include "postgresql-ha.configuration.postgresConf" . | nindent 4 }}
|
||||
{{- end }}
|
||||
|
||||
@@ -458,6 +458,10 @@ 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" . ) }}
|
||||
- name: dshm
|
||||
mountPath: /dev/shm
|
||||
{{- end }}
|
||||
{{- if .Values.metrics.enabled }}
|
||||
- name: metrics
|
||||
image: {{ include "postgresql-ha.metrics.image" . }}
|
||||
@@ -598,6 +602,12 @@ spec:
|
||||
- name: postgresql-certificates
|
||||
emptyDir: {}
|
||||
{{- end }}
|
||||
{{- if ( include "postgresql-ha.configuration.postgresql.sharedMemory" . ) }}
|
||||
- name: dshm
|
||||
emptyDir:
|
||||
medium: Memory
|
||||
sizeLimit: {{ include "postgresql-ha.configuration.postgresql.sharedMemory" . }}
|
||||
{{- end }}
|
||||
{{- if and .Values.persistence.enabled .Values.persistence.existingClaim }}
|
||||
- name: data
|
||||
persistentVolumeClaim:
|
||||
|
||||
Reference in New Issue
Block a user