Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task/patroni pgbackrest #3239

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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" -p GIT_REF="<branch>" | 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();`
15 changes: 13 additions & 2 deletions openshift/patroni-postgis/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@
# For details, see: https://github.com/bcgov/patroni-postgres-container/
FROM image-registry.openshift-image-registry.svc:5000/bcgov/patroni-postgres:12.4-latest

# The below must be supplied for a build
ARG OBJECT_STORE_SERVER=server
ARG OBJECT_STORE_BUCKET=bucket
ARG OBJECT_STORE_USER_ID=uid
ARG OBJECT_STORE_SECRET=sec

ENV POSTGIS_MAJOR 3
ENV POSTGIS_VERSION 3.3.1+dfsg-1.pgdg100+1
ENV POSTGIS_VERSION 3.3.4+dfsg-1.pgdg100+1

# Switch to root user for package installs
USER 0
Expand All @@ -12,8 +18,13 @@ USER 0
RUN apt-get update \
&& apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \
&& apt-get install -y --no-install-recommends \
# ca-certificates: for accessing remote raster files;
# fix: https://github.com/postgis/docker-postgis/issues/307
ca-certificates \
\
postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION \
postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts=$POSTGIS_VERSION \
postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \
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
23 changes: 22 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 Expand Up @@ -55,6 +67,15 @@ objects:
type: Git
strategy:
dockerStrategy:
buildArgs:
- name: "OBJECT_STORE_SERVER"
value: "${OBJECT_STORE_SERVER}"
- name: "OBJECT_STORE_BUCKET"
value: "${OBJECT_STORE_BUCKET}"
- name: "OBJECT_STORE_USER_ID"
value: "${OBJECT_STORE_USER_ID}"
- name: "OBJECT_STORE_SECRET"
value: "${OBJECT_STORE_SECRET}"
type: Docker
triggers:
- type: ConfigChange
Expand Down
4 changes: 2 additions & 2 deletions openshift/templates/patroni.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -287,12 +287,12 @@ parameters:
- name: IMAGE_NAME
description: |
The Patroni image stream name
value: patroni-postgres
value: patroni-postgres-pgbackrest
- name: IMAGE_TAG
description: |
The image tag used to specify which image you would like deployed.
Don't use `latest`.
value: "v12-2022-09-12"
value: "v12-latest"
- name: PVC_SIZE
description: The size of the persistent volume to create.
displayName: Persistent Volume Size
Expand Down
Loading