Skip to content

Commit db0d089

Browse files
author
Pavel Tumik
authored
Fix cloning from GCS (zalando#1176)
* Fix clone from gcs * pass google credentials env var if using GS bucket * remove requirement for timezone as GCS returns timestamp in local time to the region it is in * Revert "remove requirement for timezone as GCS returns timestamp in local time to the region it is in" This reverts commit ac4eb35. * update GCS documentation * remove sentence about logical backups * reword pod environment configmap section * fix documentation
1 parent 4f3bb6a commit db0d089

File tree

2 files changed

+50
-4
lines changed

2 files changed

+50
-4
lines changed

docs/administrator.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,32 @@ aws_or_gcp:
686686
...
687687
```
688688

689+
### Setup pod environment configmap
690+
691+
To make postgres-operator work with GCS, use following configmap:
692+
```yml
693+
apiVersion: v1
694+
kind: ConfigMap
695+
metadata:
696+
name: pod-env-overrides
697+
namespace: postgres-operator-system
698+
data:
699+
# Any env variable used by spilo can be added
700+
USE_WALG_BACKUP: "true"
701+
USE_WALG_RESTORE: "true"
702+
CLONE_USE_WALG_RESTORE: "true"
703+
```
704+
This configmap will instruct operator to use WAL-G, instead of WAL-E, for backup and restore.
705+
706+
Then provide this configmap in postgres-operator settings:
707+
```yml
708+
...
709+
# namespaced name of the ConfigMap with environment variables to populate on every pod
710+
pod_environment_configmap: "postgres-operator-system/pod-env-overrides"
711+
...
712+
```
713+
714+
689715
## Sidecars for Postgres clusters
690716

691717
A list of sidecars is added to each cluster created by the operator. The default

pkg/cluster/k8sres.go

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1719,11 +1719,31 @@ func (c *Cluster) generateCloneEnvironment(description *acidv1.CloneDescription)
17191719
msg := "Figure out which S3 bucket to use from env"
17201720
c.logger.Info(msg, description.S3WalPath)
17211721

1722+
if c.OpConfig.WALES3Bucket != "" {
1723+
envs := []v1.EnvVar{
1724+
{
1725+
Name: "CLONE_WAL_S3_BUCKET",
1726+
Value: c.OpConfig.WALES3Bucket,
1727+
},
1728+
}
1729+
result = append(result, envs...)
1730+
} else if c.OpConfig.WALGSBucket != "" {
1731+
envs := []v1.EnvVar{
1732+
{
1733+
Name: "CLONE_WAL_GS_BUCKET",
1734+
Value: c.OpConfig.WALGSBucket,
1735+
},
1736+
{
1737+
Name: "CLONE_GOOGLE_APPLICATION_CREDENTIALS",
1738+
Value: c.OpConfig.GCPCredentials,
1739+
},
1740+
}
1741+
result = append(result, envs...)
1742+
} else {
1743+
c.logger.Error("Cannot figure out S3 or GS bucket. Both are empty.")
1744+
}
1745+
17221746
envs := []v1.EnvVar{
1723-
{
1724-
Name: "CLONE_WAL_S3_BUCKET",
1725-
Value: c.OpConfig.WALES3Bucket,
1726-
},
17271747
{
17281748
Name: "CLONE_WAL_BUCKET_SCOPE_SUFFIX",
17291749
Value: getBucketScopeSuffix(description.UID),

0 commit comments

Comments
 (0)