Skip to content

Commit 9d77611

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

18 files changed

+434
-64
lines changed

docs/explanation.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,22 @@
22

33
This section contains pages with more detailed explanations that provide additional context about some of the key concepts behind the PostgreSQL charm:
44

5+
## Core concepts and design
56
* [Architecture]
67
* [Interfaces and endpoints]
7-
* [Connection pooling]
8-
* [Statuses]
9-
* [Users]
10-
* [Logs]
118
* [Juju]
129
* [Legacy charm]
1310

11+
## Operational concepts
12+
* [Users]
13+
* [Logs]
14+
* [Connection pooling]
15+
16+
## Security and hardening
17+
* [Security hardening guide][Security]
18+
* [Cryptography]
19+
20+
## Development
1421
Charm event flowcharts:
1522
* [Charm]
1623
* [Relations]
@@ -20,12 +27,13 @@ Charm event flowcharts:
2027

2128
[Architecture]: /t/11856
2229
[Interfaces and endpoints]: /t/10252
23-
[Statuses]: /t/11855
2430
[Users]: /t/10843
2531
[Logs]: /t/12098
2632
[Juju]: /t/11986
2733
[Legacy charm]: /t/11013
2834
[Connection pooling]: /t/15799
2935
[Charm]: /t/9305
3036
[Relations]: /t/9306
31-
[Backups]: /t/10248
37+
[Backups]: /t/10248
38+
[Security]: /t/16850
39+
[Cryptography]: /t/16851

docs/explanation/e-architecture.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ The rock "charmed-postgresql" also ships list of tools used by charm:
9292

9393
The charm "[PostgreSQL Test App](https://charmhub.io/postgresql-test-app)" is a Canonical test application to validate the charm installation / functionality and perform the basic performance tests.
9494

