Skip to content

Commit

Permalink
PG-1197 Removed steps for tde_heap_basic from docs (#330)
Browse files Browse the repository at this point in the history
* PG-1197 Removed steps for tde_heap_basic

Added description of versions

* Updated after the review
  • Loading branch information
nastena1606 authored Nov 7, 2024
1 parent bdd5f64 commit 5f95c34
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 90 deletions.
2 changes: 1 addition & 1 deletion documentation/_resource/overrides/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

{% block announce %}
This is a Beta version of Percona Transparent Encryption extension and it is
<strong>not recommended for production environments</strong> yet. We encourage you to test it and give your feedback.
<strong>not recommended for production environments</strong> yet. We encourage you to test it and <a href= "https://forums.percona.com/c/postgresql/pg-tde-transparent-data-encryption-tde/82">give your feedback</a>.
This will help us improve the product and make it production-ready faster.
{% endblock %}

Expand Down
2 changes: 1 addition & 1 deletion documentation/_resource/overrides/partials/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<path d="m7.825 13 5.6 5.6L12 20l-8-8 8-8 1.425 1.4-5.6 5.6H20v2H7.825Z"/>
</g>
</svg>
<span>Percona Documentation</span>
<span>Percona Software for PostgreSQL Documentation</span>
</a>
</div>
</div>
Expand Down
41 changes: 29 additions & 12 deletions documentation/docs/index.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,58 @@
# `pg_tde` documentation

`pg_tde` is the extension that brings in [Transparent Data Encryption (TDE)](tde.md) to PostgreSQL and enables users to keep sensitive data safe and secure. It enables users to configure encryption differently for each database, encrypting specific tables in some databases with different encryption keys, while keeping others non encrypted.
`pg_tde` is the extension that brings in [Transparent Data Encryption (TDE)](tde.md) to PostgreSQL and enables users to keep sensitive data safe and secure. The encryption is transparent for users allowing them to access and manipulate the data and not to worry about the encryption process.

Users can configure encryption differently for each database, encrypting specific tables in some databases with different encryption keys, while keeping others non encrypted.

!!! important

This is the {{release}} version of the extension and is not meant for production use yet. [Release notes](release-notes/release-notes.md)
This extension is in the experimental phase and is under active development. It is not meant for production use yet.

[What's new ](release-notes/release-notes.md){.md-button}

## What's encrypted
## What's encrypted:

`pg_tde` encrypts the following:

* User data in tables, including TOAST tables, that are created using the extension. Metadata of those tables is not encrypted.
* Write-Ahead Log (WAL) data for tables created using the extension
* Temporary tables created during the database operation for data tables created using the extension
* Write-Ahead Log (WAL) data for the entire database cluster. This includes WAL data in encrypted and non-encrypted tables
* Indexes on encrypted tables
* Logical replication on encrypted tables

## Known limitations

* Logical replication is not available as it doesn't work with encrypted tables.
* Keys in the local keyfile are stored unencrypted.
* Indexes and `NULL` bitmaps of tuples are currently not encrypted.
* System tables are currently not encrypted.

<i warning>:material-alert: Warning:</i> Note that introducing encryption/decryption affects performance. Our benchmark tests show less than 10% performance overhead for most situations. However, in some specific applications such as those using JSONB operations, performance degradation might be higher.

[Get started](install.md){.md-button}
## Versions and supported PostgreSQL deployments

The `pg_tde` extension comes in two distinct versions with specific access methods to encrypt the data. These versions are database-specific and differ in terms of what they encrypt and with what access method. Each version is characterized by the database it supports, the access method it provides, and the scope of encryption it offers.

* **Version for Percona Server for PostgreSQL**

This `pg_tde` version is based on and supported for [Percona Server for PostgreSQL 17.x :octicons-link-external-16:](https://docs.percona.com/postgresql/17/postgresql-server.html) - an open source binary drop-in replacement for PostgreSQL Community. It provides the `tde_heap` access method and offers [full encryption capabilities](#whats-encrypted).

## Supported PostgreSQL versions
* **Community version**

`pg_tde` is currently based on Percona Server for PostgreSQL 17.0 and upstream PostgreSQL 16.x.
This version is supported for PostgreSQL Community 16 and 17, and Percona Distribution for PostgreSQL 16. It provides the `tde_heap_basic` access method, offering limited encryption features. The limitations are in encrypting WAL data only for tables created using the extension and no support of index encryption nor logical replication.

It is also supported for Percona Distribution for PostgreSQL 16.x and upstream PostgreSQL 16.x.
### Which version to chose?

The answer is pretty straightforward: if you don't use indexes and don't need index encryption, use the community version and the `tde_heap_basic` access method. Check the [upstream documentation :octicons-link-external-16:](https://github.com/percona/pg_tde/blob/main/README.md) how to get started.

Otherwise, enjoy full encryption with the Percona Server for PostgreSQL version and the `tde_heap` access method.

Still not sure? [Contact our experts](https://www.percona.com/about/contact) to find the best solution for you.

[Get started](install.md){.md-button}

## Future releases

The following is planned for future releases of `pg_tde`:

* Encryption of indexes and `NULL` bitmaps of tuples
* Logical replication support
* KMIP integration for key management
* Global principal key management

Expand Down
18 changes: 11 additions & 7 deletions documentation/docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Install `pg_tde` using one of available installation methods:

=== "Package manager"

Starting with Aplha1 version, you can install the extension as package from Percona repositories using the `percona-release` tool. The packages are available for the following operating systems:
The packages are available for the following operating systems:

- Red Hat Enterprise Linux 8 and compatible derivatives
- Red Hat Enterprise Linux 9 and compatible derivatives
Expand All @@ -33,15 +33,15 @@ Install `pg_tde` using one of available installation methods:

=== "Build from source"

The following steps apply to PostgreSQL 16. To build `pg_tde` for PostgreSQL 17, replace the version in the commands.
To build `pg_tde` from source code, do the following

1. To build `pg_tde` from source code, you require the following on Ubuntu/Debian:
1. On Ubuntu/Debian: Install the following dependencies required for the build:

```sh
sudo apt install make gcc postgresql-server-dev-16 libcurl4-openssl-dev
sudo apt install make gcc postgresql-server-dev-17 libcurl4-openssl-dev
```

2. [Install Percona Distribution for PostgreSQL 16](https://docs.percona.com/postgresql/16/installing.html) or [upstream PostgreSQL 16](https://www.postgresql.org/download/)
2. [Install Percona Distribution for PostgreSQL 17](https://docs.percona.com/postgresql/17/installing.html) or [upstream PostgreSQL 17](https://www.postgresql.org/download/)

3. If PostgreSQL is installed in a non standard directory, set the `PG_CONFIG` environment variable to point to the `pg_config` executable.

Expand All @@ -62,15 +62,19 @@ Install `pg_tde` using one of available installation methods:

=== "Run in Docker"

You can find Docker images built from the current main branch on [Docker Hub](https://hub.docker.com/r/perconalab/pg_tde). Images are built on top of [postgres:16](https://hub.docker.com/_/postgres) official image.
!!! note

The steps below are for the `pg_tde` community version.

You can find Docker images built from the current main branch on [Docker Hub](https://hub.docker.com/r/perconalab/pg_tde). Images are built on top of [postgres:17](https://hub.docker.com/_/postgres) official image.

To run `pg_tde` in Docker, use the following command:

```
docker run --name pg-tde -e POSTGRES_PASSWORD=mysecretpassword -d perconalab/pg_tde
```

It builds and adds `pg_tde` extension to PostgreSQL 16. The `postgresql.conf` contains the required modifications. The `pg_tde` extension is added to `template1` so that all new databases automatically have the `pg_tde` extension loaded.
It builds and adds `pg_tde` extension to PostgreSQL 17. The `postgresql.conf` contains the required modifications. The `pg_tde` extension is added to `template1` so that all new databases automatically have the `pg_tde` extension loaded.

Keys are not created automatically. You must configure a key provider and a principal key for each database where you wish to use encrypted tables. See the instructions in the [Setup](setup.md) section, starting with the 4th point, as the first 3 steps are already completed in the Docker image.

Expand Down
10 changes: 4 additions & 6 deletions documentation/docs/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,9 @@ Load the `pg_tde` at the start time. The extension requires additional shared me

## WAL encryption configuration (tech preview)

Perform this step if you [installed Percona Server for PostgreSQL :octicons-link-external-16:](https://docs.percona.com/postgresql/17/installing.html). Otherwise, proceed to the [Next steps](#next-steps).

After you [enabled `pg_tde`](#enable-extension) and started the Percona Server for PostgreSQL, a principal key and a keyring for WAL are created. Now you need to instruct `pg_tde ` to encrypt WAL files by configuring WAL encryption. Here's how to do it:

1. Enable WAL level encryption using the `ALTER SYSTEM SET` command:
1. Enable WAL level encryption using the `ALTER SYSTEM SET` command. You need the privileges of the superuser to run this command:

```sql
ALTER SYSTEM set pg_tde.wal_encrypt = on;
Expand All @@ -104,8 +102,8 @@ After you [enabled `pg_tde`](#enable-extension) and started the Percona Server f

3. We highly recommend you to create your own keyring and rotate the principal key. This is because the default principal key is created from the local keyfile and is stored unencrypted.

Set up the key provider for WAL encryption

Set up the key provider for WAL encryption
=== "With HashiCorp Vault"

```sql
Expand Down Expand Up @@ -136,7 +134,7 @@ After you [enabled `pg_tde`](#enable-extension) and started the Percona Server f
SELECT pg_tde_rotate_principal_key('PG_TDE_GLOBAL', 'new-principal-key', 'provider-name');
```
Now all WAL files are encrypted.
Now all WAL files are encrypted for both encrypted and unencrypted tables.
## Next steps
Expand Down
82 changes: 20 additions & 62 deletions documentation/docs/test.md
Original file line number Diff line number Diff line change
@@ -1,76 +1,34 @@
# Test Transparent Data Encryption

To check if the data is encrypted, do the following:

=== "pg_tde Beta"

1. Create a table in the database for which you have [enabled `pg_tde`](setup.md). Enabling `pg_tde` extension creates the table access method `tde_heap_basic`. To enable data encryption, create the table using this access method as follows:

```sql
CREATE TABLE <table_name> (<field> <datatype>) USING tde_heap_basic;
```

!!! hint

You can enable data encryption by default by setting the `default_table_access_method` to `tde_heap_basic`:

```sql
ALTER SYSTEM SET default_table_access_method=tde_heap;
```

Reload the configuration to apply the changes:
!!! warning

```
SELECT pg_reload_conf();
```

2. Run the following function:
This is the tech preview functionality. Its scope is not yet finalized and can change anytime.** Use it only for testing purposes.**

```sql
SELECT pg_tde_is_encrypted('table_name');
```

The function returns `t` if the table is encrypted and `f` - if not.

3. Rotate the principal key when needed:

```sql
SELECT pg_tde_rotate_principal_key(); -- uses automatic key versionin
-- or
SELECT pg_tde_rotate_principal_key('new-principal-key', NULL); -- specify new key name
-- or
SELECT pg_tde_rotate_principal_key('new-principal-key', 'new-provider'); -- change provider
```

=== "pg_tde Tech preview"

!!! warning

This is the tech preview functionality. Its scope is not yet finalized and can change anytime.** Use it only for testing purposes.**
To check if the data is encrypted, do the following:

1. Create a table in the database for which you have [enabled `pg_tde`](setup.md). Enabling `pg_tde` extension creates the table access method `tde_heap`. To enable data encryption, create the table using this access method as follows:
1. Create a table in the database for which you have [enabled `pg_tde`](setup.md). Enabling `pg_tde` extension creates the table access method `tde_heap`. To enable data encryption, create the table using this access method as follows:

```sql
CREATE TABLE <table_name> (<field> <datatype>) USING tde_heap;
```
```sql
CREATE TABLE <table_name> (<field> <datatype>) USING tde_heap;
```

2. Run the following function:
2. Run the following function:

```sql
SELECT pg_tde_is_encrypted('table_name');
```
```sql
SELECT pg_tde_is_encrypted('table_name');
```

The function returns `t` if the table is encrypted and `f` - if not.
The function returns `t` if the table is encrypted and `f` - if not.

3. Rotate the principal key when needed:
3. Rotate the principal key when needed:

```sql
SELECT pg_tde_rotate_principal_key(); -- uses automatic key versionin
-- or
SELECT pg_tde_rotate_principal_key('new-principal-key', NULL); -- specify new key name
-- or
SELECT pg_tde_rotate_principal_key('new-principal-key', 'new-provider'); -- change provider
```
```sql
SELECT pg_tde_rotate_principal_key(); -- uses automatic key versionin
-- or
SELECT pg_tde_rotate_principal_key('new-principal-key', NULL); -- specify new key name
-- or
SELECT pg_tde_rotate_principal_key('new-principal-key', 'new-provider'); -- changeprovider
```

!!! hint

Expand Down
2 changes: 1 addition & 1 deletion documentation/snippets/services-banner.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ If you need assistance, visit the community forum for comprehensive and free dat

<div class="actions" markdown>

[:material-forum-outline: Community Forum](https://forums.percona.com/c/postgresql/25?utm_campaign=Doc%20pages) [:percona-logo: Get a Percona Expert](https://www.percona.com/about/contact)
[:material-forum-outline: Community Forum](https://forums.percona.com/c/postgresql/pg-tde-transparent-data-encryption-tde/82) [:percona-logo: Get a Percona Expert](https://www.percona.com/about/contact)


<img referrerpolicy="no-referrer-when-downgrade" src="https://static.scarf.sh/a.png?x-pxid=b95a2b04-c5c7-47f9-bb4e-b7fc13c3ab0d" />
Expand Down

0 comments on commit 5f95c34

Please sign in to comment.