Skip to content

Commit 136d22e

Browse files
authored
Merge pull request #2035 from EnterpriseDB/release/2021-11-11
Release: 2021-11-11
2 parents 8fd9b1f + b8fbce1 commit 136d22e

29 files changed

+1491
-173
lines changed

advocacy_docs/kubernetes/cloud_native_postgresql/api_reference.mdx

Lines changed: 233 additions & 45 deletions
Large diffs are not rendered by default.

advocacy_docs/kubernetes/cloud_native_postgresql/architecture.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ Kubernetes cluster, with the following specifications:
3535
information about how Cloud Native PostgreSQL relies on PostgreSQL replication,
3636
including synchronous settings.
3737

38+
!!! Seealso "Connection Pooling"
39+
Please refer to the ["Connection Pooling" section](connection_pooling.md) for
40+
information about how to take advantage of PgBouncer as a connection pooler,
41+
and create an access layer between your applications and the PostgreSQL clusters.
42+
3843
## Read-write workloads
3944

4045
Applications can decide to connect to the PostgreSQL instance elected as

advocacy_docs/kubernetes/cloud_native_postgresql/backup_recovery.mdx

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ product: 'Cloud Native Operator'
77
The operator can orchestrate a continuous backup infrastructure
88
that is based on the [Barman](https://pgbarman.org) tool. Instead
99
of using the classical architecture with a Barman server, which
10-
backup many PostgreSQL instances, the operator will use the
11-
`barman-cloud-wal-archive` and `barman-cloud-backup` tools.
10+
backs up many PostgreSQL instances, the operator relies on the
11+
`barman-cloud-wal-archive`, `barman-cloud-backup`, `barman-cloud-backup-list`,
12+
and `barman-cloud-backup-delete` tools.
1213
As a result, base backups will be *tarballs*. Both base backups and WAL files
1314
can be compressed and encrypted.
1415

@@ -17,17 +18,16 @@ You can use the image `quay.io/enterprisedb/postgresql` for this scope,
1718
as it is composed of a community PostgreSQL image and the latest
1819
`barman-cli-cloud` package.
1920

21+
!!! Important
22+
Always ensure that you are running the latest version of the operands
23+
in your system to take advantage of the improvements introduced in
24+
Barman cloud (as well as improve the security aspects of your cluster).
25+
2026
A backup is performed from a primary or a designated primary instance in a
2127
`Cluster` (please refer to
2228
[replica clusters](replication.md#replication-from-an-external-postgresql-cluster)
2329
for more information about designated primary instances).
2430

25-
!!! Warning
26-
Cloud Native PostgreSQL does not currently manage the deletion of backup files
27-
from the backup object store. The retention policy feature will be merged from
28-
Barman to Barman Cloud in the future. For the time being, it is your responsibility
29-
to configure retention policies directly on the object store.
30-
3131
## Cloud provider support
3232

3333
You can archive the backup files in any service that is supported
@@ -464,6 +464,7 @@ will use it unless you override it in the cluster configuration.
464464

465465
## Recovery
466466

467+
Cluster restores are not performed "in-place" on an existing cluster.
467468
You can use the data uploaded to the object storage to bootstrap a
468469
new cluster from a backup. The operator will orchestrate the recovery
469470
process using the `barman-cloud-restore` tool.
@@ -540,4 +541,43 @@ manager running in the Pods.
540541
You can optionally specify a `recoveryTarget` to perform a point in time
541542
recovery. If left unspecified, the recovery will continue up to the latest
542543
available WAL on the default target timeline (`current` for PostgreSQL up to
543-
11, `latest` for version 12 and above).
544+
11, `latest` for version 12 and above).
545+
546+
## Retention policies
547+
548+
Cloud Native PostgreSQL can manage the automated deletion of backup files from the backup object store, using **retention policies** based on recovery window.
549+
550+
Internally, the retention policy feature uses `barman-cloud-backup-delete`
551+
with `--retention-policy “RECOVERY WINDOW OF {{ retention policy value }} {{ retention policy unit }}”`.
552+
553+
For example, you can define your backups with a retention policy of 30 days as
554+
follows:
555+
556+
```yaml
557+
apiVersion: postgresql.k8s.enterprisedb.io/v1
558+
kind: Cluster
559+
[...]
560+
spec:
561+
backup:
562+
barmanObjectStore:
563+
destinationPath: "<destination path here>"
564+
s3Credentials:
565+
accessKeyId:
566+
name: aws-creds
567+
key: ACCESS_KEY_ID
568+
secretAccessKey:
569+
name: aws-creds
570+
key: ACCESS_SECRET_KEY
571+
retentionPolicy: "30d"
572+
```
573+
574+
!!! Note "There's more ..."
575+
The **recovery window retention policy** is focused on the concept of
576+
*Point of Recoverability* (`PoR`), a moving point in time determined by
577+
`current time - recovery window`. The *first valid backup* is the first
578+
available backup before `PoR` (in reverse chronological order).
579+
Cloud Native PostgreSQL must ensure that we can recover the cluster at
580+
any point in time between `PoR` and the latest successfully archived WAL
581+
file, starting from the first valid backup. Base backups that are older
582+
than the first valid backup will be marked as *obsolete* and permanently
583+
removed after the next backup is completed.

advocacy_docs/kubernetes/cloud_native_postgresql/bootstrap.mdx

Lines changed: 58 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,44 @@ relies on the superuser to reconcile the cluster with the desired status.
183183
to the cluster.
184184

185185
The actual PostgreSQL data directory is created via an invocation of the
186-
`initdb` PostgreSQL command. If you need to add custom options to that
187-
command (i.e., to change the locale used for the template databases or to
188-
add data checksums), you can add them to the `options` section like in
189-
the following example:
186+
`initdb` PostgreSQL command. If you need to add custom options to that command
187+
(i.e., to change the `locale` used for the template databases or to add data
188+
checksums), you can use the following parameters:
189+
190+
dataChecksums
191+
: When `dataChecksums` is set to `true`, CNP invokes the `-k` option in
192+
`initdb` to enable checksums on data pages and help detect corruption by the
193+
I/O system - that would otherwise be silent (default: `false`).
194+
195+
encoding
196+
: When `encoding` set to a value, CNP passes it to the `--encoding` option in `initdb`,
197+
which selects the encoding of the template database (default: `UTF8`).
198+
199+
localeCollate
200+
: When `localeCollate` is set to a value, CNP passes it to the `--lc-collate`
201+
option in `initdb`. This option controls the collation order (`LC_COLLATE`
202+
subcategory), as defined in ["Locale Support"](https://www.postgresql.org/docs/current/locale.html)
203+
from the PostgreSQL documentation (default: `C`).
204+
205+
localeCType
206+
: When `localeCType` is set to a value, CNP passes it to the `--lc-ctype` option in
207+
`initdb`. This option controls the collation order (`LC_CTYPE` subcategory), as
208+
defined in ["Locale Support"](https://www.postgresql.org/docs/current/locale.html)
209+
from the PostgreSQL documentation (default: `C`).
210+
211+
walSegmentSize
212+
: When `walSegmentSize` is set to a value, CNP passes it to the `--wal-segsize`
213+
option in `initdb` (default: not set - defined by PostgreSQL as 16 megabytes).
214+
215+
!!! Note
216+
The only two locale options that Cloud Native PostgreSQL implements during
217+
the `initdb` bootstrap refer to the `LC_COLLATE` and `LC_TYPE` subcategories.
218+
The remaining locale subcategories can be configured directly in the PostgreSQL
219+
configuration, using the `lc_messages`, `lc_monetary`, `lc_numeric`, and
220+
`lc_time` parameters.
221+
222+
The following example enables data checksums and sets the default encoding to
223+
`LATIN1`:
190224

191225
```yaml
192226
apiVersion: postgresql.k8s.enterprisedb.io/v1
@@ -200,14 +234,19 @@ spec:
200234
initdb:
201235
database: app
202236
owner: app
203-
options:
204-
- "-k"
205-
- "--locale=en_US"
237+
dataChecksums: true
238+
encoding: 'LATIN1'
206239
storage:
207240
size: 1Gi
208241
```
209242

210-
The user can also specify a custom list of queries that will be executed
243+
Cloud Native PostgreSQL supports another way to customize the behaviour of the
244+
`initdb` invocation, using the `options` subsection. However, given that there
245+
are options that can break the behaviour of the operator (such as `--auth` or
246+
`-d`), this technique is deprecated and will be removed from future versions of
247+
the API.
248+
249+
You can also specify a custom list of queries that will be executed
211250
once, just after the database is created and configured. These queries will
212251
be executed as the *superuser* (`postgres`), connected to the `postgres`
213252
database:
@@ -224,9 +263,9 @@ spec:
224263
initdb:
225264
database: app
226265
owner: app
227-
options:
228-
- "-k"
229-
- "--locale=en_US"
266+
dataChecksums: true
267+
localeCollate: 'en_US'
268+
localeCType: 'en_US'
230269
postInitSQL:
231270
- CREATE ROLE angus
232271
- CREATE ROLE malcolm
@@ -235,8 +274,9 @@ spec:
235274
```
236275

237276
!!! Warning
238-
Please use the `postInitSQL` option with extreme care as queries
239-
are run as a superuser and can disrupt the entire cluster.
277+
Please use the `postInitSQL` and `postInitTemplateSQL` options with extreme care,
278+
as queries are run as a superuser and can disrupt the entire cluster.
279+
An error in any of those queries interrupts the bootstrap phase, leaving the cluster incomplete.
240280

241281
### Compatibility Features
242282

@@ -618,7 +658,7 @@ file on the source PostgreSQL instance:
618658
host replication streaming_replica all md5
619659
```
620660

621-
The following manifest creates a new PostgreSQL 14.0 cluster,
661+
The following manifest creates a new PostgreSQL 14.1 cluster,
622662
called `target-db`, using the `pg_basebackup` bootstrap method
623663
to clone an external PostgreSQL cluster defined as `source-db`
624664
(in the `externalClusters` array). As you can see, the `source-db`
@@ -633,7 +673,7 @@ metadata:
633673
name: target-db
634674
spec:
635675
instances: 3
636-
imageName: quay.io/enterprisedb/postgresql:14.0
676+
imageName: quay.io/enterprisedb/postgresql:14.1
637677
638678
bootstrap:
639679
pg_basebackup:
@@ -653,7 +693,7 @@ spec:
653693
```
654694

655695
All the requirements must be met for the clone operation to work, including
656-
the same PostgreSQL version (in our case 14.0).
696+
the same PostgreSQL version (in our case 14.1).
657697

658698
#### TLS certificate authentication
659699

@@ -668,7 +708,7 @@ in the same Kubernetes cluster.
668708
This example can be easily adapted to cover an instance that resides
669709
outside the Kubernetes cluster.
670710

671-
The manifest defines a new PostgreSQL 14.0 cluster called `cluster-clone-tls`,
711+
The manifest defines a new PostgreSQL 14.1 cluster called `cluster-clone-tls`,
672712
which is bootstrapped using the `pg_basebackup` method from the `cluster-example`
673713
external cluster. The host is identified by the read/write service
674714
in the same cluster, while the `streaming_replica` user is authenticated
@@ -683,7 +723,7 @@ metadata:
683723
name: cluster-clone-tls
684724
spec:
685725
instances: 3
686-
imageName: quay.io/enterprisedb/postgresql:14.0
726+
imageName: quay.io/enterprisedb/postgresql:14.1
687727
688728
bootstrap:
689729
pg_basebackup:

advocacy_docs/kubernetes/cloud_native_postgresql/cnp-plugin.mdx

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,20 @@ PostgreSQL Image: quay.io/enterprisedb/postgresql:13
4141
Primary instance: cluster-example-1
4242
Instances: 3
4343
Ready instances: 3
44+
Current Timeline: 2
45+
Current WAL file: 00000002000000000000000A
46+
47+
Continuous Backup status
48+
First Point of Recoverability: 2021-11-09T13:36:43Z
49+
Working WAL archiving: OK
50+
Last Archived WAL: 00000002000000000000000A @ 2021-11-09T13:47:28.354645Z
4451

4552
Instances status
46-
Pod name Current LSN Received LSN Replay LSN System ID Primary Replicating Replay paused Pending restart
47-
-------- ----------- ------------ ---------- --------- ------- ----------- ------------- ---------------
48-
cluster-example-1 0/6000060 6927251808674721812 ✓ ✗ ✗ ✗
49-
cluster-example-2 0/6000060 0/6000060 6927251808674721812 ✗ ✓ ✗ ✗
50-
cluster-example-3 0/6000060 0/6000060 6927251808674721812 ✗ ✓ ✗ ✗
53+
Manager Version Pod name Current LSN Received LSN Replay LSN System ID Primary Replicating Replay paused Pending restart Status
54+
--------------- -------- ----------- ------------ ---------- --------- ------- ----------- ------------- --------------- ------
55+
1.10.0 cluster-example-1 0/5000060 7027078108164751389 ✓ ✗ ✗ ✗ OK
56+
1.10.0 cluster-example-2 0/5000060 0/5000060 7027078108164751389 ✗ ✓ ✗ ✗ OK
57+
1.10.0 cluster-example-3 0/5000060 0/5000060 7027078108164751389 ✗ ✓ ✗ ✗ OK
5158

5259
```
5360

@@ -65,47 +72,65 @@ PostgreSQL Image: quay.io/enterprisedb/postgresql:13
6572
Primary instance: cluster-example-1
6673
Instances: 3
6774
Ready instances: 3
75+
Current Timeline: 2
76+
Current WAL file: 00000002000000000000000A
6877

6978
PostgreSQL Configuration
70-
archive_command = '/controller/manager wal-archive %p'
79+
archive_command = '/controller/manager wal-archive --log-destination /controller/log/postgres.json %p'
7180
archive_mode = 'on'
7281
archive_timeout = '5min'
82+
cluster_name = 'cluster-example'
7383
full_page_writes = 'on'
7484
hot_standby = 'true'
7585
listen_addresses = '*'
76-
logging_collector = 'off'
86+
log_destination = 'csvlog'
87+
log_directory = '/controller/log'
88+
log_filename = 'postgres'
89+
log_rotation_age = '0'
90+
log_rotation_size = '0'
91+
log_truncate_on_rotation = 'false'
92+
logging_collector = 'on'
7793
max_parallel_workers = '32'
7894
max_replication_slots = '32'
7995
max_worker_processes = '32'
8096
port = '5432'
97+
shared_preload_libraries = ''
8198
ssl = 'on'
8299
ssl_ca_file = '/controller/certificates/client-ca.crt'
83100
ssl_cert_file = '/controller/certificates/server.crt'
84101
ssl_key_file = '/controller/certificates/server.key'
85-
unix_socket_directories = '/var/run/postgresql'
102+
unix_socket_directories = '/controller/run'
86103
wal_keep_size = '512MB'
87104
wal_level = 'logical'
88105
wal_log_hints = 'on'
89-
106+
cnp.config_sha256 = '407239112913e96626722395d549abc78b2cf9b767471e1c8eac6f33132e789c'
90107

91108
PostgreSQL HBA Rules
109+
92110
# Grant local access
93-
local all all peer
111+
local all all peer map=local
94112

95113
# Require client certificate authentication for the streaming_replica user
96114
hostssl postgres streaming_replica all cert
97115
hostssl replication streaming_replica all cert
116+
hostssl all cnp_pooler_pgbouncer all cert
117+
118+
98119

99-
# Otherwise use md5 authentication
120+
# Otherwise use the default authentication method
100121
host all all all md5
101122

123+
Continuous Backup status
124+
First Point of Recoverability: 2021-11-09T13:36:43Z
125+
Working WAL archiving: OK
126+
Last Archived WAL: 00000002000000000000000A @ 2021-11-09T13:47:28.354645Z
102127

103128
Instances status
104-
Pod name Current LSN Received LSN Replay LSN System ID Primary Replicating Replay paused Pending restart
105-
-------- ----------- ------------ ---------- --------- ------- ----------- ------------- ---------------
106-
cluster-example-1 0/6000060 6927251808674721812 ✓ ✗ ✗ ✗
107-
cluster-example-2 0/6000060 0/6000060 6927251808674721812 ✗ ✓ ✗ ✗
108-
cluster-example-3 0/6000060 0/6000060 6927251808674721812 ✗ ✓ ✗ ✗
129+
Manager Version Pod name Current LSN Received LSN Replay LSN System ID Primary Replicating Replay paused Pending restart Status
130+
--------------- -------- ----------- ------------ ---------- --------- ------- ----------- ------------- --------------- ------
131+
1.10.0 cluster-example-1 0/5000060 7027078108164751389 ✓ ✗ ✗ ✗ OK
132+
1.10.0 cluster-example-2 0/5000060 0/5000060 7027078108164751389 ✗ ✓ ✗ ✗ OK
133+
1.10.0 cluster-example-3 0/5000060 0/5000060 7027078108164751389 ✗ ✓ ✗ ✗ OK
109134
```
110135

111136
The command also supports output in `yaml` and `json` format.

0 commit comments

Comments
 (0)