From 1ed3d2657e897aa4a3924ffe21b95437773af2c0 Mon Sep 17 00:00:00 2001 From: Bruno Sakoto Date: Fri, 5 Mar 2021 18:11:00 -0500 Subject: [COMMON] Fix postgres data persistence This changes fixes postgres data lost that occurs when postgres pods are restarting. When crunchy data postgres image starts, it runs /opt/cpm/bin/setenv.sh script to set PGDATA folder. This script contains: -- export PGDATA=/pgdata/$HOSTNAME if [[ -v PGDATA_PATH_OVERRIDE ]]; then export PGDATA=/pgdata/$PGDATA_PATH_OVERRIDE fi -- Since postgres is now a deployment (commit 0b243b600), its pod name is different on each startup, hence HOSTNAME and PGDATA are also different each time. This change is leveraging crunchy data PGDATA_PATH_OVERRIDE environment variable to set PGDATA to a fixed path. By default, this path is set to /pgdata/data. Issue-ID: CPS-271 Change-Id: Icc0f05d64230a98bc21d8f2a74c12c6661e05482 Signed-off-by: Bruno Sakoto --- kubernetes/common/postgres/templates/_deployment.tpl | 3 +++ kubernetes/common/postgres/values.yaml | 2 ++ 2 files changed, 5 insertions(+) diff --git a/kubernetes/common/postgres/templates/_deployment.tpl b/kubernetes/common/postgres/templates/_deployment.tpl index 6142baa63f..38a7ce1f63 100644 --- a/kubernetes/common/postgres/templates/_deployment.tpl +++ b/kubernetes/common/postgres/templates/_deployment.tpl @@ -1,6 +1,7 @@ {{/* # Copyright © 2018 Amdocs, AT&T, Bell Canada # Copyright © 2020 Samsung Electronics +# Modifications Copyright (C) 2021 Bell Canada. # # # # Licensed under the Apache License, Version 2.0 (the "License"); # # you may not use this file except in compliance with the License. @@ -134,6 +135,8 @@ spec: value: "{{ $dot.Values.config.pgDatabase }}" - name: PG_ROOT_PASSWORD {{- include "common.secret.envFromSecretFast" (dict "global" $dot "uid" (include "common.postgres.secret.rootPassUID" .) "key" "password") | indent 10 }} + - name: PGDATA_PATH_OVERRIDE + value: "{{ $dot.Values.config.pgDataPath }}" volumeMounts: - name: config mountPath: /pgconf/pool_hba.conf diff --git a/kubernetes/common/postgres/values.yaml b/kubernetes/common/postgres/values.yaml index 07bb5c4eac..93f6d66385 100644 --- a/kubernetes/common/postgres/values.yaml +++ b/kubernetes/common/postgres/values.yaml @@ -1,4 +1,5 @@ # Copyright © 2018 Amdocs, AT&T, Bell Canada +# Modifications Copyright (C) 2021 Bell Canada. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -50,6 +51,7 @@ pullPolicy: Always config: pgUserName: testuser pgDatabase: userdb + pgDataPath: data # pgPrimaryPassword: password # pgUserPassword: password # pgRootPassword: password -- cgit 1.2.3-korg