@@ -32,7 +32,7 @@ For more detailed information about this feature, please refer to the
32
32
EDB Postgres for Kubernetes requires both the ` postgres ` user and database to
33
33
always exists. Using the local Unix Domain Socket, it needs to connect
34
34
as ` postgres ` user to the ` postgres ` database via ` peer ` authentication in
35
- order to perform administrative tasks on the cluster.
35
+ order to perform administrative tasks on the cluster.
36
36
** DO NOT DELETE** the ` postgres ` user or the ` postgres ` database!!!
37
37
38
38
!!! Info
@@ -212,36 +212,87 @@ The user that owns the database defaults to the database name instead.
212
212
The application user is not used internally by the operator, which instead
213
213
relies on the superuser to reconcile the cluster with the desired status.
214
214
215
- # ## Passing options to `initdb`
215
+ # ## Passing Options to `initdb`
216
216
217
- The actual PostgreSQL data directory is created via an invocation of the
218
- ` initdb` PostgreSQL command. If you need to add custom options to that command
219
- (i.e., to change the `locale` used for the template databases or to add data
220
- checksums), you can use the following parameters :
217
+ The PostgreSQL data directory is initialized using the
218
+ [`initdb` PostgreSQL command](https://www.postgresql.org/docs/current/app-initdb.html).
219
+
220
+ EDB Postgres for Kubernetes enables you to customize the behavior of `initdb` to modify
221
+ settings such as default locale configurations and data checksums.
222
+
223
+ !!! Warning
224
+ EDB Postgres for Kubernetes acts only as a direct proxy to `initdb` for locale-related
225
+ options, due to the ongoing and significant enhancements in PostgreSQL's locale
226
+ support. It is your responsibility to ensure that the correct options are
227
+ provided, following the PostgreSQL documentation, and to verify that the
228
+ bootstrap process completes successfully.
229
+
230
+ To include custom options in the `initdb` command, you can use the following
231
+ parameters :
232
+
233
+ builtinLocale
234
+ : When `builtinLocale` is set to a value, EDB Postgres for Kubernetes passes it to the
235
+ ` --builtin-locale` option in `initdb`. This option controls the builtin locale, as
236
+ defined in ["Locale Support"](https://www.postgresql.org/docs/current/locale.html)
237
+ from the PostgreSQL documentation (default : empty). Note that this option requires
238
+ ` localeProvider` to be set to `builtin`. Available from PostgreSQL 17.
221
239
222
240
dataChecksums
223
- : When `dataChecksums` is set to `true`, CNP invokes the `-k` option in
241
+ : When `dataChecksums` is set to `true`, EDB Postgres for Kubernetes invokes the `-k` option in
224
242
` initdb` to enable checksums on data pages and help detect corruption by the
225
243
I/O system - that would otherwise be silent (default : ` false` ).
226
244
227
245
encoding
228
- : When `encoding` set to a value, CNP passes it to the `--encoding` option in `initdb`,
229
- which selects the encoding of the template database (default : ` UTF8` ).
246
+ : When `encoding` set to a value, EDB Postgres for Kubernetes passes it to the `--encoding`
247
+ option in `initdb`, which selects the encoding of the template database
248
+ (default : ` UTF8` ).
249
+
250
+ icuLocale
251
+ : When `icuLocale` is set to a value, EDB Postgres for Kubernetes passes it to the
252
+ ` --icu-locale` option in `initdb`. This option controls the ICU locale, as
253
+ defined in ["Locale Support"](https://www.postgresql.org/docs/current/locale.html)
254
+ from the PostgreSQL documentation (default : empty).
255
+ Note that this option requires `localeProvider` to be set to `icu`.
256
+ Available from PostgreSQL 15.
257
+
258
+ icuRules
259
+ : When `icuRules` is set to a value, EDB Postgres for Kubernetes passes it to the
260
+ ` --icu-rules` option in `initdb`. This option controls the ICU locale, as
261
+ defined in ["Locale
262
+ Support"](https://www.postgresql.org/docs/current/locale.html) from the
263
+ PostgreSQL documentation (default : empty). Note that this option requires
264
+ ` localeProvider` to be set to `icu`. Available from PostgreSQL 16.
265
+
266
+ locale
267
+ : When `locale` is set to a value, EDB Postgres for Kubernetes passes it to the `--locale`
268
+ option in `initdb`. This option controls the locale, as defined in
269
+ ["Locale Support"](https://www.postgresql.org/docs/current/locale.html) from
270
+ the PostgreSQL documentation. By default, the locale parameter is empty. In
271
+ this case, environment variables such as `LANG` are used to determine the
272
+ locale. Be aware that these variables can vary between container images,
273
+ potentially leading to inconsistent behavior.
230
274
231
275
localeCollate
232
- : When `localeCollate` is set to a value, CNP passes it to the `--lc-collate`
276
+ : When `localeCollate` is set to a value, EDB Postgres for Kubernetes passes it to the `--lc-collate`
233
277
option in `initdb`. This option controls the collation order (`LC_COLLATE`
234
278
subcategory), as defined in ["Locale Support"](https://www.postgresql.org/docs/current/locale.html)
235
279
from the PostgreSQL documentation (default : ` C` ).
236
280
237
281
localeCType
238
- : When `localeCType` is set to a value, CNP passes it to the `--lc-ctype` option in
282
+ : When `localeCType` is set to a value, EDB Postgres for Kubernetes passes it to the `--lc-ctype` option in
239
283
` initdb` . This option controls the collation order (`LC_CTYPE` subcategory), as
240
284
defined in ["Locale Support"](https://www.postgresql.org/docs/current/locale.html)
241
285
from the PostgreSQL documentation (default : ` C` ).
242
286
287
+ localeProvider
288
+ : When `localeProvider` is set to a value, EDB Postgres for Kubernetes passes it to the `--locale-provider`
289
+ option in `initdb`. This option controls the locale provider, as defined in
290
+ ["Locale Support"](https://www.postgresql.org/docs/current/locale.html) from the
291
+ PostgreSQL documentation (default : empty, which means `libc` for PostgreSQL).
292
+ Available from PostgreSQL 15.
293
+
243
294
walSegmentSize
244
- : When `walSegmentSize` is set to a value, CNP passes it to the `--wal-segsize`
295
+ : When `walSegmentSize` is set to a value, EDB Postgres for Kubernetes passes it to the `--wal-segsize`
245
296
option in `initdb` (default : not set - defined by PostgreSQL as 16 megabytes).
246
297
247
298
!!! Note
@@ -430,44 +481,59 @@ to the ["Recovery" section](recovery.md).
430
481
431
482
# ## Bootstrap from a live cluster (`pg_basebackup`)
432
483
433
- The `pg_basebackup` bootstrap mode lets you create a new cluster (*target*) as
434
- an exact physical copy of an existing and **binary compatible** PostgreSQL
435
- instance (*source*), through a valid *streaming replication* connection.
436
- The source instance can be either a primary or a standby PostgreSQL server.
484
+ The `pg_basebackup` bootstrap mode allows you to create a new cluster
485
+ (*target*) as an exact physical copy of an existing and **binary-compatible**
486
+ PostgreSQL instance (*source*) managed by EDB Postgres for Kubernetes, using a valid
487
+ *streaming replication* connection. The source instance can either be a primary
488
+ or a standby PostgreSQL server. It’s crucial to thoroughly review the
489
+ requirements section below, as the pros and cons of PostgreSQL physical
490
+ replication fully apply.
437
491
438
- The primary use case for this method is represented by **migrations** to EDB Postgres for Kubernetes,
439
- either from outside Kubernetes or within Kubernetes (e.g., from another operator).
492
+ The primary use cases for this method include :
440
493
441
- !!! Warning
442
- The current implementation creates a *snapshot* of the origin PostgreSQL
443
- instance when the cloning process terminates and immediately starts
444
- the created cluster. See ["Current limitations"](#current-limitations) below for details.
494
+ - Reporting and business intelligence clusters that need to be regenerated
495
+ periodically (daily, weekly)
496
+ - Test databases containing live data that require periodic regeneration
497
+ (daily, weekly, monthly) and anonymization
498
+ - Rapid spin-up of a standalone replica cluster
499
+ - Physical migrations of EDB Postgres for Kubernetes clusters to different namespaces or
500
+ Kubernetes clusters
445
501
446
- Similar to the case of the `recovery` bootstrap method, once the clone operation
447
- completes, the operator will take ownership of the target cluster, starting from
448
- the first instance. This includes overriding some configuration parameters, as
449
- required by EDB Postgres for Kubernetes, resetting the superuser password, creating
450
- the `streaming_replica` user, managing the replicas, and so on. The resulting
451
- cluster will be completely independent of the source instance.
502
+ !!! Important
503
+ Avoid using this method, based on physical replication, to migrate an
504
+ existing PostgreSQL cluster outside of Kubernetes into EDB Postgres for Kubernetes unless you
505
+ are completely certain that all requirements are met and the operation has been
506
+ thoroughly tested. The EDB Postgres for Kubernetes community does not endorse this approach
507
+ for such use cases and recommends using logical import instead. It is
508
+ exceedingly rare that all requirements for physical replication are met in a
509
+ way that seamlessly works with EDB Postgres for Kubernetes.
510
+
511
+ !!! Warning
512
+ In its current implementation, this method clones the source PostgreSQL
513
+ instance, thereby creating a *snapshot*. Once the cloning process has finished,
514
+ the new cluster is immediately started.
515
+ Refer to ["Current limitations"](#current-limitations) for more details.
516
+
517
+ Similar to the `recovery` bootstrap method, once the cloning operation is
518
+ complete, the operator takes full ownership of the target cluster, starting
519
+ from the first instance. This includes overriding certain configuration
520
+ parameters as required by EDB Postgres for Kubernetes, resetting the superuser password,
521
+ creating the `streaming_replica` user, managing replicas, and more. The
522
+ resulting cluster operates independently from the source instance.
452
523
453
524
!!! Important
454
- Configuring the network between the target instance and the source instance
455
- goes beyond the scope of EDB Postgres for Kubernetes documentation, as it depends
456
- on the actual context and environment.
525
+ Configuring the network connection between the target and source instances
526
+ lies outside the scope of EDB Postgres for Kubernetes documentation, as it depends heavily on
527
+ the specific context and environment.
457
528
458
- The streaming replication client on the target instance, which will be
459
- transparently managed by `pg_basebackup`, can authenticate itself on the source
460
- instance in any of the following ways :
529
+ The streaming replication client on the target instance, managed transparently
530
+ by `pg_basebackup`, can authenticate on the source instance using one of the
531
+ following methods :
461
532
462
- 1. via [username /password](#usernamepassword-authentication)
463
- 2. via [TLS client certificate](#tls-certificate-authentication)
533
+ 1. [Username /password](#usernamepassword-authentication)
534
+ 2. [TLS client certificate](#tls-certificate-authentication)
464
535
465
- The latter is the recommended one if you connect to a source managed
466
- by EDB Postgres for Kubernetes or configured for TLS authentication.
467
- The first option is, however, the most common form of authentication to a
468
- PostgreSQL server in general, and might be the easiest way if the source
469
- instance is on a traditional environment outside Kubernetes.
470
- Both cases are explained below.
536
+ Both authentication methods are detailed below.
471
537
472
538
# ### Requirements
473
539
@@ -545,7 +611,7 @@ file on the source PostgreSQL instance:
545
611
host replication streaming_replica all md5
546
612
` ` `
547
613
548
- The following manifest creates a new PostgreSQL 17.0 cluster,
614
+ The following manifest creates a new PostgreSQL 17.2 cluster,
549
615
called `target-db`, using the `pg_basebackup` bootstrap method
550
616
to clone an external PostgreSQL cluster defined as `source-db`
551
617
(in the `externalClusters` array). As you can see, the `source-db`
@@ -560,7 +626,7 @@ metadata:
560
626
name: target-db
561
627
spec:
562
628
instances: 3
563
- imageName: quay.io/enterprisedb/postgresql:17.0
629
+ imageName: quay.io/enterprisedb/postgresql:17.2
564
630
565
631
bootstrap:
566
632
pg_basebackup:
@@ -580,7 +646,7 @@ spec:
580
646
` ` `
581
647
582
648
All the requirements must be met for the clone operation to work, including
583
- the same PostgreSQL version (in our case 17.0 ).
649
+ the same PostgreSQL version (in our case 17.2 ).
584
650
585
651
# ### TLS certificate authentication
586
652
@@ -595,7 +661,7 @@ in the same Kubernetes cluster.
595
661
This example can be easily adapted to cover an instance that resides
596
662
outside the Kubernetes cluster.
597
663
598
- The manifest defines a new PostgreSQL 17.0 cluster called `cluster-clone-tls`,
664
+ The manifest defines a new PostgreSQL 17.2 cluster called `cluster-clone-tls`,
599
665
which is bootstrapped using the `pg_basebackup` method from the `cluster-example`
600
666
external cluster. The host is identified by the read/write service
601
667
in the same cluster, while the `streaming_replica` user is authenticated
@@ -610,7 +676,7 @@ metadata:
610
676
name: cluster-clone-tls
611
677
spec:
612
678
instances: 3
613
- imageName: quay.io/enterprisedb/postgresql:17.0
679
+ imageName: quay.io/enterprisedb/postgresql:17.2
614
680
615
681
bootstrap:
616
682
pg_basebackup:
@@ -691,7 +757,7 @@ instance using a second connection (see the `--wal-method=stream` option for
691
757
Once the backup is completed, the new instance will be started on a new timeline
692
758
and diverge from the source.
693
759
For this reason, it is advised to stop all write operations to the source database
694
- before migrating to the target database in Kubernetes .
760
+ before migrating to the target database.
695
761
696
762
!!! Important
697
763
Before you attempt a migration, you must test both the procedure
0 commit comments