Skip to content

Commit 23bb2fa

Browse files
authored
Merge pull request #84 from mesoform/dev/pg-v14
dev/pg_v14
2 parents 4b35e7f + 3c01d50 commit 23bb2fa

3 files changed

Lines changed: 31 additions & 29 deletions

File tree

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
FROM golang:1.15-alpine AS builder
1+
FROM golang:1.18-alpine AS builder
22

3-
ENV WALG_VERSION=v0.2.19
3+
ENV WALG_VERSION=v1.1
44

55
ENV _build_deps="wget cmake git build-base bash"
66

@@ -15,7 +15,7 @@ RUN set -ex \
1515
&& install main/pg/wal-g / \
1616
&& /wal-g --help
1717

18-
FROM postgres:14.4-alpine3.16
18+
FROM postgres:14.6-alpine3.16
1919

2020
RUN apk add --update iputils htop curl busybox-suid jq \
2121
&& curl -sOL https://cronitor.io/dl/linux_amd64.tar.gz \

README.md

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Postgres database image setup for HA replication with control over backups and WAL archiving to GCS and backup restoration functionality.
55

66
## Semantic versioning
7-
The way in which versioning is done in this repository and for the image labels which it creates is a little different to standard versioning format. The normal major and minor versions that you would expect are still major and minor versions but they are tracking the major and minor versions of Postgres upstream. The second part of the version system also is broken into two parts, again major and minor versions. These represent major and minor versions of the additional features added by Mesoform. You can expect them to behave in the normal way of major and minor versions, in that major versions could include breaking changes. For example `13.1-1.1` represents Postgres version 13.1 with Mesoform features version 1.1
7+
The way in which versioning is done in this repository and for the image labels which it creates is a little different to standard versioning format. The normal major and minor versions that you would expect are still major and minor versions but they are tracking the major and minor versions of Postgres upstream. The second part of the version system also is broken into two parts, again major and minor versions. These represent major and minor versions of the additional features added by Mesoform. You can expect them to behave in the normal way of major and minor versions, in that major versions could include breaking changes. For example `14.4-3.0` represents Postgres version 14.4 with Mesoform features version 3.0
88

99
## How to use
1010
Variables usage:
@@ -72,7 +72,7 @@ secrets:
7272
7373
services:
7474
pg_master:
75-
image: mesoform/postgres-ha:13-latest
75+
image: mesoform/postgres-ha:14-latest
7676
volumes:
7777
- pg_data:/var/lib/postgresql/data
7878
environment:
@@ -125,7 +125,7 @@ services:
125125
retries: 3
126126
start_period: 60s
127127
pg_replica:
128-
image: mesoform/postgres-ha:13-latest
128+
image: mesoform/postgres-ha:14-latest
129129
volumes:
130130
- pg_replica:/var/lib/postgresql/data
131131
environment:
@@ -173,9 +173,11 @@ volumes:
173173
Run with:
174174

175175
```shell script
176-
docker stack deploy -c docker-compose-example.yml test_pg13ha
176+
docker stack deploy -c docker-compose-example.yml test_pg14ha
177177
```
178178

179+
Remember that docker secrets and storage bucket need to exist beforehand.
180+
179181
Note: Healthchecks can be added as in the example to avoid processes like backup restoration or database replication from being terminated too early before they complete
180182

181183
## How to restore from a backup
@@ -210,7 +212,7 @@ secrets:
210212
211213
services:
212214
pg_master:
213-
image: mesoform/postgres-ha:13-latest
215+
image: mesoform/postgres-ha:14-latest
214216
volumes:
215217
- pg_data:/var/lib/postgresql/data
216218
environment:
@@ -257,7 +259,7 @@ services:
257259
retries: 3
258260
start_period: 60s
259261
pg_replica:
260-
image: mesoform/postgres-ha:13-latest
262+
image: mesoform/postgres-ha:14-latest
261263
volumes:
262264
- pg_replica:/var/lib/postgresql/data
263265
environment:
@@ -306,7 +308,7 @@ volumes:
306308
Run with:
307309

308310
```shell script
309-
docker stack deploy -c docker-compose-restore.yml restore_pg13
311+
docker stack deploy -c docker-compose-restore.yml restore_pg14
310312
```
311313
Master database container logs:
312314
```
@@ -344,15 +346,15 @@ Stop the database to be upgraded and take a consistent copy of the data volume w
344346
root@testapp:~# docker exec -it ab1cdef23g4h pg_dumpall -U testuser > /backups/dump-testapp_db_data.sql
345347
```
346348

347-
2) Deploy a new PostgreSQL v13 database (with the same database name and username) on an empty volume which will be used to import the data dump taken on the database to be upgraded:
349+
2) Deploy a new PostgreSQL v14 database (with the same database name and username) on an empty volume which will be used to import the data dump taken on the database to be upgraded:
348350

