diff --git a/charts/postgres-operator/values.yaml b/charts/postgres-operator/values.yaml index 39fdb9929..57c3ff33a 100644 --- a/charts/postgres-operator/values.yaml +++ b/charts/postgres-operator/values.yaml @@ -259,6 +259,8 @@ configLogicalBackup: logical_backup_s3_sse: "AES256" # backup schedule in the cron format logical_backup_schedule: "30 00 * * *" + # prefix for the backup job name + logical_backup_job_prefix: "logical-backup-" # automate creation of human users with teams API service configTeamsApi: diff --git a/docs/reference/operator_parameters.md b/docs/reference/operator_parameters.md index 01e5c4039..1e6670b55 100644 --- a/docs/reference/operator_parameters.md +++ b/docs/reference/operator_parameters.md @@ -571,6 +571,9 @@ grouped under the `logical_backup` key. S3 bucket to store backup results. The bucket has to be present and accessible by Postgres pods. Default: empty. +* **logical_backup_job_prefix** + 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: If you change the prefix, you will have to recreate respective CronJobs manually. Default: "logical-backup-". + * **logical_backup_s3_region** Specifies the region of the bucket which is required with some non-AWS S3 storage services. The default is empty. diff --git a/manifests/operatorconfiguration.crd.yaml b/manifests/operatorconfiguration.crd.yaml index 50405a8cc..d115f9d07 100644 --- a/manifests/operatorconfiguration.crd.yaml +++ b/manifests/operatorconfiguration.crd.yaml @@ -334,6 +334,8 @@ spec: logical_backup_schedule: type: string pattern: '^(\d+|\*)(/\d+)?(\s+(\d+|\*)(/\d+)?){4}$' + logical_backup_job_prefix: + type: string debug: type: object properties: diff --git a/manifests/postgresql-operator-default-configuration.yaml b/manifests/postgresql-operator-default-configuration.yaml index 69e53daeb..e4f29aff0 100644 --- a/manifests/postgresql-operator-default-configuration.yaml +++ b/manifests/postgresql-operator-default-configuration.yaml @@ -125,6 +125,7 @@ configuration: # logical_backup_s3_secret_access_key: "" logical_backup_s3_sse: "AES256" logical_backup_schedule: "30 00 * * *" + logical_backup_job_prefix: "logical-backup-" debug: debug_logging: true enable_database_access: true diff --git a/pkg/apis/acid.zalan.do/v1/operator_configuration_type.go b/pkg/apis/acid.zalan.do/v1/operator_configuration_type.go index 9e5d01040..b55bfa492 100644 --- a/pkg/apis/acid.zalan.do/v1/operator_configuration_type.go +++ b/pkg/apis/acid.zalan.do/v1/operator_configuration_type.go @@ -196,6 +196,7 @@ type OperatorLogicalBackupConfiguration struct { S3SecretAccessKey string `json:"logical_backup_s3_secret_access_key,omitempty"` S3SSE string `json:"logical_backup_s3_sse,omitempty"` GoogleApplicationCredentials string `json:"logical_backup_google_application_credentials,omitempty"` + JobPrefix string `json:"logical_backup_job_prefix,omitempty"` } // OperatorConfigurationData defines the operation config diff --git a/pkg/cluster/k8sres.go b/pkg/cluster/k8sres.go index 6b47b37f6..6b1af045f 100644 --- a/pkg/cluster/k8sres.go +++ b/pkg/cluster/k8sres.go @@ -2079,7 +2079,7 @@ func (c *Cluster) generateLogicalBackupPodEnvVars() []v1.EnvVar { // getLogicalBackupJobName returns the name; the job itself may not exists func (c *Cluster) getLogicalBackupJobName() (jobName string) { - return "logical-backup-" + c.clusterName().Name + return c.OpConfig.LogicalBackupJobPrefix + c.clusterName().Name } // Return an array of ownerReferences to make an arbitraty object dependent on diff --git a/pkg/controller/operator_config.go b/pkg/controller/operator_config.go index a55dab2d8..faf1a4908 100644 --- a/pkg/controller/operator_config.go +++ b/pkg/controller/operator_config.go @@ -154,6 +154,7 @@ func (c *Controller) importConfigurationFromCRD(fromCRD *acidv1.OperatorConfigur result.LogicalBackupS3SecretAccessKey = fromCRD.LogicalBackup.S3SecretAccessKey result.LogicalBackupS3SSE = fromCRD.LogicalBackup.S3SSE result.LogicalBackupGoogleApplicationCredentials = fromCRD.LogicalBackup.GoogleApplicationCredentials + result.LogicalBackupJobPrefix = fromCRD.LogicalBackup.JobPrefix // debug config result.DebugLogging = fromCRD.OperatorDebug.DebugLogging diff --git a/pkg/util/config/config.go b/pkg/util/config/config.go index 62cfdec57..142aa2be9 100644 --- a/pkg/util/config/config.go +++ b/pkg/util/config/config.go @@ -121,6 +121,7 @@ type LogicalBackup struct { LogicalBackupS3SecretAccessKey string `name:"logical_backup_s3_secret_access_key" default:""` LogicalBackupS3SSE string `name:"logical_backup_s3_sse" default:""` LogicalBackupGoogleApplicationCredentials string `name:"logical_backup_google_application_credentials" default:""` + LogicalBackupJobPrefix string `name:"logical_backup_job_prefix" default:"logical-backup-"` } // Operator options for connection pooler