From ddef303dc800d64fc38a35a6e6d502a9357db1c5 Mon Sep 17 00:00:00 2001 From: Scott Hussey Date: Sat, 27 Jan 2018 10:33:48 -0600 Subject: [PATCH] Fix PostgreSQL dataloss on pod restart - Make data volume mount path configurable - Use volumeMount subPath to avoid 'lost+found' in PVC - Set PGDATA env to match data volume mount path Change-Id: I5988ae663d21dd09f6edece9e380a001b3a2d2df --- postgresql/templates/statefulset.yaml | 5 ++++- postgresql/values.yaml | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/postgresql/templates/statefulset.yaml b/postgresql/templates/statefulset.yaml index 1b3a65ad31..341be96e32 100644 --- a/postgresql/templates/statefulset.yaml +++ b/postgresql/templates/statefulset.yaml @@ -56,6 +56,8 @@ spec: secretKeyRef: name: {{ .Values.secrets.postgresql.admin }} key: 'POSTGRES_USER' + - name: 'PGDATA' + value: {{ .Values.storage.mount.path | quote }} livenessProbe: exec: command: @@ -71,7 +73,8 @@ spec: {{ tuple $envAll $envAll.Values.pod.resources.server | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }} volumeMounts: - name: postgresql-data - mountPath: /var/lib/postgresql + mountPath: {{ .Values.storage.mount.path }} + subPath: {{ .Values.storage.mount.subpath }} {{- if not .Values.storage.pvc.enabled }} volumes: - name: postgresql-data diff --git a/postgresql/values.yaml b/postgresql/values.yaml index 884df07e51..148ed54918 100644 --- a/postgresql/values.yaml +++ b/postgresql/values.yaml @@ -51,6 +51,9 @@ storage: class_path: volume.beta.kubernetes.io/storage-class host: host_path: /data/openstack-helm/postgresql + mount: + path: /var/lib/postgresql/data + subpath: pgdata labels: node_selector_key: openstack-control-plane