-
Notifications
You must be signed in to change notification settings - Fork 52
Add Postgres TDE (pg_tde) encryption-at-rest guide #1033
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
Open
tamalsaha
wants to merge
6
commits into
master
Choose a base branch
from
postgres-tde
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3c43636
Add Postgres TDE (pg_tde) encryption-at-rest guide
tamalsaha 62fc10f
Document TDE in the Postgres concept references
tamalsaha 5971c6a
Document TDE backup, PITR, and private-image pull for Postgres
tamalsaha ddbdf30
Address CodeRabbit review comments on TDE docs
tamalsaha 295a623
Remove imagePullSecrets guidance from TDE docs
tamalsaha aa830ac
Scope TDE backup limitation to the physical path only
tamalsaha File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| --- | ||
| title: TDE Encryption at Rest | ||
| menu: | ||
| docs_{{ .version }}: | ||
| identifier: guides-postgres-tde | ||
| name: TDE Encryption at Rest | ||
| parent: pg-postgres-guides | ||
| weight: 75 | ||
| menu_name: docs_{{ .version }} | ||
| --- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| --- | ||
| title: Backup & Restore a TDE-Encrypted Postgres | ||
| menu: | ||
| docs_{{ .version }}: | ||
| identifier: guides-postgres-tde-backup | ||
| name: Backup & Restore | ||
| parent: guides-postgres-tde | ||
| weight: 30 | ||
| menu_name: docs_{{ .version }} | ||
| section_menu_id: guides | ||
| --- | ||
|
|
||
| > New to KubeDB? Please start with the [KubeDB documentation](/docs/README.md). | ||
|
|
||
| # Backup & Restore a TDE-Encrypted Postgres | ||
|
|
||
| A TDE-encrypted Postgres cannot use the community physical backup and WAL | ||
| archiving path: the physical backup tool (`pg_basebackup`) and the WAL reader | ||
| used for continuous archiving cannot read `pg_tde`-encrypted files or its | ||
| custom WAL records. KubeDB ships `pg_tde`-aware equivalents for the physical | ||
| path, so once you point at the right catalog entries, physical backup and | ||
| restore work the same way you would expect. Logical backups are unaffected: | ||
| KubeStash's logical backup path already talks to Postgres over the normal | ||
| protocol, described below. | ||
|
|
||
| Read the [TDE overview](/docs/guides/postgres/tde/overview/index.md) and | ||
| [TDE guide](/docs/guides/postgres/tde/guide/index.md) first. | ||
|
|
||
| ## Logical backup & restore (KubeStash) | ||
|
|
||
| [KubeStash logical backup](/docs/guides/postgres/backup/kubestash/logical/index.md) | ||
| uses `pg_dump`/`pg_dumpall` to back up and `psql` to restore, which talk to | ||
| Postgres over the normal protocol and never touch the on-disk files directly, | ||
| so a TDE cluster backs up exactly like a community one -- no extra | ||
| configuration needed on the | ||
| `BackupConfiguration`/`RestoreSession` side. The `postgres-addon` used by | ||
| KubeStash detects the Percona distribution automatically. | ||
|
|
||
| The one thing to plan for is the **restore target**: | ||
|
|
||
| - Restoring a TDE-encrypted dump into another TDE (Percona) cluster works as | ||
| expected; data is re-encrypted under the target cluster's own principal key. | ||
| - Restoring a TDE-encrypted dump into a **non-TDE (community) Postgres** is | ||
| rejected: the dump contains `pg_tde`/`tde_heap` DDL that a community server | ||
| cannot execute. The restore addon detects this up front and fails loudly | ||
| instead of partially applying the dump. | ||
|
|
||
| ## Physical backup, continuous archiving & PITR | ||
|
|
||
| Follow the [continuous archiving and PITR guide](/docs/guides/postgres/pitr/archiver.md) | ||
| for the general `PostgresArchiver` setup (`BackupStorage`, `RetentionPolicy`, | ||
| `PostgresArchiver`, `spec.archiver.ref` on the `Postgres` object). For a TDE | ||
| cluster, the differences are: | ||
|
|
||
| - **Full/base backups** use `pg_tde_basebackup` instead of `pg_basebackup` | ||
| (selected automatically whenever the database image is a Percona | ||
| distribution -- no field to set). | ||
| - **WAL archiving and PITR recovery** need a `pg_tde`-aware archiver image, | ||
| because reading the commit LSN out of the WAL stream (for archiving) and | ||
| replaying it (for recovery) both require registering `pg_tde`'s custom WAL | ||
| resource manager, and -- when `spec.tde.encryptWAL: true` -- decrypting the | ||
| WAL itself. Use a `PostgresVersion` whose `spec.archiver.walg.image` points | ||
| at the Percona build of the archiver image (matching the `-percona` catalog | ||
| entries used elsewhere in TDE, e.g. `17.9-percona`), not the community | ||
| build. The KubeDB installer ships the correct image per version; you only | ||
| need to make sure you deployed the `-percona` `PostgresVersion`, the same | ||
| one used to create the database. | ||
| - This applies whether or not `spec.tde.encryptWAL` is enabled: even with WAL | ||
| encryption off, `pg_tde` still writes custom WAL records that a community | ||
| WAL reader does not recognize. | ||
|
|
||
| With the Percona archiver image in place, PITR works the same for both | ||
| `encryptWAL: false` and `encryptWAL: true` clusters. Either way, the original | ||
| cluster's principal key must still be resolvable through its key provider | ||
| (Vault, KMIP, or file) at restore time: decrypting the archived WAL and the | ||
| base backup's `pg_tde` internal keys both depend on it, regardless of whether | ||
| WAL encryption itself was on. Restore a `Postgres` with | ||
| `spec.init.archiver.recoveryTimestamp` exactly as shown in the | ||
| [PITR guide](/docs/guides/postgres/pitr/archiver.md#restore-postgresql). | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| ## Next Steps | ||
|
|
||
| - Review the [TDE overview](/docs/guides/postgres/tde/overview/index.md) for | ||
| the key hierarchy and limitations. | ||
| - Follow the [TDE guide](/docs/guides/postgres/tde/guide/index.md) to deploy | ||
| an encrypted Postgres, rotate the principal key, and enable WAL encryption. | ||
| - Learn about [logical backup & restore with KubeStash](/docs/guides/postgres/backup/kubestash/logical/index.md). | ||
| - Learn about [continuous archiving and point-in-time recovery](/docs/guides/postgres/pitr/archiver.md). | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.