commit 85cbd6f04b4429f245a19156fce7639321f3ec61 Author: Apurva Gokani Date: Thu Sep 17 14:38:14 2020 -0500 adding archiving to postgres To safeguard postgres from clogging up wal files in pg_xlog directory, This change does the following: 1) adding postgres archiving to move the WAL file to different directory 2) Makes sure that archive is in different Persistent volume. Change-Id: I59bc76f27384d4f3836ef609855afcc33a7b99d0 diff --git a/postgresql/Chart.yaml b/postgresql/Chart.yaml index c695d01..7771f74 100644 --- a/postgresql/Chart.yaml +++ b/postgresql/Chart.yaml @@ -15,7 +15,7 @@ apiVersion: v1 appVersion: v9.6 description: OpenStack-Helm PostgreSQL name: postgresql -version: 0.1.1 +version: 0.1.2 home: https://www.postgresql.org sources: - https://github.com/postgres/postgres diff --git a/postgresql/templates/statefulset.yaml b/postgresql/templates/statefulset.yaml index 7456a88..17f75d9 100644 --- a/postgresql/templates/statefulset.yaml +++ b/postgresql/templates/statefulset.yaml @@ -205,16 +205,21 @@ spec: subPath: readiness.sh readOnly: true - name: postgresql-etc - mountPath: /tmp/postgresql.conf - subPath: postgresql.conf - readOnly: true - - name: postgresql-etc mountPath: /tmp/pg_hba.conf subPath: pg_hba.conf readOnly: true + - name: postgresql-etc + mountPath: /tmp/postgresql.conf + subPath: postgresql.conf + readOnly: true - name: postgresql-data mountPath: {{ .Values.storage.mount.path }} subPath: {{ .Values.storage.mount.subpath }} +{{- if eq .Values.conf.postgresql.archive_mode "on" }} + - name: postgresql-archive + mountPath: {{ .Values.storage.archive.mount_path }} + subPath: {{ .Values.storage.mount.subpath }} +{{- end }} volumes: - name: pod-tmp emptyDir: {} @@ -235,8 +240,10 @@ spec: - name: postgresql-data hostPath: path: {{ .Values.storage.host.host_path }} -{{- else }} +{{- end }} +{{- if or (eq .Values.conf.postgresql.archive_mode "on" ) (eq .Values.storage.pvc.enabled true) }} volumeClaimTemplates: +{{- if .Values.storage.pvc.enabled }} - metadata: name: postgresql-data annotations: @@ -247,4 +254,16 @@ spec: requests: storage: {{ .Values.storage.pvc.size }} {{- end }} +{{- if eq .Values.conf.postgresql.archive_mode "on" }} + - metadata: + name: postgresql-archive + annotations: + {{ .Values.storage.archive_pvc.class_path }}: {{ .Values.storage.archive_pvc.class_name }} + spec: + accessModes: ["ReadWriteOnce"] + resources: + requests: + storage: {{ .Values.storage.archive_pvc.size }} +{{- end }} +{{- end }} {{- end }} diff --git a/postgresql/values.yaml b/postgresql/values.yaml index 0cd221b..adce955 100644 --- a/postgresql/values.yaml +++ b/postgresql/values.yaml @@ -164,11 +164,17 @@ storage: size: 5Gi class_name: general class_path: volume.beta.kubernetes.io/storage-class + archive_pvc: + size: 5Gi + class_name: general + class_path: volume.beta.kubernetes.io/storage-class host: host_path: /data/openstack-helm/postgresql mount: path: /var/lib/postgresql subpath: . + archive: + mount_path: /var/lib/archive labels: server: @@ -263,7 +269,8 @@ conf: host all all 0.0.0.0/0 reject postgresql: - archive_mode: 'off' + archive_mode: 'on' + archive_command: 'test ! -f /var/lib/archive/%f && gzip < %p > /var/lib/archive/%f' cluster_name: 'postgresql' datestyle: 'iso, mdy' external_pid_file: '/tmp/postgres.pid'