Skip to content

Commit 168b679

Browse files
sdudoladovSergey Dudoladov
andauthored
add a prefix for the name of a logical backup job (#1287)
* add a prefix for the name of a logical backup job Co-authored-by: Sergey Dudoladov <sergey.dudoladov@zalando.de>
1 parent a215045 commit 168b679

File tree

8 files changed

+30
-19
lines changed

8 files changed

+30
-19
lines changed

charts/postgres-operator/values.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,24 +242,26 @@ configLogicalBackup:
242242
logical_backup_docker_image: "registry.opensource.zalan.do/acid/logical-backup:v.1.6.0"
243243
# path of google cloud service account json file
244244
# logical_backup_google_application_credentials: ""
245-
245+
# prefix for the backup job name
246+
logical_backup_job_prefix: "logical-backup-"
246247
# storage provider - either "s3" or "gcs"
247248
logical_backup_provider: "s3"
248249
# S3 Access Key ID
249250
logical_backup_s3_access_key_id: ""
250251
# S3 bucket to store backup results
251252
logical_backup_s3_bucket: "my-bucket-url"
252-
# S3 region of bucket
253-
logical_backup_s3_region: ""
254253
# S3 endpoint url when not using AWS
255254
logical_backup_s3_endpoint: ""
255+
# S3 region of bucket
256+
logical_backup_s3_region: ""
256257
# S3 Secret Access Key
257258
logical_backup_s3_secret_access_key: ""
258259
# S3 server side encryption
259260
logical_backup_s3_sse: "AES256"
260261
# backup schedule in the cron format
261262
logical_backup_schedule: "30 00 * * *"
262263

264+
263265
# automate creation of human users with teams API service
264266
configTeamsApi:
265267
# team_admin_role will have the rights to grant roles coming from PG manifests

docs/reference/operator_parameters.md

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -551,44 +551,47 @@ These parameters configure a K8s cron job managed by the operator to produce
551551
Postgres logical backups. In the CRD-based configuration those parameters are
552552
grouped under the `logical_backup` key.
553553

554-
* **logical_backup_schedule**
555-
Backup schedule in the cron format. Please take the
556-
[reference schedule format](https://kubernetes.io/docs/tasks/job/automated-tasks-with-cron-jobs/#schedule)
557-
into account. Default: "30 00 \* \* \*"
558-
559554
* **logical_backup_docker_image**
560555
An image for pods of the logical backup job. The [example image](../../docker/logical-backup/Dockerfile)
561556
runs `pg_dumpall` on a replica if possible and uploads compressed results to
562557
an S3 bucket under the key `/spilo/pg_cluster_name/cluster_k8s_uuid/logical_backups`.
563558
The default image is the same image built with the Zalando-internal CI
564559
pipeline. Default: "registry.opensource.zalan.do/acid/logical-backup"
565560

561+
* **logical_backup_google_application_credentials**
562+
Specifies the path of the google cloud service account json file. Default is empty.
563+
564+
* **logical_backup_job_prefix**
565+
The prefix to be prepended to the name of a k8s CronJob running the backups. Beware the prefix counts towards the name length restrictions imposed by k8s. Empty string is a legitimate value. Operator does not do the actual renaming: It simply creates the job with the new prefix. You will have to delete the old cron job manually. Default: "logical-backup-".
566+
566567
* **logical_backup_provider**
567568
Specifies the storage provider to which the backup should be uploaded (`s3` or `gcs`).
568569
Default: "s3"
569570

571+
* **logical_backup_s3_access_key_id**
572+
When set, value will be in AWS_ACCESS_KEY_ID env variable. The Default is empty.
573+
570574
* **logical_backup_s3_bucket**
571575
S3 bucket to store backup results. The bucket has to be present and
572576
accessible by Postgres pods. Default: empty.
573577

578+
* **logical_backup_s3_endpoint**
579+
When using non-AWS S3 storage, endpoint can be set as a ENV variable. The default is empty.
580+
574581
* **logical_backup_s3_region**
575582
Specifies the region of the bucket which is required with some non-AWS S3 storage services. The default is empty.
576583

577-
* **logical_backup_s3_endpoint**
578-
When using non-AWS S3 storage, endpoint can be set as a ENV variable. The default is empty.
584+
* **logical_backup_s3_secret_access_key**
585+
When set, value will be in AWS_SECRET_ACCESS_KEY env variable. The Default is empty.
579586

580587
* **logical_backup_s3_sse**
581588
Specify server side encryption that S3 storage is using. If empty string
582589
is specified, no argument will be passed to `aws s3` command. Default: "AES256".
583590

584-
* **logical_backup_s3_access_key_id**
585-
When set, value will be in AWS_ACCESS_KEY_ID env variable. The Default is empty.
586-
587-
* **logical_backup_s3_secret_access_key**
588-
When set, value will be in AWS_SECRET_ACCESS_KEY env variable. The Default is empty.
589-
590-
* **logical_backup_google_application_credentials**
591-
Specifies the path of the google cloud service account json file. Default is empty.
591+
* **logical_backup_schedule**
592+
Backup schedule in the cron format. Please take the
593+
[reference schedule format](https://kubernetes.io/docs/tasks/job/automated-tasks-with-cron-jobs/#schedule)
594+
into account. Default: "30 00 \* \* \*"
592595

593596
## Debugging the operator
594597

manifests/operatorconfiguration.crd.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,8 @@ spec:
317317
type: string
318318
logical_backup_google_application_credentials:
319319
type: string
320+
logical_backup_job_prefix:
321+
type: string
320322
logical_backup_provider:
321323
type: string
322324
logical_backup_s3_access_key_id:

manifests/postgresql-operator-default-configuration.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ configuration:
117117
logical_backup:
118118
logical_backup_docker_image: "registry.opensource.zalan.do/acid/logical-backup:v.1.6.0"
119119
# logical_backup_google_application_credentials: ""
120+
logical_backup_job_prefix: "logical-backup-"
120121
logical_backup_provider: "s3"
121122
# logical_backup_s3_access_key_id: ""
122123
logical_backup_s3_bucket: "my-bucket-url"

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ type OperatorLogicalBackupConfiguration struct {
196196
S3SecretAccessKey string `json:"logical_backup_s3_secret_access_key,omitempty"`
197197
S3SSE string `json:"logical_backup_s3_sse,omitempty"`
198198
GoogleApplicationCredentials string `json:"logical_backup_google_application_credentials,omitempty"`
199+
JobPrefix string `json:"logical_backup_job_prefix,omitempty"`
199200
}
200201

201202
// OperatorConfigurationData defines the operation config

pkg/cluster/k8sres.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2079,7 +2079,7 @@ func (c *Cluster) generateLogicalBackupPodEnvVars() []v1.EnvVar {
20792079

20802080
// getLogicalBackupJobName returns the name; the job itself may not exists
20812081
func (c *Cluster) getLogicalBackupJobName() (jobName string) {
2082-
return "logical-backup-" + c.clusterName().Name
2082+
return c.OpConfig.LogicalBackupJobPrefix + c.clusterName().Name
20832083
}
20842084

20852085
// Return an array of ownerReferences to make an arbitraty object dependent on

pkg/controller/operator_config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ func (c *Controller) importConfigurationFromCRD(fromCRD *acidv1.OperatorConfigur
154154
result.LogicalBackupS3SecretAccessKey = fromCRD.LogicalBackup.S3SecretAccessKey
155155
result.LogicalBackupS3SSE = fromCRD.LogicalBackup.S3SSE
156156
result.LogicalBackupGoogleApplicationCredentials = fromCRD.LogicalBackup.GoogleApplicationCredentials
157+
result.LogicalBackupJobPrefix = fromCRD.LogicalBackup.JobPrefix
157158

158159
// debug config
159160
result.DebugLogging = fromCRD.OperatorDebug.DebugLogging

pkg/util/config/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ type LogicalBackup struct {
121121
LogicalBackupS3SecretAccessKey string `name:"logical_backup_s3_secret_access_key" default:""`
122122
LogicalBackupS3SSE string `name:"logical_backup_s3_sse" default:""`
123123
LogicalBackupGoogleApplicationCredentials string `name:"logical_backup_google_application_credentials" default:""`
124+
LogicalBackupJobPrefix string `name:"logical_backup_job_prefix" default:"logical-backup-"`
124125
}
125126

126127
// Operator options for connection pooler

0 commit comments

Comments
 (0)