349351
```
350-
root@testapp:~/testapp$ cat docker-compose.pg13.yml
352+
root@testapp:~/testapp$ cat docker-compose.pg14.yml
351353
version: "3.7"
352354
353355
volumes:
354-
pg13_data:
355-
name: zones/volumes/pg13_data
356+
pg14_data:
357+
name: zones/volumes/pg14_data
356358
driver: zfs
357359
secrets:
358360
db_password:
@@ -363,18 +365,18 @@ networks:
363365
database: {}
364366
365367
services:
366-
pg13:
367-
image: mesoform/postgres-ha:13-latest
368+
pg14:
369+
image: mesoform/postgres-ha:14-latest
368370
volumes:
369-
- pg13_data:/var/lib/postgresql/data
371+
- pg14_data:/var/lib/postgresql/data
370372
environment:
371373
- POSTGRES_DB=testdb
372374
- POSTGRES_USER=testuser
373375
- PGPORT: 5432
374376
- POSTGRES_PASSWORD_FILE=/run/secrets/db_password
375377
- HBA_ADDRESS=10.0.0.0/8
376378
- BACKUPS=true
377-
- STORAGE_BUCKET=gs://backups/postgres/testdb
379+
- STORAGE_BUCKET=gs://postgresql/backups/testdb
378380
- GCP_CREDENTIALS=/run/secrets/gcp_credentials
379381
secrets:
380382
- source: db_password
@@ -385,7 +387,7 @@ services:
385387
- node.labels.storage == primary
386388
```
387389
```
388-
root@testapp:~# docker stack deploy -c docker-compose.pg13.yml pg13db
390+
root@testapp:~# docker stack deploy -c docker-compose.pg14.yml pg14db
389391
```
390392

391393
3) Import the data dump taken on the first step to the new database:
@@ -420,13 +422,13 @@ root@testapp:~# docker stack rm testapp
420422
root@testapp:~# rm -rf /volumes/testapp_db_data
421423
```
422424

423-
6) Move upgraded data volume from the PostgreSQL v13 database to the old database data volume:
425+
6) Move upgraded data volume from the PostgreSQL v14 database to the old database data volume:
424426

425427
```
426-
root@testapp:~# mv -v /volumes/testapp_db13_data /volumes/testapp_db_data/
428+
root@testapp:~# mv -v /volumes/testapp_db14_data /volumes/testapp_db_data/
427429
```
428430

429-
7) Edit the original `docker-compose` file to update the database postgres image to v13 and gcp parameters to backup to cloud storage:
431+
7) Edit the original `docker-compose` file to update the database postgres image to v14 and gcp parameters to backup to cloud storage:
430432

431433
```
432434
root@testapp:~/testapp$ cat docker-compose.yml
@@ -469,7 +471,7 @@ services:
469471
constraints:
470472
- node.labels.storage == primary
471473
db:
472-
image: mesoform/postgres-ha:13-latest
474+
image: mesoform/postgres-ha:14-latest
473475
volumes:
474476
- db_data:/var/lib/postgresql/data
475477
environment:
@@ -482,7 +484,7 @@ services:
482484
- PG_REP_PASSWORD_FILE=/run/secrets/testapp_db_replica_password
483485
- HBA_ADDRESS=10.0.0.0/8
484486
- BACKUPS=true
485-
- STORAGE_BUCKET=gs://backups/postgres/testapp
487+
- STORAGE_BUCKET=gs://postgresql/backups/testapp
486488
- GCP_CREDENTIALS=/run/secrets/gcp_credentials
487489
secrets:
488490
- testapp_db_password
@@ -493,7 +495,7 @@ services:
493495
constraints:
494496
- node.labels.storage == primary
495497
db_replica:
496-
image: mesoform/postgres-ha:13-latest
498+
image: mesoform/postgres-ha:14-latest
497499
volumes:
498500
- db_replica_data:/var/lib/postgresql/data
499501
environment:
@@ -523,8 +525,8 @@ docker stack deploy -c docker-compose.yml testapp
523525
```
524526
root@testapp:~$ sudo docker stack ps testapp
525527
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
526-
wklerj2344jd testapp_db_replica.1 mesoform/postgres-ha:13-latest secondary Running Running 2 minutes ago
527-
lclkerk34kl3 testapp_db.1 mesoform/postgres-ha:13-latest primary Running Running 2 minutes ago
528+
wklerj2344jd testapp_db_replica.1 mesoform/postgres-ha:14-latest secondary Running Running 2 minutes ago
529+
lclkerk34kl3 testapp_db.1 mesoform/postgres-ha:14-latest primary Running Running 2 minutes ago
528530
mfdk34jll34k testapp_app.1 testapp/testapp-prod:1.0.0 primary Running Running 2 minutes ago
529531
```
530532

docker-compose-example.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ secrets:
1111

1212
services:
1313
pg_master:
14-
image: mesoform/postgres-ha:13-latest
14+
image: mesoform/postgres-ha:14-latest
1515
volumes:
1616
- pg_data:/var/lib/postgresql/data
1717
environment:
@@ -57,7 +57,7 @@ services:
5757
constraints:
5858
- node.labels.type == primary
5959
pg_replica:
60-
image: mesoform/postgres-ha:13-latest
60+
image: mesoform/postgres-ha:14-latest
6161
volumes:
6262
- pg_replica:/var/lib/postgresql/data
6363
environment:

0 commit comments

Comments
 (0)