95+
### GLAuth
96+
97+
GLAuth is a secure, easy-to-use and open-sourced LDAP server which provides capabilities to centrally manage accounts across infrastructures. The charm is available for Kubernetes clouds under the [GLAuth-K8s operator](https://charmhub.io/glauth-k8s) page.
98+
9599
### Grafana
96100

97101
Grafana is an open-source visualization tools that allows to query, visualize, alert on, and visualize metrics from mixed datasources in configurable dashboards for observability. This charms is shipped with its own Grafana dashboard and supports integration with the [Grafana Operator](https://charmhub.io/grafana-k8s) to simplify observability. Please follow [COS Monitoring](/t/10812) setup.

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 K8s.
4+
5+
## Resource checksums
6+
7+
Charmed PostgreSQL K8s and Charmed PgBouncer K8s operators use pinned versions of the respective images ([Charmed PostgreSQL rock](https://github.com/orgs/canonical/packages/container/package/charmed-postgresql) and [PgBouncer rock](https://github.com/canonical/charmed-pgbouncer-rock/pkgs/container/charmed-pgbouncer)) to provide reproducible and secure environments.
8+
9+
The rocks are OCI images derived from the respective snaps. Snaps package their workload 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 K8s and Charmed PgBouncer K8s charms, snaps, and rocks 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 K8s can be used to deploy a secure PostgreSQL cluster on K8s 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 K8s and Charmed PgBouncer K8s 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-security.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Security hardening guide
2+
3+
This document provides an overview of security features and guidance for hardening the security of [Charmed PostgreSQL K8s](https://charmhub.io/postgresql-k8s) deployments, including setting up and managing a secure environment.
4+
5+
## Environment
6+
7+
The environment where Charmed PostgreSQL K8s operates can be divided into two components:
8+
9+
1. Kubernetes
10+
2. Juju
11+
12+
### Kubernetes
13+
14+
Charmed PostgreSQL K8s can be deployed on top of several Kubernetes distributions. The following table provides references for the security documentation for the main supported cloud platforms.
15+
16+
|Cloud|Security guides|
17+
| --- | --- |
18+
|Canonical Kubernetes|[Security overview](https://ubuntu.com/kubernetes/docs/security), [How to secure a cluster](https://ubuntu.com/kubernetes/docs/how-to-security)|
19+
|microK8s|[CIS compliance](https://microk8s.io/docs/cis-compliance), [Cluster hardening guide](https://microk8s.io/docs/how-to-cis-harden)|
20+
|AWS EKS|[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), [Security in EKS](https://docs.aws.amazon.com/eks/latest/userguide/security.html)|
21+
|Azure AKS|[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/), [Security in AKS](https://learn.microsoft.com/en-us/azure/aks/concepts-security)|
22+
|GCP GKE|[Google security overview](https://cloud.google.com/kubernetes-engine/docs/concepts/security-overview), [Harden your cluster’s security](https://cloud.google.com/kubernetes-engine/docs/how-to/hardening-your-cluster)|
23+
24+
### Juju
25+
26+
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.
27+
28+
#### Cloud credentials
29+
30+
When configuring cloud credentials to be used with Juju, ensure that users have the correct permissions to operate at the required level on the Kubernetes cluster. Juju superusers responsible for bootstrapping and managing controllers require elevated permissions to manage several kinds of resources. For this reason, the K8s user for bootstrapping and managing the deployments should have full permissions, such as:
31+
32+
* create, delete, patch, and list:
33+
* namespaces
34+
* services
35+
* deployments
36+
* stateful sets
37+
* pods
38+
* PVCs
39+
40+
In general, it is common practice to run Juju using the admin role of K8s, to have full permissions on the Kubernetes cluster.
41+
42+
#### Juju users
43+
44+
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.
45+
46+
Juju user credentials must be stored securely and rotated regularly to limit the chances of unauthorized access due to credentials leakage.
47+
48+
## Applications
49+
50+
In the following sections, we provide guidance on how to harden your deployment using:
51+
52+
1. Base images
53+
2. Charmed operator security upgrades
54+
3. Encryption
55+
4. Authentication
56+
5. Monitoring and auditing
57+
58+
### Base images
59+
60+
Charmed PostgreSQL K8s and Charmed PgBouncer K8s run on top of rockcraft-based images shipping the PostgreSQL and PgBouncer distribution binaries built by Canonical. These images (rocks) are available in a GitHub registry for [PostgreSQL](https://github.com/canonical/charmed-postgresql-rock/pkgs/container/charmed-postgresql) and [PgBouncer](https://github.com/orgs/canonical/packages/container/package/charmed-pgbouncer) respectively. Both images are based on Ubuntu 22.04.
61+
62+
### Charmed operator security upgrades
63+
64+
[Charmed PostgreSQL K8s](https://charmhub.io/postgresql-k8s) operator and [Charmed PgBouncer K8s](https://charmhub.io/pgbouncer-k8s) operator install pinned versions of their respective rocks to provide reproducible and secure environments.
65+
66+
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.
67+
68+
For more information on upgrading Charmed PostgreSQL K8s, see the [How to upgrade PostgreSQL K8s](https://canonical.com/data/docs/postgresql/k8s/h-upgrade) and [How to upgrade PgBouncer K8s](https://charmhub.io/pgbouncer-k8s/docs/h-upgrade) guides, as well as the respective Release notes for [PostgreSQL](https://canonical.com/data/docs/postgresql/k8s/r-releases) and [PgBouncer](https://charmhub.io/pgbouncer-k8s/docs/r-releases).
69+
70+
### Encryption
71+
72+
To utilise encryption at transit for all internal and external cluster connections, integrate Charmed PostgreSQL K8s and Charmed PgBouncer K8s 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.
73+
74+
Encryption in transit for backups is provided by the storage service (Charmed PostgreSQL K8s is a client for an S3-compatible storage).
75+
76+
For more information on encryption, see the [Cryptography](/t/charmed-postgresql-k8s-explanations-encryption/16851) explanation page and [How to enable encryption](https://canonical.com/data/docs/postgresql/k8s/h-enable-tls) guide.
77+
78+
### Authentication
79+
80+
Charmed PostgreSQL K8s supports the password-based `scram-sha-256` authentication method for authentication between:
81+
82+
* External connections to clients
83+
* Internal connections between members of cluster
84+
* PgBouncer connections
85+
86+
For more implementation details, see the [PostgreSQL documentation](https://www.postgresql.org/docs/14/auth-password.html).
87+
88+
### Monitoring and auditing
89+
90+
Charmed PostgreSQL K8s 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/k8s/h-enable-monitoring), [alert rules](https://canonical.com/data/docs/postgresql/k8s/h-enable-alert-rules), and [tracing](https://canonical.com/data/docs/postgresql/k8s/h-enable-tracing) for practical instructions.
91+
92+
PostgreSQL logs are stored in `/var/log/postgresql` within the postgresql container of each unit. It’s recommended to integrate the charm with [COS](https://canonical.com/data/docs/postgresql/k8s/h-enable-monitoring), from where the logs can be easily persisted and queried using [Loki](https://charmhub.io/loki-k8s)/[Grafana](https://charmhub.io/grafana).
93+
94+
## Additional Resources
95+
96+
For details on the cryptography used by Charmed PostgreSQL K8s, see the [Cryptography](/t/charmed-postgresql-k8s-explanations-encryption/16851) explanation page.

docs/explanation/e-users.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# Charm Users explanations
22

3-
There are two types of users in PostgreSQL:
3+
There are three types of users in PostgreSQL:
44

55
* Internal users (used by charm operator)
6-
* Relation/integration users (used by related applications)
6+
* Relation users (used by related applications)
77
* Extra user roles (if default permissions are not enough)
8+
* Identity users (used when LDAP is enabled)
89

910
<a name="internal-users"></a>
1011
## Internal users explanations:
@@ -75,7 +76,7 @@ unit-postgresql-1:
7576
**Note**: the action `set-password` must be executed on juju leader unit (to update peer relation data with new value).
7677
7778
<a name="relation-users"></a>
78-
## Relation/integration users explanations:
79+
## Relation users explanations:
7980
8081
The operator created a dedicated user for every application related/integrated with database. Those users are removed on the juju relation/integration removal request. However, DB data stays in place and can be reused on re-created relations (using new user credentials):
8182
@@ -102,4 +103,10 @@ postgres=# \du
102103
103104
When an application charm requests a new user through the relation/integration it can specify that the user should have the `admin` role in the `extra-user-roles` field. The `admin` role enables the new user to read and write to all databases (for the `postgres` system database it can only read data) and also to create and delete non-system databases.
104105
105-
**Note**: `extra-user-roles` is supported by modern interface `postgresql_client` only and missing for legacy `pgsql` interface. Read more about the supported charm interfaces [here](/t/10252).
106+
**Note**: `extra-user-roles` is supported by modern interface `postgresql_client` only and missing for legacy `pgsql` interface. Read more about the supported charm interfaces [here](/t/10252).
107+
108+
<a name="identity-users"></a>
109+
## Identity users explanations:
110+
The operator considers Identity users all those that are automatically created when the LDAP integration is enabled, or in other words, the [GLAuth](https://charmhub.io/glauth-k8s) charm is related/integrated.
111+
112+
When synchronized from the LDAP server, these users do not have any permissions by default, so the LDAP group they belonged to must be mapped to a PostgreSQL pre-defined authorization role by using the `ldap_map` configuration option.

docs/how-to.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ The following guides cover key processes and common tasks for managing and using
44

55
## Deployment and setup
66

7-
The following guides walk you through the details of how to install different cloud services and bootstrap them to Juju:
7+
Installation of different cloud services with Juju:
88
* [Canonical K8s]
99
* [MicroK8s]
1010
* [GKE]
1111
* [EKS]
1212
* [AKS]
1313
* [Multi-availability zones (AZ)][Multi-AZ]
1414

15-
The following guides cover some specific deployment scenarios and architectures:
15+
Other deployment scenarios and configurations:
1616
* [Terraform]
1717
* [Air-gapped]
1818

@@ -22,6 +22,7 @@ The following guides cover some specific deployment scenarios and architectures:
2222
* [External access]
2323
* [Scale replicas]
2424
* [Enable TLS]
25+
* [Enable LDAP]
2526
* [Enable plugins/extensions]
2627

2728
## Backup and restore
@@ -34,9 +35,9 @@ The following guides cover some specific deployment scenarios and architectures:
3435

3536
## Monitoring (COS)
3637

37-
* [Enable monitoring]
38-
* [Enable alert rules]
39-
* [Enable tracing]
38+
* [Enable monitoring] with Grafana
39+
* [Enable alert rules] with Prometheus
40+
* [Enable tracing] with Parca
4041

4142
## Minor upgrades
4243
* [Perform a minor upgrade]
@@ -52,7 +53,7 @@ The following guides cover some specific deployment scenarios and architectures:
5253

5354
## Development
5455

55-
This section is aimed at charm developers looking to support PostgreSQL integrations with their charm.
56+
This section is for charm developers looking to support PostgreSQL integrations with their charm.
5657

5758
* [Integrate with your charm]
5859
* [Migrate data via pg_dump]
@@ -73,6 +74,7 @@ This section is aimed at charm developers looking to support PostgreSQL integrat
7374
[External access]: /t/15701
7475
[Scale replicas]: /t/9592
7576
[Enable TLS]: /t/9593
77+
[Enable LDAP]: /t/17189
7678
[Enable plugins/extensions]: /t/10907
7779

7880
[Configure S3 AWS]: /t/9595

docs/how-to/h-async-set-up.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ juju run -m rome db1/leader create-replication
6262
To switchover and use `lisbon` as the primary instead, run
6363

6464
```shell
65-
juju run -m lisbon db2/leader promote-to-primary
65+
juju run -m lisbon db2/leader promote-to-primary scope=cluster
6666
```
6767

6868
## Scale a cluster

docs/how-to/h-deploy-canonical-k8s.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ kubectl get namespaces # to test the credentials
4242

4343
Install Juju and bootstrap the first Juju controller in K8s:
4444
```shell
45-
sudo snap install juju --channel 3.6/candidate
45+
sudo snap install juju --channel 3.6/stable
4646
juju add-k8s ck8s --client --context-name="k8s"
4747
juju bootstrap ck8s
4848
```

docs/how-to/h-deploy.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ juju deploy postgresql-k8s --trust
2525
```
2626
> See also: [`juju deploy` command](https://canonical-juju.readthedocs-hosted.com/en/latest/user/reference/juju-cli/list-of-juju-cli-commands/deploy/)
2727
28-
To deploy with `terraform juju`, follow the guide [How to deploy using Terraform](/t/).
28+
To deploy with `terraform juju`, follow the guide [How to deploy using Terraform].
2929
> See also: [Terraform Provider for Juju documentation](https://canonical-terraform-provider-juju.readthedocs-hosted.com/en/latest/)
3030
3131
If you are not sure where to start or would like a more guided walkthrough for setting up your environment, see the [Charmed PostgreSQL K8s tutorial][Tutorial].
@@ -40,9 +40,9 @@ The guides below go through the steps to install different cloud services and bo
4040

4141
[How to deploy on multiple availability zones (AZ)] demonstrates how to deploy a cluster on a cloud using different AZs for high availability.
4242

43-
## Special deployments
43+
## Special deployment scenarios
4444

45-
These guides cover some specific deployment scenarios and architectures.
45+
These guides cover some specific deployment scenarios and configurations.
4646

4747
### External network access
4848

@@ -67,7 +67,6 @@ The [Cross-regional async replication] guide goes through the steps to set up cl
6767

6868
[How to deploy on multiple availability zones (AZ)]: /t/15678
6969

70-
7170
[How to enable TLS]: /t/9593
7271
[How to connect from outside the local network]: /t/15701
7372

0 commit comments

Comments
 (0)