Skip to content

Commit e1ec7d3

Browse files
Sync docs from Discourse (#748)
Co-authored-by: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 1134930 commit e1ec7d3

20 files changed

+441
-765
lines changed

docs/explanation.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Explanation
2+
3+
This section contains pages with more detailed explanations that provide additional context about some of the key concepts behind the PostgreSQL charm:
4+
5+
* [Architecture]
6+
* [Interfaces and endpoints]
7+
* [Connection pooling]
8+
* [Users]
9+
* [Logs]
10+
* [Juju]
11+
* [Legacy charm]
12+
13+
<!-- Links -->
14+
15+
[Architecture]: /t/11857
16+
[Interfaces and endpoints]: /t/10251
17+
[Users]: /t/10798
18+
[Logs]: /t/12099
19+
[Juju]: /t/11985
20+
[Legacy charm]: /t/10690
21+
[Connection pooling]: /t/15777

docs/explanation/e-cryptography.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Cryptography
2+
3+
This document describes the cryptography used by Charmed PostgreSQL.
4+
5+
## Resource checksums
6+
7+
Charmed PostgreSQL and Charmed PgBouncer operators use pinned versions of the respective snaps to provide reproducible and secure environments.
8+
9+
The snaps package their workloads along with the necessary dependencies and utilities required for the operators’ lifecycle. For more details, see the snaps content in the `snapcraft.yaml` file for [PostgreSQL](https://github.com/canonical/charmed-postgresql-snap/blob/14/edge/snap/snapcraft.yaml) and [PgBouncer](https://github.com/canonical/charmed-pgbouncer-snap/blob/1/edge/snap/snapcraft.yaml).
10+
11+
Every artifact bundled into a snap is verified against its MD5, SHA256, or SHA512 checksum after download. The installation of certified snap into the rock is ensured by snap primitives that verify their squashfs filesystems images GPG signature. For more information on the snap verification process, refer to the [snapcraft.io documentation](https://snapcraft.io/docs/assertions).
12+
13+
## Sources verification
14+
15+
PostgreSQL and its extra components are built by Canonical from upstream source codes on [Launchpad](https://launchpad.net/ubuntu/+source/postgresql-common). PostgreSQL and PgBouncer are built as deb packages, other components - as PPAs.
16+
17+
Charmed PostgreSQL and Charmed PgBouncer charms and snaps are published and released programmatically using release pipelines implemented via GitHub Actions in their respective repositories.
18+
19+
All repositories in GitHub are set up with branch protection rules, requiring:
20+
21+
* new commits to be merged to main branches via pull request with at least 2 approvals from repository maintainers
22+
* new commits to be signed (e.g. using GPG keys)
23+
* developers to sign the [Canonical Contributor License Agreement (CLA)](https://ubuntu.com/legal/contributors)
24+
25+
## Encryption
26+
27+
Charmed PostgreSQL can be used to deploy a secure PostgreSQL cluster that provides encryption-in-transit capabilities out of the box for:
28+
29+
* Cluster internal communications
30+
* PgBouncer connections
31+
* External clients connections
32+
33+
To set up a secure connection Charmed PostgreSQL and Charmed PgBouncer need to be integrated with TLS Certificate Provider charms, e.g. self-signed-certificates operator. Certificate Signing Requests (CSRs) are generated for every unit using the tls_certificates_interface library that uses the cryptography Python library to create X.509 compatible certificates. The CSR is signed by the TLS Certificate Provider, returned to the units, and stored in Juju secret. The relation also provides the CA certificate, which is loaded into Juju secret.
34+
35+
Encryption at rest is currently not supported, although it can be provided by the substrate (cloud or on-premises).
36+
37+
## Authentication
38+
39+
In Charmed PostgreSQL, authentication layers can be enabled for:
40+
41+
1. PgBouncer authentication to PostgreSQL
42+
2. PostgreSQL cluster authentication
43+
3. Clients authentication to PostgreSQL
44+
45+
### PgBouncer authentication to PostgreSQL
46+
47+
Authentication of PgBouncer to PostgreSQL is based on the password-based `scram-sha-256` authentication method. See the [PostgreSQL official documentation](https://www.postgresql.org/docs/14/auth-password.html) for more details.
48+
49+
Credentials are exchanged via [Juju secrets](https://canonical-juju.readthedocs-hosted.com/en/latest/user/howto/manage-secrets/).
50+
51+
### PostgreSQL cluster authentication
52+
53+
Authentication among members of a PostgreSQL cluster is based on the password-based `scram-sha-256` authentication method.
54+
55+
An internal user is used for this authentication with its hashed password stored in a system metadata database. These credentials are also stored as a plain text file on the disk of each unit for the Patroni HA service.
56+
57+
### Clients authentication to PostgreSQL
58+
59+
Authentication of clients to PostgreSQL is based on the password-based `scram-sha-256` authentication method. See the [PostgreSQL official documentation](https://www.postgresql.org/docs/14/auth-password.html) for more details.
60+
61+
Credentials are exchanged via [Juju secrets](https://canonical-juju.readthedocs-hosted.com/en/latest/user/howto/manage-secrets/).

docs/explanation/e-juju-details.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,34 @@
1-
# Juju tech details
1+
# Juju
22

33
[Juju](https://juju.is/) is an open source orchestration engine for software operators that enables the deployment, integration and lifecycle management of applications at any scale, on any infrastructure using charms.
44

5-
This [charm](https://charmhub.io/postgresql) is an operator - business logic encapsulated in reusable software packages that automate every aspect of an application's life. Charms are shared via [CharmHub](https://charmhub.io/).
5+
> See also: [Juju client documentation](https://juju.is/docs/juju), [Juju blog](https://ubuntu.com/blog/tag/juju)
66
7-
See also:
7+
## Compatibility with PostgreSQL
88

9-
* [Juju Documentation](https://juju.is/docs/juju) and [Blog](https://ubuntu.com/blog/tag/juju)
10-
* [Charm SDK](https://juju.is/docs/sdk)
9+
Current stable releases of this charm can still be deployed on Juju 2.9. However, newer features are not supported.
10+
> See the [Releases page](/t/11875) for more information about the minimum Juju version required to operate the features of each revision.
11+
12+
Additionally, there are limitations regarding integrations with other charms. For example, integration with [modern TLS charms](https://charmhub.io/topics/security-with-x-509-certificates) requires Juju 3.x.
1113

1214
## Breaking changes between Juju 2.9.x and 3.x
1315

1416
As this charm documentation is written for Juju 3.x, users of 2.9.x will encounter noteworthy changes when following the instructions. This section explains those changes.
1517

1618
Breaking changes have been introduced in the Juju client between versions 2.9.x and 3.x. These are caused by the renaming and re-purposing of several commands - functionality and command options remain unchanged.
1719

18-
In the context of this guide, the pertinent changes are shown here:
20+
In the context of this guide, the pertinent changes are as follows:
1921

20-
|2.9.x|3.x|
22+
| v2.9.x | v3.x |
2123
| --- | --- |
22-
|**add-relation**|**integrate**|
23-
|**relate**|**integrate**|
24-
|**run**|**exec**|
25-
|**run-action --wait**|**run**|
24+
|`add-relation`|`integrate`|
25+
|`relate`|`integrate`|
26+
|`run`|`exec`|
27+
|`run-action --wait`|`run`|
2628

2729
See the [Juju 3.0 release notes](https://juju.is/docs/juju/roadmap#heading--juju-3-0-0---22-oct-2022) for the comprehensive list of changes.
2830

29-
The response is to therefore substitute the documented command with the equivalent 2.9.x command. For example:
31+
Example substitutions:
3032

3133
### Juju 3.x:
3234
```shell

docs/explanation/e-security.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Security hardening guide
2+
3+
This document provides an overview of security features and guidance for hardening the security of [Charmed PostgreSQL](https://charmhub.io/postgresql) deployments, including setting up and managing a secure environment.
4+
5+
## Environment
6+
7+
The environment where Charmed PostgreSQL operates can be divided into two components:
8+
9+
1. Cloud
10+
2. Juju
11+
12+
### Cloud
13+
14+
Charmed PostgreSQL can be deployed on top of several clouds and virtualization layers:
15+
16+
|Cloud|Security guides|
17+
| --- | --- |
18+
|OpenStack|[OpenStack Security Guide](https://docs.openstack.org/security-guide/)|
19+
|AWS|[Best Practices for Security, Identity and Compliance](https://aws.amazon.com/architecture/security-identity-compliance), [AWS security credentials](https://docs.aws.amazon.com/IAM/latest/UserGuide/security-creds.html#access-keys-and-secret-access-keys)|
20+
|Azure|[Azure security best practices and patterns](https://learn.microsoft.com/en-us/azure/security/fundamentals/best-practices-and-patterns), [Managed identities for Azure resource](https://learn.microsoft.com/en-us/entra/identity/managed-identities-azure-resources/)|
21+
|GCP|[Google security overview](https://cloud.google.com/docs/security)|
22+
23+
### Juju
24+
25+
Juju is the component responsible for orchestrating the entire lifecycle, from deployment to Day 2 operations. For more information on Juju security hardening, see the [Juju security page](https://canonical-juju.readthedocs-hosted.com/en/latest/user/explanation/juju-security/) and the [How to harden your deployment](https://juju.is/docs/juju/harden-your-deployment) guide.
26+
27+
#### Cloud credentials
28+
29+
When configuring cloud credentials to be used with Juju, ensure that users have correct permissions to operate at the required level. Juju superusers responsible for bootstrapping and managing controllers require elevated permissions to manage several kinds of resources, such as virtual machines, networks, storages, etc. Please refer to the links below for more information on the policies required to be used depending on the cloud.
30+
31+
|Cloud|Cloud user policies|
32+
| --- | --- |
33+
|OpenStack|N/A|
34+
|AWS|[Juju AWS Permission](/t/juju-aws-permissions/5307), [AWS Instance Profiles](/t/using-aws-instance-profiles-with-juju-2-9/5185), [Juju on AWS](https://juju.is/docs/juju/amazon-ec2)|
35+
|Azure|[Juju Azure Permission](https://juju.is/docs/juju/microsoft-azure), [How to use Juju with Microsoft Azure](/t/how-to-use-juju-with-microsoft-azure/15219)|
36+
|GCP|[Google Cloud's Identity and Access Management](https://cloud.google.com/iam/docs/overview), [GCE role recommendations](https://cloud.google.com/policy-intelligence/docs/role-recommendations-overview), [Google GCE cloud and Juju](https://canonical-juju.readthedocs-hosted.com/en/latest/user/reference/cloud/list-of-supported-clouds/the-google-gce-cloud-and-juju/)|
37+
38+
#### Juju users
39+
40+
It is very important that Juju users are set up with minimal permissions depending on the scope of their operations. Please refer to the [User access levels](https://juju.is/docs/juju/user-permissions) documentation for more information on the access levels and corresponding abilities.
41+
42+
Juju user credentials must be stored securely and rotated regularly to limit the chances of unauthorized access due to credentials leakage.
43+
44+
## Applications
45+
46+
In the following sections, we provide guidance on how to harden your deployment using:
47+
48+
1. Operating system
49+
2. Security upgrades
50+
3. Encryption
51+
4. Authentication
52+
5. Monitoring and auditing
53+
54+
### Operating system
55+
56+
Charmed PostgreSQL and Charmed PgBouncer run on top of Ubuntu 22.04. Deploy a [Landscape Client Charm](https://charmhub.io/landscape-client?) to connect the underlying VM to a Landscape User Account to manage security upgrades and integrate [Ubuntu Pro](https://ubuntu.com/pro) subscriptions.
57+
58+
### Security upgrades
59+
60+
[Charmed PostgreSQL](https://charmhub.io/postgresql) and [Charmed PgBouncer](https://charmhub.io/pgbouncer) operators install pinned versions of their respective snaps to provide reproducible and secure environments.
61+
62+
New versions (revisions) of the charmed operators can be released to update the operator's code, workloads, or both. It is important to refresh the charms regularly to make sure the workloads are as secure as possible.
63+
64+
For more information on upgrading Charmed PostgreSQL, see the [How to upgrade PostgreSQL](https://canonical.com/data/docs/postgresql/iaas/h-upgrade) and [How to upgrade PgBouncer](https://charmhub.io/pgbouncer/docs/h-upgrade) guides, as well as the respective Release notes for [PostgreSQL](https://canonical.com/data/docs/postgresql/iaas/r-releases) and [PgBouncer](https://charmhub.io/pgbouncer/docs/r-releases).
65+
66+
### Encryption
67+
68+
To utilise encryption at transit for all internal and external cluster connections, integrate Charmed PostgreSQL with a TLS certificate provider. Please refer to the [Charming Security page](https://charmhub.io/topics/security-with-x-509-certificates) for more information on how to select the right certificate provider for your use case.
69+
70+
Encryption in transit for backups is provided by the storage service (Charmed PostgreSQL is a client for an S3-compatible storage).
71+
72+
For more information on encryption, see the [Cryptography](/t/charmed-postgresql-explanations-encryption/16853) explanation page and [How to enable encryption](https://canonical.com/data/docs/postgresql/iaas/h-enable-tls) guide.
73+
74+
### Authentication
75+
76+
Charmed PostgreSQL supports the password-based `scram-sha-256` authentication method for authentication between:
77+
78+
* External connections to clients
79+
* Internal connections between members of cluster
80+
* PgBouncer connections
81+
82+
For more implementation details, see the [PostgreSQL documentation](https://www.postgresql.org/docs/14/auth-password.html).
83+
84+
### Monitoring and auditing
85+
86+
Charmed PostgreSQL provides native integration with the [Canonical Observability Stack (COS)](https://charmhub.io/topics/canonical-observability-stack). To reduce the blast radius of infrastructure disruptions, the general recommendation is to deploy COS and the observed application into separate environments, isolated from one another. Refer to the [COS production deployments best practices](https://charmhub.io/topics/canonical-observability-stack/reference/best-practices) for more information or see the How to guides for PostgreSQL [monitoring](https://canonical.com/data/docs/postgresql/iaas/h-enable-monitoring), [alert rules](https://canonical.com/data/docs/postgresql/iaas/h-enable-alert-rules), and [tracing](https://canonical.com/data/docs/postgresql/iaas/h-enable-tracing) for practical instructions.
87+
88+
PostgreSQL logs are stored in `/var/snap/charmed-postgresql/common/var/log/postgresql` within the postgresql container of each unit. It’s recommended to integrate the charm with [COS](/t/10600), from where the logs can be easily persisted and queried using [Loki](https://charmhub.io/loki-k8s)/[Grafana](https://charmhub.io/grafana).
89+
90+
## Additional Resources
91+
92+
For details on the cryptography used by Charmed PostgreSQL, see the [Cryptography](/t/charmed-postgresql-explanations-encryption/16853) explanation page.

docs/how-to.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# How-to guides
2+
3+
The following guides cover key processes and common tasks for managing and using Charmed PostgreSQL on machines.
4+
5+
## Deployment and setup
6+
7+
The following guides walk you through the details of how to install different cloud services and bootstrap them to Juju:
8+
* [Sunbeam]
9+
* [LXD]
10+
* [MAAS]
11+
* [AWS EC2]
12+
* [GCE]
13+
* [Azure]
14+
* [Multi-availability zones (AZ)][Multi-AZ]
15+
16+
The following guides cover some specific deployment scenarios and architectures:
17+
* [Terraform]
18+
* [Air-gapped]
19+
* [TLS VIP access]
20+
21+
## Usage and maintenance
22+
23+
* [Integrate with another application]
24+
* [External access]
25+
* [Scale replicas]
26+
* [Enable TLS]
27+
* [Enable plugins/extensions]
28+
29+
## Backup and restore
30+
* [Configure S3 AWS]
31+
* [Configure S3 RadosGW]
32+
* [Create a backup]
33+
* [Restore a backup]
34+
* [Manage backup retention]
35+
* [Migrate a cluster]
36+
37+
## Monitoring (COS)
38+
39+
* [Enable monitoring]
40+
* [Enable alert rules]
41+
* [Enable tracing]
42+
43+
## Minor upgrades
44+
* [Perform a minor upgrade]
45+
* [Perform a minor rollback]
46+
47+
## Cross-regional (cluster-cluster) async replication
48+
49+
* [Cross-regional async replication]
50+
* [Set up clusters]
51+
* [Integrate with a client app]
52+
* [Remove or recover a cluster]
53+
* [Enable plugins/extensions]
54+
55+
## Development
56+
57+
This section is aimed at charm developers looking to support PostgreSQL integrations with their charm.
58+
59+
* [Integrate with your charm]
60+
* [Migrate data via pg_dump]
61+
* [Migrate data via backup/restore]
62+
63+
<!--Links-->
64+
65+
[Sunbeam]: /t/15972
66+
[LXD]: /t/11861
67+
[MAAS]: /t/14293
68+
[AWS EC2]: /t/15703
69+
[GCE]: /t/15722
70+
[Azure]: /t/15733
71+
[Multi-AZ]: /t/15749
72+
[Terraform]: /t/14916
73+
[Air-gapped]: /t/15746
74+
[TLS VIP access]: /t/16576
75+
[Integrate with another application]: /t/9687
76+
[External access]: /t/15802
77+
[Scale replicas]: /t/9689
78+
[Enable TLS]: /t/9685
79+
80+
[Configure S3 AWS]: /t/9681
81+
[Configure S3 RadosGW]: /t/10313
82+
[Create a backup]: /t/9683
83+
[Restore a backup]: /t/9693
84+
[Manage backup retention]: /t/14249
85+
[Migrate a cluster]: /t/9691
86+
87+
[Enable monitoring]: /t/10600
88+
[Enable alert rules]: /t/13084
89+
[Enable tracing]: /t/14521
90+
91+
[Perform a minor upgrade]: /t/12089
92+
[Perform a minor rollback]: /t/12090
93+
94+
[Cross-regional async replication]: /t/15412
95+
[Set up clusters]: /t/13991
96+
[Integrate with a client app]: /t/13992
97+
[Remove or recover a cluster]: /t/13994
98+
[Enable plugins/extensions]: /t/10906
99+
100+
[Integrate with your charm]: /t/11865
101+
[Migrate data via pg_dump]: /t/12163
102+
[Migrate data via backup/restore]: /t/12164

docs/how-to/h-deploy-lxd.md

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)