Skip to content

Commit c542800

Browse files
committed
doc: Included description about users and secrets
1 parent a7d4fc3 commit c542800

1 file changed

Lines changed: 52 additions & 3 deletions

File tree

  • doc/content/en/04-administration-guide/10-replication/03-remote-cluster/01-replicateFrom

doc/content/en/04-administration-guide/10-replication/03-remote-cluster/01-replicateFrom/_index.md

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,67 @@ description: This section details the cluster cascading replication.
77

88
The `replicateFrom` feature is explained in the [SGCluster CRD]({{% relref "06-crd-reference/01-sgcluster/#sgclusterspecreplicatefrom" %}}) but here is a practical guide to accomplish the setup.
99

10-
Since `replicateFrom` works through the Patroni [*Standby Cluster* concept](https://patroni.readthedocs.io/en/latest/standby_cluster.html), when using streaming replication, it is required that the main cluster leader member is accessible from the new cluster replica. Based on the DC architecture or k8s Cloud provider, enabling connections to the WAN must be done. Beforehand, consider that the k8s service should be ready to expose the cluster service.
10+
Since `replicateFrom` works through the Patroni [*Standby Cluster* concept](https://patroni.readthedocs.io/en/latest/standby_cluster.html), when using streaming replication, it is required that the main cluster leader member or a simple stand alone Postgres server, is accessible from the new cluster replica. Based on the DC architecture or k8s Cloud provider, enabling connections to the WAN must be done. Beforehand, consider that in k8s a service should be ready to expose the cluster service.
11+
12+
StackGres requires to setup 3 users in the `replicateFrom` spec using the specific keys `superuser`, `replication`, and `authenticator` (that may be the same user in the source server) in order to properly functioning. The 3 (or 2 or 1) users must exists in the main cluster that is being replicated. To create each of those users you can fallow the next commad examples:
13+
14+
* Superuser username:
15+
```
16+
CREATE ROLE postgres;
17+
```
18+
* Superuser password:
19+
```
20+
ALTER ROLE postgres WITH SUPERUSER INHERIT CREATEROLE CREATEDB LOGIN REPLICATION BYPASSRLS PASSWORD '***';
21+
```
22+
* Replication username:
23+
```
24+
CREATE ROLE replicator;
25+
```
26+
* Replication password:
27+
```
28+
ALTER ROLE replicator WITH NOSUPERUSER INHERIT NOCREATEROLE NOCREATEDB LOGIN REPLICATION NOBYPASSRLS PASSWORD '***';
29+
```
30+
* Authenticator username:
31+
```
32+
CREATE ROLE authenticator;
33+
```
34+
* Authenticator password:
35+
```
36+
ALTER ROLE authenticator WITH SUPERUSER INHERIT NOCREATEROLE NOCREATEDB LOGIN NOREPLICATION NOBYPASSRLS PASSWORD '***';
37+
```
38+
39+
> More details can be found in the [CRD reference]({{% relref "06-crd-reference/01-sgcluster/#sgclusterspecconfigurationscredentialsusers"%}})
1140
1241
Once access is granted, the next command can be used to test the connection:
1342

1443
```sh
1544
psql -U <USER> -p 5433 -h <HOST> -d <database>
1645
```
1746

18-
Then, the new Stackgres Cluster will require the credentials for the user that will connect to the main Cluster, the classical way is by using a Postgres user named "replication" or similar. Since credentials are being present here, it should be saved into `secrets`.
47+
Then, the new StackGres Cluster will require the credentials for the users that will connect to the main Cluster. Since credentials are being present here, it should be saved into a `Secret`.
48+
Te next example helps to understand how to create it, using the same names from the example above:
1949

50+
```yaml
51+
apiVersion: v1
52+
data:
53+
authenticator-password: ***
54+
authenticator-username: authenticator
55+
replication-password: ***
56+
replication-username: replicator
57+
superuser-password: ***
58+
superuser-username: postgres
59+
kind: Secret
60+
metadata:
61+
labels:
62+
app: StackGresCluster
63+
stackgres.io/cluster-name: my-db
64+
name: mysecrets-db
65+
namespace: my-namespace
66+
type: Opaque
67+
EOF
68+
```
2069

21-
It the new remote Stackgres deployment, where a new Stackgres Cluster will be created as Standby Leader, equal CRDs are needed after creating it. Create them accordingly as follows:
70+
In the new remote StackGres deployment, where a new StackGres Cluster will be created as Standby Leader, equal CRDs are required before proceed. Create them accordingly as follows:
2271

2372
- Namespace
2473
- StorageClass - Setting up the same storage or better performance is strongly recommended.

0 commit comments

Comments
 (0)