# postgres-ha 버전 갱신 가이드 ## 1. git 작업 환경 구성 - 서비스 카탈로그 git 다운로드 ``` $ git clone https://github.com/paasup/service-catalog.git ``` - 작업 브랜치로 체크아웃 ``` $ git checkout -b update-postgresql-ha/11.9.4 ``` ## 2. helm chart 업데이트 ### 1) 차트 버전 변경 - 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" -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" -o -path "./templates/_configuration.tpl" \) -prune -o -exec rm -rf {} + ``` - bitnami/postgres-ha 차트 다운로드 ``` sh # charts 디렉토리로 이동 cd ~/service-catalog/charts # helm repo 추가 helm repo add bitnami https://charts.bitnami.com/bitnami helm repo update # helm 차트 helm pull bitnami/postgresql-ha --version="11.9.4" # 차트 변경 tar xzvf postgresql-ha*.tgz # 필요 없는 파일 삭제 rm postgresql-ha-*.tgz ``` ### 2) 차트 수정 사항 반영 - 다음은 Postgresql 설정을 추가하기 위하여 수정한 파일 목록 및 내용이다. #### ./template/postgresql/statefulset.yaml - 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.enabled" . ) }} - name: postgresql-config mountPath: /bitnami/repmgr/conf - name: dshm mountPath: /dev/shm {{- end }} ... voluems: ... ## line 600 아래 추가 {{- if ( include "postgresql-ha.configuration.postgresql.enabled" . ) }} - name: postgresql-config configMap: name: {{ include "postgresql-ha.postgresqlConfigurationCM" . }} - name: dshm emptyDir: medium: Memory sizeLimit: {{ include "postgresql-ha.configuration.postgresql.sharedMemory" . }} {{- end }} ``` #### ./template/postgresql/configmap.yaml - `postgresql.resources.limits.memory`에 따라 postgresql에 설정 변경 사항을 반영하기 위해 다음 내용을 추가한다. - `./template/postgresql/configmap.yaml`에 다음 내용을 추가한다. ``` yaml ## line 29 아래 추가 ... {{- 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 }} ... ``` ## 3. git push 및 tag 추가 - 갱신작업 진행후 commit ``` $ git add . $ git commit -m "update postgresql-ha/11.9.4-1" ``` - main 브랜치에 체크아웃 후 merge ``` $ git checkout main $ 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-1 ``` - git tag 추가 후 push ``` $ 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가 적용되지 않는 오류 수정를 수정하였다.