From 5b636bb8ea9a947c68f4b335871337167eacd002 Mon Sep 17 00:00:00 2001 From: "Christian M. Adams" Date: Thu, 13 Jan 2022 23:17:33 -0500 Subject: [PATCH] Use an Init Container to move the pg data subPath in the pvc --- roles/installer/templates/deployment.yaml.j2 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/roles/installer/templates/deployment.yaml.j2 b/roles/installer/templates/deployment.yaml.j2 index c4933b5c4..fb3316194 100644 --- a/roles/installer/templates/deployment.yaml.j2 +++ b/roles/installer/templates/deployment.yaml.j2 @@ -35,6 +35,22 @@ spec: {% endif %} {% if bundle_ca_crt or projects_persistence|bool or init_container_extra_commands %} initContainers: + - name: database-check + image: '{{ _init_container_image }}' + imagePullPolicy: '{{ image_pull_policy }}' + command: + - /bin/sh + - -c + - | + [[ -d /check-db/pgsql/data ]] && rm -rf /check-db/data; mv /check-db/pgsql/data/ /check-db/data/ && rm -rf /check-db/pgsql + volumeMounts: + - name: check-db-pvc + mountPath: /check-db + subPath: '' + volumes: + - name: check-db-pvc + persistentVolumeClaim: + claimName: postgres-{{ ansible_operator_meta.name }}-postgres-0 - name: init image: '{{ _init_container_image }}' imagePullPolicy: '{{ image_pull_policy }}'