Skip to content

Commit

Permalink
adding archiving to postgres
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Apurvag011 committed Oct 8, 2020
1 parent 4665fda commit 85cbd6f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 7 deletions.
2 changes: 1 addition & 1 deletion postgresql/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 24 additions & 5 deletions postgresql/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}
Expand All @@ -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:
Expand All @@ -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 }}
9 changes: 8 additions & 1 deletion postgresql/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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'
Expand Down

0 comments on commit 85cbd6f

Please sign in to comment.