Skip to content

Commit 0c7e2da

Browse files
authored
chore(docs): add workload identity authentication to Google Cloud Platform backup setup (#2200)
1 parent ab25c63 commit 0c7e2da

File tree

1 file changed

+80
-3
lines changed

1 file changed

+80
-3
lines changed

docs/administrator.md

Lines changed: 80 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,81 @@ with `USE_WALG_BACKUP: "true"`.
993993

994994
### Google Cloud Platform setup
995995

996-
To configure the operator on GCP these prerequisites that are needed:
996+
When using GCP, there are two authentication methods to allow the postgres
997+
cluster to access buckets to write WAL-E logs: Workload Identity (recommended)
998+
or using a GCP Service Account Key (legacy).
999+
1000+
#### Workload Identity setup
1001+
1002+
To configure the operator on GCP using Workload Identity these prerequisites are
1003+
needed.
1004+
1005+
* [Workload Identity](https://cloud.google.com/kubernetes-engine/docs/how-to/workload-identity) enabled on the GKE cluster where the operator will be deployed
1006+
* A GCP service account with the proper IAM setup to access the GCS bucket for the WAL-E logs
1007+
* An IAM policy granting the Kubernetes service account the
1008+
`roles/iam.workloadIdentityUser` role on the GCP service account, e.g.:
1009+
```bash
1010+
gcloud iam service-accounts add-iam-policy-binding <GCP_SERVICE_ACCOUNT_NAME>@<GCP_PROJECT_ID>.iam.gserviceaccount.com \
1011+
--role roles/iam.workloadIdentityUser \
1012+
--member "serviceAccount:PROJECT_ID.svc.id.goog[<POSTGRES_OPERATOR_NS>/postgres-pod-custom]"
1013+
```
1014+
1015+
The configuration parameters that we will be using are:
1016+
1017+
* `wal_gs_bucket`
1018+
1019+
1. Create a custom Kubernetes service account to be used by Patroni running on
1020+
the postgres cluster pods, this service account should include an annotation
1021+
with the email address of the Google IAM service account used to communicate
1022+
with the GCS bucket, e.g.
1023+
1024+
```yml
1025+
apiVersion: v1
1026+
kind: ServiceAccount
1027+
metadata:
1028+
name: postgres-pod-custom
1029+
namespace: <POSTGRES_OPERATOR_NS>
1030+
annotations:
1031+
iam.gke.io/gcp-service-account: <GCP_SERVICE_ACCOUNT_NAME>@<GCP_PROJECT_ID>.iam.gserviceaccount.com
1032+
```
1033+
1034+
2. Specify the new custom service account in your [operator paramaters](./reference/operator_parameters.md)
1035+
1036+
If using manual deployment or kustomize, this is done by setting
1037+
`pod_service_account_name` in your configuration file specified in the
1038+
[postgres-operator deployment](../manifests/postgres-operator.yaml#L37)
1039+
1040+
If deploying the operator [using Helm](./quickstart.md#helm-chart), this can
1041+
be specified in the chart's values file, e.g.:
1042+
1043+
```yml
1044+
...
1045+
podServiceAccount:
1046+
name: postgres-pod-custom
1047+
```
1048+
1049+
3. Setup your operator configuration values. Ensure that the operator's configuration
1050+
is set up like the following:
1051+
```yml
1052+
...
1053+
aws_or_gcp:
1054+
# additional_secret_mount: ""
1055+
# additional_secret_mount_path: ""
1056+
# aws_region: eu-central-1
1057+
# kube_iam_role: ""
1058+
# log_s3_bucket: ""
1059+
# wal_s3_bucket: ""
1060+
wal_gs_bucket: "postgres-backups-bucket-28302F2" # name of bucket on where to save the WAL-E logs
1061+
# gcp_credentials: ""
1062+
...
1063+
```
1064+
1065+
Continue to shared steps below.
1066+
1067+
#### GCP Service Account Key setup
1068+
1069+
To configure the operator on GCP using a GCP service account key these
1070+
prerequisites are needed.
9971071

9981072
* A service account with the proper IAM setup to access the GCS bucket for the WAL-E logs
9991073
* The credentials file for the service account.
@@ -1037,7 +1111,10 @@ aws_or_gcp:
10371111
...
10381112
```
10391113

1040-
3. Setup pod environment configmap that instructs the operator to use WAL-G,
1114+
Once you have set up authentication using one of the two methods above, continue
1115+
with the remaining shared steps:
1116+
1117+
1. Setup pod environment configmap that instructs the operator to use WAL-G,
10411118
instead of WAL-E, for backup and restore.
10421119
```yml
10431120
apiVersion: v1
@@ -1052,7 +1129,7 @@ data:
10521129
CLONE_USE_WALG_RESTORE: "true"
10531130
```
10541131

1055-
4. Then provide this configmap in postgres-operator settings:
1132+
2. Then provide this configmap in postgres-operator settings:
10561133
```yml
10571134
...
10581135
# namespaced name of the ConfigMap with environment variables to populate on every pod

0 commit comments

Comments
 (0)