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 appVersion: v9.6
description: OpenStack-Helm PostgreSQL description: OpenStack-Helm PostgreSQL
name: postgresql name: postgresql
version: 0.1.1 version: 0.1.2
home: https://www.postgresql.org home: https://www.postgresql.org
sources: sources:
- https://github.com/postgres/postgres - https://github.com/postgres/postgres

View File

@ -204,17 +204,22 @@ spec:
mountPath: /tmp/readiness.sh mountPath: /tmp/readiness.sh
subPath: readiness.sh subPath: readiness.sh
readOnly: true readOnly: true
- name: postgresql-etc
mountPath: /tmp/postgresql.conf
subPath: postgresql.conf
readOnly: true
- name: postgresql-etc - name: postgresql-etc
mountPath: /tmp/pg_hba.conf mountPath: /tmp/pg_hba.conf
subPath: pg_hba.conf subPath: pg_hba.conf
readOnly: true readOnly: true
- name: postgresql-etc
mountPath: /tmp/postgresql.conf
subPath: postgresql.conf
readOnly: true
- name: postgresql-data - name: postgresql-data
mountPath: {{ .Values.storage.mount.path }} mountPath: {{ .Values.storage.mount.path }}
subPath: {{ .Values.storage.mount.subpath }} 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: volumes:
- name: pod-tmp - name: pod-tmp
emptyDir: {} emptyDir: {}
@ -235,8 +240,10 @@ spec:
- name: postgresql-data - name: postgresql-data
hostPath: hostPath:
path: {{ .Values.storage.host.host_path }} path: {{ .Values.storage.host.host_path }}
{{- else }} {{- end }}
{{- if or (eq .Values.conf.postgresql.archive_mode "on" ) (eq .Values.storage.pvc.enabled true) }}
volumeClaimTemplates: volumeClaimTemplates:
{{- if .Values.storage.pvc.enabled }}
- metadata: - metadata:
name: postgresql-data name: postgresql-data
annotations: annotations:
@ -247,4 +254,16 @@ spec:
requests: requests:
storage: {{ .Values.storage.pvc.size }} storage: {{ .Values.storage.pvc.size }}
{{- end }} {{- 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 }} {{- end }}

View File

@ -164,11 +164,17 @@ storage:
size: 5Gi size: 5Gi
class_name: general class_name: general
class_path: volume.beta.kubernetes.io/storage-class 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:
host_path: /data/openstack-helm/postgresql host_path: /data/openstack-helm/postgresql
mount: mount:
path: /var/lib/postgresql path: /var/lib/postgresql
subpath: . subpath: .
archive:
mount_path: /var/lib/archive
labels: labels:
server: server:
@ -263,7 +269,8 @@ conf:
host all all 0.0.0.0/0 reject host all all 0.0.0.0/0 reject
postgresql: postgresql:
archive_mode: 'off' archive_mode: 'on'
archive_command: 'test ! -f /var/lib/archive/%f && gzip < %p > /var/lib/archive/%f'
cluster_name: 'postgresql' cluster_name: 'postgresql'
datestyle: 'iso, mdy' datestyle: 'iso, mdy'
external_pid_file: '/tmp/postgres.pid' external_pid_file: '/tmp/postgres.pid'