From 6c9f82eb692bc0269c6e6f3c533537c8abd35e09 Mon Sep 17 00:00:00 2001 From: wbsong111 Date: Mon, 6 Jan 2025 11:02:33 +0900 Subject: [PATCH] Update BUILD-README.md --- charts/postgresql-ha/BUILD-README.md | 141 ++++++--------------------- 1 file changed, 32 insertions(+), 109 deletions(-) diff --git a/charts/postgresql-ha/BUILD-README.md b/charts/postgresql-ha/BUILD-README.md index d85114e..c4ac684 100644 --- a/charts/postgresql-ha/BUILD-README.md +++ b/charts/postgresql-ha/BUILD-README.md @@ -16,16 +16,16 @@ $ git checkout -b update-postgresql-ha/11.9.4 ### 1) 차트 버전 변경 -- README-build.md, custom-values.yaml을 제외한 파일 삭제 +- BUILD-README.md, CUSTOM-README.md, custom-values.yaml, templates/_configuration.tpl을 제외한 파일 삭제 ``` sh # chart 디렉토리로 이동 cd ~/service-catalog/charts/postgresql-ha # 파일 삭제 전 삭제할 파일 목록 확인 - find . -mindepth 1 \( -name "CUSTOM-README.md" -o -name "BUILD-README.md" -o -name "custom-values.yaml" \) -prune -o -print + find . -mindepth 1 \( -name "CUSTOM-README.md" -o -name "BUILD-README.md" -o -name "custom-values.yaml" -o -path "./templates/_configuration.tpl" \) -prune -o -print # 파일 삭제 - find . -mindepth 1 \(-name "CUSTOM-README.md" -o -name "BUILD-README.md" -o -name "custom-values.yaml" \) -prune -o -exec rm -rf {} + + find . -mindepth 1 \(-name "CUSTOM-README.md" -o -name "BUILD-README.md" -o -name "custom-values.yaml" -o -path "./templates/_configuration.tpl" \) -prune -o -exec rm -rf {} + ``` @@ -52,114 +52,25 @@ $ git checkout -b update-postgresql-ha/11.9.4 - 다음은 Postgresql 설정을 추가하기 위하여 수정한 파일 목록 및 내용이다. - -#### ./template/_configuration.tpl - -- `./template/_configuration.tpl`을 추가 작성한다. -- 파일 내용은 다음과 같다. - -``` yaml -{{/* -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 -}} -``` - - #### ./template/postgresql/statefulset.yaml -- `postgresql.resources.limits.memory`에 따라 shared memory 설정을 적용하기 위한 변경 사항이다. +- postgresql의 설정을 적용하기 위한 변경 사항이다. - `./template/postgresql/statefulset.yaml`에 다음 내용을 추가한다. ``` yaml + ## line 125 아래 추가 + command: + ... + {{- if ( include "postgresql-ha.configuration.postgresql.enabled" . ) }} + chmod -R 777 /dev/shm + {{- end }} + volumeMount: ... ## line 460 아래 추가 - {{- 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 }} @@ -167,7 +78,10 @@ timezone={{ $tzEnv }} voluems: ... ## line 600 아래 추가 - {{- 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 @@ -206,23 +120,32 @@ data: - 갱신작업 진행후 commit ``` $ git add . -$ git commit -m "update postgresql-ha/11.9.4" +$ git commit -m "update postgresql-ha/11.9.4-1" ``` - main 브랜치에 체크아웃 후 merge ``` $ git checkout main -$ git merge update-postgresql-ha/11.9.4 +$ git merge update-postgresql-ha/11.9.4-1 ``` - git에 push 후 작업 브랜치 삭제 ``` $ git push -u origin main -$ git branch -d update-postgresql-ha/11.9.4 +$ git branch -d update-postgresql-ha/11.9.4-1 ``` - git tag 추가 후 push ``` -$ git tag postgresql-ha/11.9.4 -$ git push origin postgresql-ha/11.9.4 +$ git tag postgresql-ha/11.9.4-1 +$ git push origin postgresql-ha/11.9.4-1 ``` + +## 4. 차트 버전 정보 + +- postgresql-ha/11.9.4 + - 서비스 배포를 위하여 custom-values.yam에 정의하였다. + - 차트의 빌드 방법과 배포 방법을 BUILD-README.md, CUSTOM-README.md 문서에 작성하였다. + - values.yaml의 설정에 따라 postgresql.conf를 생성하여 postgresql에 적용하도록 차트를 수정하였다. +- postgresql-ha/11.9.4-1 + - values.yaml의 설정에 따라 생성한 postgresql.conf가 적용되지 않는 오류 수정를 수정하였다.