Skip to content

Commit

Permalink
Install pgbackrest and configure
Browse files Browse the repository at this point in the history
  • Loading branch information
conbrad committed Nov 15, 2023
1 parent 8ba8c94 commit b759d11
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
4 changes: 2 additions & 2 deletions openshift/patroni-postgis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The WPS pipeline currently assumes the existence of an appropriately tagged patr

```bash
# Build a patroni imagestream:
oc -n e1e498-tools process -f openshift/build.yaml | oc -n e1e498-tools apply -f -
oc -n e1e498-tools process -f openshift/build.yaml -p OBJECT_STORE_SERVER="server" -p OBJECT_STORE_BUCKET="bucket" -p OBJECT_STORE_USER_ID="uid" -p OBJECT_STORE_SECRET="sec" | oc -n e1e498-tools apply -f -
# Tag the old imagestream so we can keep it around if we need to revert:
oc -n e1e498-tools tag patroni-postgres:v12 patroni-postgres:v12-<date deprecated, e.g. 20200826>
# Tag the new imagestream (it won't be used until the pods get re-created):
Expand Down Expand Up @@ -69,4 +69,4 @@ SELECT postgis_extensions_upgrade();

This script cannot be run as part of the alembic scripts in the api project, the api uses a `wps` user that does not have the appropriate priveleges. Upgrading the image may this require manually running `SELECT postgis_extensions_upgrade();` on the target database once the new image has been applied.

The PostGIS version can be checked with `SELECT postgis_full_version();`
The PostGIS version can be checked with `SELECT postgis_full_version();`
1 change: 1 addition & 0 deletions openshift/patroni-postgis/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ RUN apt-get update \
&& apt-get install -y --no-install-recommends \
postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION \
postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts=$POSTGIS_VERSION \
pgbackrest \
&& rm -rf /var/lib/apt/lists/*

# Add the POSTGIS command to the end of the post_init script.
Expand Down
25 changes: 25 additions & 0 deletions openshift/patroni-postgis/docker/init_postgis
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,28 @@ if [[ (! -z "$APP_USER") && (! -z "$APP_PASSWORD") && (! -z "$APP_DATABASE")]];
echo "Loading PostGIS extensions into $APP_DATABASE"
psql "$1" -w -c "\c ${APP_DATABASE}" -c "CREATE EXTENSION IF NOT EXISTS postgis;"
fi

cat <<EOF | sudo tee /etc/pgbackrest.conf
[global]
repo1-type=s3
repo1-storage-verify-tls=n
repo1-s3-endpoint=${OBJECT_STORE_SERVER}
repo1-s3-uri-style=path
repo1-s3-bucket=${OBJECT_STORE_BUCKET}
repo1-s3-key=${OBJECT_STORE_USER_ID}
repo1-s3-key-secret=${OBJECT_STORE_SECRET}
repo1-s3-region=eu-west-3

repo1-path=/repo1
repo1-retention-full=3
start-fast=y
log-level-console=info
log-level-file=debug
delta=y
process-max=2

[demo-cluster-1]
pg1-path=/var/lib/postgresql/data
pg1-port=5432
pg1-user=postgres
EOF
14 changes: 13 additions & 1 deletion openshift/patroni-postgis/openshift/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ labels:
app.kubernetes.io/version: "12"
parameters:
- name: NAME
value: patroni-postgres
value: patroni-postgres-pgbackrest
- name: SUFFIX
- name: VERSION
description: Output version
Expand All @@ -23,6 +23,18 @@ parameters:
value: main
- name: POSTGRES_VERSION
value: "12"
- name: OBJECT_STORE_SERVER
description: Backup object store server
required: true
- name: OBJECT_STORE_BUCKET
description: Backup object store bucket
required: true
- name: OBJECT_STORE_USER_ID
description: Backup object store user id
required: true
- name: OBJECT_STORE_SECRET
description: Backup object store secret
required: true
objects:
- apiVersion: v1
kind: ImageStream
Expand Down

0 comments on commit b759d11

Please sign in to comment.