Skip to content

Commit a660d75

Browse files
authored
Add region setting for logical backups to non-AWS storage (zalando#813)
* Add region setting for logical backups to non-AWS storage
1 parent 1ee99b8 commit a660d75

File tree

13 files changed

+25
-1
lines changed

13 files changed

+25
-1
lines changed

charts/postgres-operator/crds/operatorconfigurations.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ spec:
243243
type: string
244244
logical_backup_s3_endpoint:
245245
type: string
246+
logical_backup_s3_region:
247+
type: string
246248
logical_backup_s3_secret_access_key:
247249
type: string
248250
logical_backup_s3_sse:

charts/postgres-operator/values-crd.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ configLogicalBackup:
204204
logical_backup_s3_access_key_id: ""
205205
# S3 bucket to store backup results
206206
logical_backup_s3_bucket: "my-bucket-url"
207+
# S3 region of bucket
208+
logical_backup_s3_region: ""
207209
# S3 endpoint url when not using AWS
208210
logical_backup_s3_endpoint: ""
209211
# S3 Secret Access Key

charts/postgres-operator/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ configLogicalBackup:
195195
logical_backup_s3_access_key_id: ""
196196
# S3 bucket to store backup results
197197
logical_backup_s3_bucket: "my-bucket-url"
198+
# S3 region of bucket
199+
logical_backup_s3_region: ""
198200
# S3 endpoint url when not using AWS
199201
logical_backup_s3_endpoint: ""
200202
# S3 Secret Access Key

docker/logical-backup/dump.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ function aws_upload {
4040

4141
[[ ! -z "$EXPECTED_SIZE" ]] && args+=("--expected-size=$EXPECTED_SIZE")
4242
[[ ! -z "$LOGICAL_BACKUP_S3_ENDPOINT" ]] && args+=("--endpoint-url=$LOGICAL_BACKUP_S3_ENDPOINT")
43+
[[ ! -z "$LOGICAL_BACKUP_S3_REGION" ]] && args+=("--region=$LOGICAL_BACKUP_S3_REGION")
4344
[[ ! -z "$LOGICAL_BACKUP_S3_SSE" ]] && args+=("--sse=$LOGICAL_BACKUP_S3_SSE")
4445

4546
aws s3 cp - "$PATH_TO_BACKUP" "${args[@]//\'/}"

docs/reference/operator_parameters.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,8 +461,11 @@ grouped under the `logical_backup` key.
461461
S3 bucket to store backup results. The bucket has to be present and
462462
accessible by Postgres pods. Default: empty.
463463

464+
* **logical_backup_s3_region**
465+
Specifies the region of the bucket which is required with some non-AWS S3 storage services. The default is empty.
466+
464467
* **logical_backup_s3_endpoint**
465-
When using non-AWS S3 storage, endpoint can be set as a ENV variable.
468+
When using non-AWS S3 storage, endpoint can be set as a ENV variable. The default is empty.
466469

467470
* **logical_backup_s3_sse**
468471
Specify server side encription that S3 storage is using. If empty string

manifests/configmap.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ data:
4040
# logical_backup_docker_image: "registry.opensource.zalan.do/acid/logical-backup"
4141
# logical_backup_s3_access_key_id: ""
4242
# logical_backup_s3_bucket: "my-bucket-url"
43+
# logical_backup_s3_region: ""
4344
# logical_backup_s3_endpoint: ""
4445
# logical_backup_s3_secret_access_key: ""
4546
# logical_backup_s3_sse: "AES256"

manifests/operatorconfiguration.crd.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,8 @@ spec:
219219
type: string
220220
logical_backup_s3_endpoint:
221221
type: string
222+
logical_backup_s3_region:
223+
type: string
222224
logical_backup_s3_secret_access_key:
223225
type: string
224226
logical_backup_s3_sse:

manifests/postgresql-operator-default-configuration.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ configuration:
8888
# logical_backup_s3_access_key_id: ""
8989
logical_backup_s3_bucket: "my-bucket-url"
9090
# logical_backup_s3_endpoint: ""
91+
# logical_backup_s3_region: ""
9192
# logical_backup_s3_secret_access_key: ""
9293
logical_backup_s3_sse: "AES256"
9394
logical_backup_schedule: "30 00 * * *"

pkg/apis/acid.zalan.do/v1/crds.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,9 @@ var OperatorConfigCRDResourceValidation = apiextv1beta1.CustomResourceValidation
909909
"logical_backup_s3_endpoint": {
910910
Type: "string",
911911
},
912+
"logical_backup_s3_region": {
913+
Type: "string",
914+
},
912915
"logical_backup_s3_secret_access_key": {
913916
Type: "string",
914917
},

pkg/apis/acid.zalan.do/v1/operator_configuration_type.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ type OperatorLogicalBackupConfiguration struct {
157157
Schedule string `json:"logical_backup_schedule,omitempty"`
158158
DockerImage string `json:"logical_backup_docker_image,omitempty"`
159159
S3Bucket string `json:"logical_backup_s3_bucket,omitempty"`
160+
S3Region string `json:"logical_backup_s3_region,omitempty"`
160161
S3Endpoint string `json:"logical_backup_s3_endpoint,omitempty"`
161162
S3AccessKeyID string `json:"logical_backup_s3_access_key_id,omitempty"`
162163
S3SecretAccessKey string `json:"logical_backup_s3_secret_access_key,omitempty"`

pkg/cluster/k8sres.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1589,6 +1589,10 @@ func (c *Cluster) generateLogicalBackupPodEnvVars() []v1.EnvVar {
15891589
Name: "LOGICAL_BACKUP_S3_BUCKET",
15901590
Value: c.OpConfig.LogicalBackup.LogicalBackupS3Bucket,
15911591
},
1592+
{
1593+
Name: "LOGICAL_BACKUP_S3_REGION",
1594+
Value: c.OpConfig.LogicalBackup.LogicalBackupS3Region,
1595+
},
15921596
{
15931597
Name: "LOGICAL_BACKUP_S3_ENDPOINT",
15941598
Value: c.OpConfig.LogicalBackup.LogicalBackupS3Endpoint,

pkg/controller/operator_config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ func (c *Controller) importConfigurationFromCRD(fromCRD *acidv1.OperatorConfigur
106106
result.LogicalBackupSchedule = fromCRD.LogicalBackup.Schedule
107107
result.LogicalBackupDockerImage = fromCRD.LogicalBackup.DockerImage
108108
result.LogicalBackupS3Bucket = fromCRD.LogicalBackup.S3Bucket
109+
result.LogicalBackupS3Region = fromCRD.LogicalBackup.S3Region
109110
result.LogicalBackupS3Endpoint = fromCRD.LogicalBackup.S3Endpoint
110111
result.LogicalBackupS3AccessKeyID = fromCRD.LogicalBackup.S3AccessKeyID
111112
result.LogicalBackupS3SecretAccessKey = fromCRD.LogicalBackup.S3SecretAccessKey

pkg/util/config/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ type LogicalBackup struct {
7676
LogicalBackupSchedule string `name:"logical_backup_schedule" default:"30 00 * * *"`
7777
LogicalBackupDockerImage string `name:"logical_backup_docker_image" default:"registry.opensource.zalan.do/acid/logical-backup"`
7878
LogicalBackupS3Bucket string `name:"logical_backup_s3_bucket" default:""`
79+
LogicalBackupS3Region string `name:"logical_backup_s3_region" default:""`
7980
LogicalBackupS3Endpoint string `name:"logical_backup_s3_endpoint" default:""`
8081
LogicalBackupS3AccessKeyID string `name:"logical_backup_s3_access_key_id" default:""`
8182
LogicalBackupS3SecretAccessKey string `name:"logical_backup_s3_secret_access_key" default:""`

0 commit comments

Comments
 (0)