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
This commit is contained in:
Scott Hussey 2018-01-27 10:33:48 -06:00 committed by Pete Birley
parent e5168393ac
commit ddef303dc8
2 changed files with 7 additions and 1 deletions

View File

@ -56,6 +56,8 @@ spec:
secretKeyRef: secretKeyRef:
name: {{ .Values.secrets.postgresql.admin }} name: {{ .Values.secrets.postgresql.admin }}
key: 'POSTGRES_USER' key: 'POSTGRES_USER'
- name: 'PGDATA'
value: {{ .Values.storage.mount.path | quote }}
livenessProbe: livenessProbe:
exec: exec:
command: command:
@ -71,7 +73,8 @@ spec:
{{ tuple $envAll $envAll.Values.pod.resources.server | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }} {{ tuple $envAll $envAll.Values.pod.resources.server | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }}
volumeMounts: volumeMounts:
- name: postgresql-data - name: postgresql-data
mountPath: /var/lib/postgresql mountPath: {{ .Values.storage.mount.path }}
subPath: {{ .Values.storage.mount.subpath }}
{{- if not .Values.storage.pvc.enabled }} {{- if not .Values.storage.pvc.enabled }}
volumes: volumes:
- name: postgresql-data - name: postgresql-data

View File

@ -51,6 +51,9 @@ storage:
class_path: volume.beta.kubernetes.io/storage-class class_path: volume.beta.kubernetes.io/storage-class
host: host:
host_path: /data/openstack-helm/postgresql host_path: /data/openstack-helm/postgresql
mount:
path: /var/lib/postgresql/data
subpath: pgdata
labels: labels:
node_selector_key: openstack-control-plane node_selector_key: openstack-control-plane