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
This commit is contained in:
Apurva Gokani 2020-09-17 14:38:14 -05:00
parent 4665fdad03
commit 85cbd6f04b
3 changed files with 33 additions and 7 deletions

View File

@ -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

View File

@ -204,17 +204,22 @@ spec:
mountPath: /tmp/readiness.sh
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 }}

View File

@ -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'