configurable resources for logical backup pod template (#710)
* new config options to specify resources for logical backup jobs * bug in logical backup script for s3 dumps * define enum for logical_backup_provider * changed order of logical backup azure options * fix unit test for stream comparison
This commit is contained in:
parent
bbc0de3ffd
commit
29cec0ceda
|
|
@ -469,6 +469,18 @@ spec:
|
||||||
logical_backup:
|
logical_backup:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
|
logical_backup_azure_storage_account_name:
|
||||||
|
type: string
|
||||||
|
logical_backup_azure_storage_container:
|
||||||
|
type: string
|
||||||
|
logical_backup_azure_storage_account_key:
|
||||||
|
type: string
|
||||||
|
logical_backup_cpu_limit:
|
||||||
|
type: string
|
||||||
|
pattern: '^(\d+m|\d+(\.\d{1,3})?)$'
|
||||||
|
logical_backup_cpu_request:
|
||||||
|
type: string
|
||||||
|
pattern: '^(\d+m|\d+(\.\d{1,3})?)$'
|
||||||
logical_backup_docker_image:
|
logical_backup_docker_image:
|
||||||
type: string
|
type: string
|
||||||
default: "registry.opensource.zalan.do/acid/logical-backup:v1.8.2"
|
default: "registry.opensource.zalan.do/acid/logical-backup:v1.8.2"
|
||||||
|
|
@ -477,8 +489,18 @@ spec:
|
||||||
logical_backup_job_prefix:
|
logical_backup_job_prefix:
|
||||||
type: string
|
type: string
|
||||||
default: "logical-backup-"
|
default: "logical-backup-"
|
||||||
|
logical_backup_memory_limit:
|
||||||
|
type: string
|
||||||
|
pattern: '^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$'
|
||||||
|
logical_backup_memory_request:
|
||||||
|
type: string
|
||||||
|
pattern: '^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$'
|
||||||
logical_backup_provider:
|
logical_backup_provider:
|
||||||
type: string
|
type: string
|
||||||
|
enum:
|
||||||
|
- "az"
|
||||||
|
- "gcs"
|
||||||
|
- "s3"
|
||||||
default: "s3"
|
default: "s3"
|
||||||
logical_backup_s3_access_key_id:
|
logical_backup_s3_access_key_id:
|
||||||
type: string
|
type: string
|
||||||
|
|
@ -498,12 +520,6 @@ spec:
|
||||||
type: string
|
type: string
|
||||||
pattern: '^(\d+|\*)(/\d+)?(\s+(\d+|\*)(/\d+)?){4}$'
|
pattern: '^(\d+|\*)(/\d+)?(\s+(\d+|\*)(/\d+)?){4}$'
|
||||||
default: "30 00 * * *"
|
default: "30 00 * * *"
|
||||||
logical_backup_azure_storage_account_name:
|
|
||||||
type: string
|
|
||||||
logical_backup_azure_storage_container:
|
|
||||||
type: string
|
|
||||||
logical_backup_azure_storage_account_key:
|
|
||||||
type: string
|
|
||||||
debug:
|
debug:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
|
|
|
||||||
|
|
@ -332,6 +332,17 @@ configAwsOrGcp:
|
||||||
|
|
||||||
# configure K8s cron job managed by the operator
|
# configure K8s cron job managed by the operator
|
||||||
configLogicalBackup:
|
configLogicalBackup:
|
||||||
|
# Azure Storage Account specs to store backup results
|
||||||
|
# logical_backup_azure_storage_account_name: ""
|
||||||
|
# logical_backup_azure_storage_container: ""
|
||||||
|
# logical_backup_azure_storage_account_key: ""
|
||||||
|
|
||||||
|
# resources for logical backup pod, if empty configPostgresPodResources will be used
|
||||||
|
# logical_backup_cpu_limit: ""
|
||||||
|
# logical_backup_cpu_request: ""
|
||||||
|
# logical_backup_memory_limit: ""
|
||||||
|
# logical_backup_memory_request: ""
|
||||||
|
|
||||||
# image for pods of the logical backup job (example runs pg_dumpall)
|
# image for pods of the logical backup job (example runs pg_dumpall)
|
||||||
logical_backup_docker_image: "registry.opensource.zalan.do/acid/logical-backup:v1.8.0"
|
logical_backup_docker_image: "registry.opensource.zalan.do/acid/logical-backup:v1.8.0"
|
||||||
# path of google cloud service account json file
|
# path of google cloud service account json file
|
||||||
|
|
@ -339,7 +350,7 @@ configLogicalBackup:
|
||||||
|
|
||||||
# prefix for the backup job name
|
# prefix for the backup job name
|
||||||
logical_backup_job_prefix: "logical-backup-"
|
logical_backup_job_prefix: "logical-backup-"
|
||||||
# storage provider - either "s3" or "gcs"
|
# storage provider - either "s3", "gcs" or "az"
|
||||||
logical_backup_provider: "s3"
|
logical_backup_provider: "s3"
|
||||||
# S3 Access Key ID
|
# S3 Access Key ID
|
||||||
logical_backup_s3_access_key_id: ""
|
logical_backup_s3_access_key_id: ""
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,7 @@ function upload {
|
||||||
"gcs")
|
"gcs")
|
||||||
gcs_upload
|
gcs_upload
|
||||||
;;
|
;;
|
||||||
"aws")
|
"s3")
|
||||||
aws_upload $(($(estimate_size) / DUMP_SIZE_COEFF))
|
aws_upload $(($(estimate_size) / DUMP_SIZE_COEFF))
|
||||||
aws_delete_outdated
|
aws_delete_outdated
|
||||||
;;
|
;;
|
||||||
|
|
|
||||||
|
|
@ -1201,6 +1201,10 @@ of the backup cron job.
|
||||||
`cronjobs` resource from the `batch` API group for the operator service account.
|
`cronjobs` resource from the `batch` API group for the operator service account.
|
||||||
See [example RBAC](https://github.com/zalando/postgres-operator/blob/master/manifests/operator-service-account-rbac.yaml)
|
See [example RBAC](https://github.com/zalando/postgres-operator/blob/master/manifests/operator-service-account-rbac.yaml)
|
||||||
|
|
||||||
|
7. Resources of the pod template in the cron job can be configured. When left
|
||||||
|
empty [default values of spilo pods](reference/operator_parameters.md#kubernetes-resource-requests)
|
||||||
|
will be used.
|
||||||
|
|
||||||
## Sidecars for Postgres clusters
|
## Sidecars for Postgres clusters
|
||||||
|
|
||||||
A list of sidecars is added to each cluster created by the operator. The default
|
A list of sidecars is added to each cluster created by the operator. The default
|
||||||
|
|
|
||||||
|
|
@ -718,6 +718,13 @@ These parameters configure a K8s cron job managed by the operator to produce
|
||||||
Postgres logical backups. In the CRD-based configuration those parameters are
|
Postgres logical backups. In the CRD-based configuration those parameters are
|
||||||
grouped under the `logical_backup` key.
|
grouped under the `logical_backup` key.
|
||||||
|
|
||||||
|
* **logical_backup_cpu_limit**
|
||||||
|
**logical_backup_cpu_request**
|
||||||
|
**logical_backup_memory_limit**
|
||||||
|
**logical_backup_memory_request**
|
||||||
|
Resource configuration for pod template in logical backup cron job. If empty
|
||||||
|
default values from `postgres_pod_resources` will be used.
|
||||||
|
|
||||||
* **logical_backup_docker_image**
|
* **logical_backup_docker_image**
|
||||||
An image for pods of the logical backup job. The [example image](https://github.com/zalando/postgres-operator/blob/master/docker/logical-backup/Dockerfile)
|
An image for pods of the logical backup job. The [example image](https://github.com/zalando/postgres-operator/blob/master/docker/logical-backup/Dockerfile)
|
||||||
runs `pg_dumpall` on a replica if possible and uploads compressed results to
|
runs `pg_dumpall` on a replica if possible and uploads compressed results to
|
||||||
|
|
@ -732,8 +739,17 @@ grouped under the `logical_backup` key.
|
||||||
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-".
|
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-".
|
||||||
|
|
||||||
* **logical_backup_provider**
|
* **logical_backup_provider**
|
||||||
Specifies the storage provider to which the backup should be uploaded (`s3` or `gcs`).
|
Specifies the storage provider to which the backup should be uploaded
|
||||||
Default: "s3"
|
(`s3`, `gcs` or `az`). Default: "s3"
|
||||||
|
|
||||||
|
* **logical_backup_azure_storage_account_name**
|
||||||
|
Storage account name used to upload logical backups to when using Azure. Default: ""
|
||||||
|
|
||||||
|
* **logical_backup_azure_storage_container**
|
||||||
|
Storage container used to upload logical backups to when using Azure. Default: ""
|
||||||
|
|
||||||
|
* **logical_backup_azure_storage_account_key**
|
||||||
|
Storage account key used to authenticate with Azure when uploading logical backups. Default: ""
|
||||||
|
|
||||||
* **logical_backup_s3_access_key_id**
|
* **logical_backup_s3_access_key_id**
|
||||||
When set, value will be in AWS_ACCESS_KEY_ID env variable. The Default is empty.
|
When set, value will be in AWS_ACCESS_KEY_ID env variable. The Default is empty.
|
||||||
|
|
@ -765,15 +781,6 @@ grouped under the `logical_backup` key.
|
||||||
[reference schedule format](https://kubernetes.io/docs/tasks/job/automated-tasks-with-cron-jobs/#schedule)
|
[reference schedule format](https://kubernetes.io/docs/tasks/job/automated-tasks-with-cron-jobs/#schedule)
|
||||||
into account. Default: "30 00 \* \* \*"
|
into account. Default: "30 00 \* \* \*"
|
||||||
|
|
||||||
* **logical_backup_azure_storage_account_name**
|
|
||||||
Storage account name used to upload logical backups to when using Azure. Default: ""
|
|
||||||
|
|
||||||
* **logical_backup_azure_storage_container**
|
|
||||||
Storage container used to upload logical backups to when using Azure. Default: ""
|
|
||||||
|
|
||||||
* **logical_backup_azure_storage_account_key**
|
|
||||||
Storage account key used to authenticate with Azure when uploading logical backups. Default: ""
|
|
||||||
|
|
||||||
## Debugging the operator
|
## Debugging the operator
|
||||||
|
|
||||||
Options to aid debugging of the operator itself. Grouped under the `debug` key.
|
Options to aid debugging of the operator itself. Grouped under the `debug` key.
|
||||||
|
|
|
||||||
|
|
@ -75,9 +75,16 @@ data:
|
||||||
# kube_iam_role: ""
|
# kube_iam_role: ""
|
||||||
# kubernetes_use_configmaps: "false"
|
# kubernetes_use_configmaps: "false"
|
||||||
# log_s3_bucket: ""
|
# log_s3_bucket: ""
|
||||||
|
# logical_backup_azure_storage_account_name: ""
|
||||||
|
# logical_backup_azure_storage_container: ""
|
||||||
|
# logical_backup_azure_storage_account_key: ""
|
||||||
|
# logical_backup_cpu_limit: ""
|
||||||
|
# logical_backup_cpu_request: ""
|
||||||
logical_backup_docker_image: "registry.opensource.zalan.do/acid/logical-backup:v1.8.2"
|
logical_backup_docker_image: "registry.opensource.zalan.do/acid/logical-backup:v1.8.2"
|
||||||
# logical_backup_google_application_credentials: ""
|
# logical_backup_google_application_credentials: ""
|
||||||
logical_backup_job_prefix: "logical-backup-"
|
logical_backup_job_prefix: "logical-backup-"
|
||||||
|
# logical_backup_memory_limit: ""
|
||||||
|
# logical_backup_memory_request: ""
|
||||||
logical_backup_provider: "s3"
|
logical_backup_provider: "s3"
|
||||||
# logical_backup_s3_access_key_id: ""
|
# logical_backup_s3_access_key_id: ""
|
||||||
logical_backup_s3_bucket: "my-bucket-url"
|
logical_backup_s3_bucket: "my-bucket-url"
|
||||||
|
|
@ -87,9 +94,6 @@ data:
|
||||||
logical_backup_s3_sse: "AES256"
|
logical_backup_s3_sse: "AES256"
|
||||||
# logical_backup_s3_retention_time: ""
|
# logical_backup_s3_retention_time: ""
|
||||||
logical_backup_schedule: "30 00 * * *"
|
logical_backup_schedule: "30 00 * * *"
|
||||||
# logical_backup_azure_storage_account_name: ""
|
|
||||||
# logical_backup_azure_storage_container: ""
|
|
||||||
# logical_backup_azure_storage_account_key: ""
|
|
||||||
major_version_upgrade_mode: "manual"
|
major_version_upgrade_mode: "manual"
|
||||||
# major_version_upgrade_team_allow_list: ""
|
# major_version_upgrade_team_allow_list: ""
|
||||||
master_dns_name_format: "{cluster}.{namespace}.{hostedzone}"
|
master_dns_name_format: "{cluster}.{namespace}.{hostedzone}"
|
||||||
|
|
|
||||||
|
|
@ -467,6 +467,18 @@ spec:
|
||||||
logical_backup:
|
logical_backup:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
|
logical_backup_azure_storage_account_name:
|
||||||
|
type: string
|
||||||
|
logical_backup_azure_storage_container:
|
||||||
|
type: string
|
||||||
|
logical_backup_azure_storage_account_key:
|
||||||
|
type: string
|
||||||
|
logical_backup_cpu_limit:
|
||||||
|
type: string
|
||||||
|
pattern: '^(\d+m|\d+(\.\d{1,3})?)$'
|
||||||
|
logical_backup_cpu_request:
|
||||||
|
type: string
|
||||||
|
pattern: '^(\d+m|\d+(\.\d{1,3})?)$'
|
||||||
logical_backup_docker_image:
|
logical_backup_docker_image:
|
||||||
type: string
|
type: string
|
||||||
default: "registry.opensource.zalan.do/acid/logical-backup:v1.8.2"
|
default: "registry.opensource.zalan.do/acid/logical-backup:v1.8.2"
|
||||||
|
|
@ -475,8 +487,18 @@ spec:
|
||||||
logical_backup_job_prefix:
|
logical_backup_job_prefix:
|
||||||
type: string
|
type: string
|
||||||
default: "logical-backup-"
|
default: "logical-backup-"
|
||||||
|
logical_backup_memory_limit:
|
||||||
|
type: string
|
||||||
|
pattern: '^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$'
|
||||||
|
logical_backup_memory_request:
|
||||||
|
type: string
|
||||||
|
pattern: '^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$'
|
||||||
logical_backup_provider:
|
logical_backup_provider:
|
||||||
type: string
|
type: string
|
||||||
|
enum:
|
||||||
|
- "az"
|
||||||
|
- "gcs"
|
||||||
|
- "s3"
|
||||||
default: "s3"
|
default: "s3"
|
||||||
logical_backup_s3_access_key_id:
|
logical_backup_s3_access_key_id:
|
||||||
type: string
|
type: string
|
||||||
|
|
@ -496,12 +518,6 @@ spec:
|
||||||
type: string
|
type: string
|
||||||
pattern: '^(\d+|\*)(/\d+)?(\s+(\d+|\*)(/\d+)?){4}$'
|
pattern: '^(\d+|\*)(/\d+)?(\s+(\d+|\*)(/\d+)?){4}$'
|
||||||
default: "30 00 * * *"
|
default: "30 00 * * *"
|
||||||
logical_backup_azure_storage_account_name:
|
|
||||||
type: string
|
|
||||||
logical_backup_azure_storage_container:
|
|
||||||
type: string
|
|
||||||
logical_backup_azure_storage_account_key:
|
|
||||||
type: string
|
|
||||||
debug:
|
debug:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
|
|
|
||||||
|
|
@ -151,6 +151,13 @@ configuration:
|
||||||
# wal_gs_bucket: ""
|
# wal_gs_bucket: ""
|
||||||
# wal_s3_bucket: ""
|
# wal_s3_bucket: ""
|
||||||
logical_backup:
|
logical_backup:
|
||||||
|
# logical_backup_azure_storage_account_name: ""
|
||||||
|
# logical_backup_azure_storage_container: ""
|
||||||
|
# logical_backup_azure_storage_account_key: ""
|
||||||
|
# logical_backup_cpu_limit: ""
|
||||||
|
# logical_backup_cpu_request: ""
|
||||||
|
# logical_backup_memory_limit: ""
|
||||||
|
# logical_backup_memory_request: ""
|
||||||
logical_backup_docker_image: "registry.opensource.zalan.do/acid/logical-backup:v1.8.2"
|
logical_backup_docker_image: "registry.opensource.zalan.do/acid/logical-backup:v1.8.2"
|
||||||
# logical_backup_google_application_credentials: ""
|
# logical_backup_google_application_credentials: ""
|
||||||
logical_backup_job_prefix: "logical-backup-"
|
logical_backup_job_prefix: "logical-backup-"
|
||||||
|
|
@ -163,9 +170,6 @@ configuration:
|
||||||
logical_backup_s3_sse: "AES256"
|
logical_backup_s3_sse: "AES256"
|
||||||
# logical_backup_s3_retention_time: ""
|
# logical_backup_s3_retention_time: ""
|
||||||
logical_backup_schedule: "30 00 * * *"
|
logical_backup_schedule: "30 00 * * *"
|
||||||
# logical_backup_azure_storage_account_name: ""
|
|
||||||
# logical_backup_azure_storage_container: ""
|
|
||||||
# logical_backup_azure_storage_account_key: ""
|
|
||||||
debug:
|
debug:
|
||||||
debug_logging: true
|
debug_logging: true
|
||||||
enable_database_access: true
|
enable_database_access: true
|
||||||
|
|
|
||||||
|
|
@ -1618,6 +1618,23 @@ var OperatorConfigCRDResourceValidation = apiextv1.CustomResourceValidation{
|
||||||
"logical_backup": {
|
"logical_backup": {
|
||||||
Type: "object",
|
Type: "object",
|
||||||
Properties: map[string]apiextv1.JSONSchemaProps{
|
Properties: map[string]apiextv1.JSONSchemaProps{
|
||||||
|
"logical_backup_azure_storage_account_name": {
|
||||||
|
Type: "string",
|
||||||
|
},
|
||||||
|
"logical_backup_azure_storage_container": {
|
||||||
|
Type: "string",
|
||||||
|
},
|
||||||
|
"logical_backup_azure_storage_account_key": {
|
||||||
|
Type: "string",
|
||||||
|
},
|
||||||
|
"logical_backup_cpu_limit": {
|
||||||
|
Type: "string",
|
||||||
|
Pattern: "^(\\d+m|\\d+(\\.\\d{1,3})?)$",
|
||||||
|
},
|
||||||
|
"logical_backup_cpu_request": {
|
||||||
|
Type: "string",
|
||||||
|
Pattern: "^(\\d+m|\\d+(\\.\\d{1,3})?)$",
|
||||||
|
},
|
||||||
"logical_backup_docker_image": {
|
"logical_backup_docker_image": {
|
||||||
Type: "string",
|
Type: "string",
|
||||||
},
|
},
|
||||||
|
|
@ -1627,8 +1644,27 @@ var OperatorConfigCRDResourceValidation = apiextv1.CustomResourceValidation{
|
||||||
"logical_backup_job_prefix": {
|
"logical_backup_job_prefix": {
|
||||||
Type: "string",
|
Type: "string",
|
||||||
},
|
},
|
||||||
|
"logical_backup_memory_limit": {
|
||||||
|
Type: "string",
|
||||||
|
Pattern: "^(\\d+(e\\d+)?|\\d+(\\.\\d+)?(e\\d+)?[EPTGMK]i?)$",
|
||||||
|
},
|
||||||
|
"logical_backup_memory_request": {
|
||||||
|
Type: "string",
|
||||||
|
Pattern: "^(\\d+(e\\d+)?|\\d+(\\.\\d+)?(e\\d+)?[EPTGMK]i?)$",
|
||||||
|
},
|
||||||
"logical_backup_provider": {
|
"logical_backup_provider": {
|
||||||
Type: "string",
|
Type: "string",
|
||||||
|
Enum: []apiextv1.JSON{
|
||||||
|
{
|
||||||
|
Raw: []byte(`"az"`),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Raw: []byte(`"gcs"`),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Raw: []byte(`"s3"`),
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
"logical_backup_s3_access_key_id": {
|
"logical_backup_s3_access_key_id": {
|
||||||
Type: "string",
|
Type: "string",
|
||||||
|
|
@ -1655,15 +1691,6 @@ var OperatorConfigCRDResourceValidation = apiextv1.CustomResourceValidation{
|
||||||
Type: "string",
|
Type: "string",
|
||||||
Pattern: "^(\\d+|\\*)(/\\d+)?(\\s+(\\d+|\\*)(/\\d+)?){4}$",
|
Pattern: "^(\\d+|\\*)(/\\d+)?(\\s+(\\d+|\\*)(/\\d+)?){4}$",
|
||||||
},
|
},
|
||||||
"logical_backup_azure_storage_account_name": {
|
|
||||||
Type: "string",
|
|
||||||
},
|
|
||||||
"logical_backup_azure_storage_container": {
|
|
||||||
Type: "string",
|
|
||||||
},
|
|
||||||
"logical_backup_azure_storage_account_key": {
|
|
||||||
Type: "string",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"debug": {
|
"debug": {
|
||||||
|
|
|
||||||
|
|
@ -218,6 +218,9 @@ type OperatorLogicalBackupConfiguration struct {
|
||||||
Schedule string `json:"logical_backup_schedule,omitempty"`
|
Schedule string `json:"logical_backup_schedule,omitempty"`
|
||||||
DockerImage string `json:"logical_backup_docker_image,omitempty"`
|
DockerImage string `json:"logical_backup_docker_image,omitempty"`
|
||||||
BackupProvider string `json:"logical_backup_provider,omitempty"`
|
BackupProvider string `json:"logical_backup_provider,omitempty"`
|
||||||
|
AzureStorageAccountName string `json:"logical_backup_azure_storage_account_name,omitempty"`
|
||||||
|
AzureStorageContainer string `json:"logical_backup_azure_storage_container,omitempty"`
|
||||||
|
AzureStorageAccountKey string `json:"logical_backup_azure_storage_account_key,omitempty"`
|
||||||
S3Bucket string `json:"logical_backup_s3_bucket,omitempty"`
|
S3Bucket string `json:"logical_backup_s3_bucket,omitempty"`
|
||||||
S3Region string `json:"logical_backup_s3_region,omitempty"`
|
S3Region string `json:"logical_backup_s3_region,omitempty"`
|
||||||
S3Endpoint string `json:"logical_backup_s3_endpoint,omitempty"`
|
S3Endpoint string `json:"logical_backup_s3_endpoint,omitempty"`
|
||||||
|
|
@ -227,9 +230,10 @@ type OperatorLogicalBackupConfiguration struct {
|
||||||
RetentionTime string `json:"logical_backup_s3_retention_time,omitempty"`
|
RetentionTime string `json:"logical_backup_s3_retention_time,omitempty"`
|
||||||
GoogleApplicationCredentials string `json:"logical_backup_google_application_credentials,omitempty"`
|
GoogleApplicationCredentials string `json:"logical_backup_google_application_credentials,omitempty"`
|
||||||
JobPrefix string `json:"logical_backup_job_prefix,omitempty"`
|
JobPrefix string `json:"logical_backup_job_prefix,omitempty"`
|
||||||
AzureStorageAccountName string `json:"logical_backup_azure_storage_account_name,omitempty"`
|
CPURequest string `json:"logical_backup_cpu_request,omitempty"`
|
||||||
AzureStorageContainer string `json:"logical_backup_azure_storage_container,omitempty"`
|
MemoryRequest string `json:"logical_backup_memory_request,omitempty"`
|
||||||
AzureStorageAccountKey string `json:"logical_backup_azure_storage_account_key,omitempty"`
|
CPULimit string `json:"logical_backup_cpu_limit,omitempty"`
|
||||||
|
MemoryLimit string `json:"logical_backup_memory_limit,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// PatroniConfiguration defines configuration for Patroni
|
// PatroniConfiguration defines configuration for Patroni
|
||||||
|
|
|
||||||
|
|
@ -139,6 +139,23 @@ func makeDefaultResources(config *config.Config) acidv1.Resources {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func makeLogicalBackupResources(config *config.Config) acidv1.Resources {
|
||||||
|
|
||||||
|
logicalBackupResourceRequests := acidv1.ResourceDescription{
|
||||||
|
CPU: config.LogicalBackup.LogicalBackupCPURequest,
|
||||||
|
Memory: config.LogicalBackup.LogicalBackupMemoryRequest,
|
||||||
|
}
|
||||||
|
logicalBackupResourceLimits := acidv1.ResourceDescription{
|
||||||
|
CPU: config.LogicalBackup.LogicalBackupCPULimit,
|
||||||
|
Memory: config.LogicalBackup.LogicalBackupMemoryLimit,
|
||||||
|
}
|
||||||
|
|
||||||
|
return acidv1.Resources{
|
||||||
|
ResourceRequests: logicalBackupResourceRequests,
|
||||||
|
ResourceLimits: logicalBackupResourceLimits,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Cluster) enforceMinResourceLimits(resources *v1.ResourceRequirements) error {
|
func (c *Cluster) enforceMinResourceLimits(resources *v1.ResourceRequirements) error {
|
||||||
var (
|
var (
|
||||||
isSmaller bool
|
isSmaller bool
|
||||||
|
|
@ -2107,9 +2124,12 @@ func (c *Cluster) generateLogicalBackupJob() (*batchv1.CronJob, error) {
|
||||||
|
|
||||||
c.logger.Debug("Generating logical backup pod template")
|
c.logger.Debug("Generating logical backup pod template")
|
||||||
|
|
||||||
// allocate for the backup pod the same amount of resources as for normal DB pods
|
// allocate configured resources for logical backup pod
|
||||||
|
logicalBackupResources := makeLogicalBackupResources(&c.OpConfig)
|
||||||
|
// if not defined only default resources from spilo pods are used
|
||||||
resourceRequirements, err = c.generateResourceRequirements(
|
resourceRequirements, err = c.generateResourceRequirements(
|
||||||
c.Spec.Resources, makeDefaultResources(&c.OpConfig), logicalBackupContainerName)
|
&logicalBackupResources, makeDefaultResources(&c.OpConfig), logicalBackupContainerName)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("could not generate resource requirements for logical backup pods: %v", err)
|
return nil, fmt.Errorf("could not generate resource requirements for logical backup pods: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2638,7 +2638,6 @@ func TestGenerateResourceRequirements(t *testing.T) {
|
||||||
clusterName := "acid-test-cluster"
|
clusterName := "acid-test-cluster"
|
||||||
namespace := "default"
|
namespace := "default"
|
||||||
clusterNameLabel := "cluster-name"
|
clusterNameLabel := "cluster-name"
|
||||||
roleLabel := "spilo-role"
|
|
||||||
sidecarName := "postgres-exporter"
|
sidecarName := "postgres-exporter"
|
||||||
|
|
||||||
// enforceMinResourceLimits will be called 2 twice emitting 4 events (2x cpu, 2x memory raise)
|
// enforceMinResourceLimits will be called 2 twice emitting 4 events (2x cpu, 2x memory raise)
|
||||||
|
|
@ -2657,7 +2656,7 @@ func TestGenerateResourceRequirements(t *testing.T) {
|
||||||
DefaultMemoryLimit: "500Mi",
|
DefaultMemoryLimit: "500Mi",
|
||||||
MaxMemoryRequest: "1Gi",
|
MaxMemoryRequest: "1Gi",
|
||||||
MinMemoryLimit: "250Mi",
|
MinMemoryLimit: "250Mi",
|
||||||
PodRoleLabel: roleLabel,
|
PodRoleLabel: "spilo-role",
|
||||||
}
|
}
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
|
|
@ -3008,6 +3007,137 @@ func TestGenerateResourceRequirements(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestGenerateLogicalBackupJob(t *testing.T) {
|
||||||
|
clusterName := "acid-test-cluster"
|
||||||
|
configResources := config.Resources{
|
||||||
|
DefaultCPURequest: "100m",
|
||||||
|
DefaultCPULimit: "1",
|
||||||
|
DefaultMemoryRequest: "100Mi",
|
||||||
|
DefaultMemoryLimit: "500Mi",
|
||||||
|
}
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
subTest string
|
||||||
|
config config.Config
|
||||||
|
specSchedule string
|
||||||
|
expectedSchedule string
|
||||||
|
expectedJobName string
|
||||||
|
expectedResources acidv1.Resources
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
subTest: "test generation of logical backup pod resources when not configured",
|
||||||
|
config: config.Config{
|
||||||
|
LogicalBackup: config.LogicalBackup{
|
||||||
|
LogicalBackupJobPrefix: "logical-backup-",
|
||||||
|
LogicalBackupSchedule: "30 00 * * *",
|
||||||
|
},
|
||||||
|
Resources: configResources,
|
||||||
|
PodManagementPolicy: "ordered_ready",
|
||||||
|
SetMemoryRequestToLimit: false,
|
||||||
|
},
|
||||||
|
specSchedule: "",
|
||||||
|
expectedSchedule: "30 00 * * *",
|
||||||
|
expectedJobName: "logical-backup-acid-test-cluster",
|
||||||
|
expectedResources: acidv1.Resources{
|
||||||
|
ResourceRequests: acidv1.ResourceDescription{CPU: "100m", Memory: "100Mi"},
|
||||||
|
ResourceLimits: acidv1.ResourceDescription{CPU: "1", Memory: "500Mi"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
subTest: "test generation of logical backup pod resources when configured",
|
||||||
|
config: config.Config{
|
||||||
|
LogicalBackup: config.LogicalBackup{
|
||||||
|
LogicalBackupCPURequest: "10m",
|
||||||
|
LogicalBackupCPULimit: "300m",
|
||||||
|
LogicalBackupMemoryRequest: "50Mi",
|
||||||
|
LogicalBackupMemoryLimit: "300Mi",
|
||||||
|
LogicalBackupJobPrefix: "lb-",
|
||||||
|
LogicalBackupSchedule: "30 00 * * *",
|
||||||
|
},
|
||||||
|
Resources: configResources,
|
||||||
|
PodManagementPolicy: "ordered_ready",
|
||||||
|
SetMemoryRequestToLimit: false,
|
||||||
|
},
|
||||||
|
specSchedule: "30 00 * * 7",
|
||||||
|
expectedSchedule: "30 00 * * 7",
|
||||||
|
expectedJobName: "lb-acid-test-cluster",
|
||||||
|
expectedResources: acidv1.Resources{
|
||||||
|
ResourceRequests: acidv1.ResourceDescription{CPU: "10m", Memory: "50Mi"},
|
||||||
|
ResourceLimits: acidv1.ResourceDescription{CPU: "300m", Memory: "300Mi"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
subTest: "test generation of logical backup pod resources when partly configured",
|
||||||
|
config: config.Config{
|
||||||
|
LogicalBackup: config.LogicalBackup{
|
||||||
|
LogicalBackupCPURequest: "50m",
|
||||||
|
LogicalBackupCPULimit: "250m",
|
||||||
|
LogicalBackupJobPrefix: "",
|
||||||
|
LogicalBackupSchedule: "30 00 * * *",
|
||||||
|
},
|
||||||
|
Resources: configResources,
|
||||||
|
PodManagementPolicy: "ordered_ready",
|
||||||
|
SetMemoryRequestToLimit: false,
|
||||||
|
},
|
||||||
|
specSchedule: "",
|
||||||
|
expectedSchedule: "30 00 * * *",
|
||||||
|
expectedJobName: "acid-test-cluster",
|
||||||
|
expectedResources: acidv1.Resources{
|
||||||
|
ResourceRequests: acidv1.ResourceDescription{CPU: "50m", Memory: "100Mi"},
|
||||||
|
ResourceLimits: acidv1.ResourceDescription{CPU: "250m", Memory: "500Mi"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
subTest: "test generation of logical backup pod resources with SetMemoryRequestToLimit enabled",
|
||||||
|
config: config.Config{
|
||||||
|
LogicalBackup: config.LogicalBackup{
|
||||||
|
LogicalBackupMemoryRequest: "80Mi",
|
||||||
|
LogicalBackupMemoryLimit: "200Mi",
|
||||||
|
LogicalBackupJobPrefix: "test-long-prefix-so-name-must-be-trimmed-",
|
||||||
|
LogicalBackupSchedule: "30 00 * * *",
|
||||||
|
},
|
||||||
|
Resources: configResources,
|
||||||
|
PodManagementPolicy: "ordered_ready",
|
||||||
|
SetMemoryRequestToLimit: true,
|
||||||
|
},
|
||||||
|
specSchedule: "",
|
||||||
|
expectedSchedule: "30 00 * * *",
|
||||||
|
expectedJobName: "test-long-prefix-so-name-must-be-trimmed-acid-test-c",
|
||||||
|
expectedResources: acidv1.Resources{
|
||||||
|
ResourceRequests: acidv1.ResourceDescription{CPU: "100m", Memory: "200Mi"},
|
||||||
|
ResourceLimits: acidv1.ResourceDescription{CPU: "1", Memory: "200Mi"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
var cluster = New(
|
||||||
|
Config{
|
||||||
|
OpConfig: tt.config,
|
||||||
|
}, k8sutil.NewMockKubernetesClient(), acidv1.Postgresql{}, logger, eventRecorder)
|
||||||
|
|
||||||
|
cluster.ObjectMeta.Name = clusterName
|
||||||
|
cluster.Spec.LogicalBackupSchedule = tt.specSchedule
|
||||||
|
cronJob, err := cluster.generateLogicalBackupJob()
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
if cronJob.Spec.Schedule != tt.expectedSchedule {
|
||||||
|
t.Errorf("%s - %s: expected schedule %s, got %s", t.Name(), tt.subTest, tt.expectedSchedule, cronJob.Spec.Schedule)
|
||||||
|
}
|
||||||
|
|
||||||
|
if cronJob.Name != tt.expectedJobName {
|
||||||
|
t.Errorf("%s - %s: expected job name %s, got %s", t.Name(), tt.subTest, tt.expectedJobName, cronJob.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
containers := cronJob.Spec.JobTemplate.Spec.Template.Spec.Containers
|
||||||
|
clusterResources, err := parseResourceRequirements(containers[0].Resources)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
if !reflect.DeepEqual(tt.expectedResources, clusterResources) {
|
||||||
|
t.Errorf("%s - %s: expected resources %#v, got %#v", t.Name(), tt.subTest, tt.expectedResources, clusterResources)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestGenerateCapabilities(t *testing.T) {
|
func TestGenerateCapabilities(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
subTest string
|
subTest string
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ package cluster
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"context"
|
"context"
|
||||||
|
|
@ -389,7 +388,7 @@ func TestUpdateFabricEventStream(t *testing.T) {
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
result := cluster.generateFabricEventStream(appId)
|
result := cluster.generateFabricEventStream(appId)
|
||||||
if !reflect.DeepEqual(result.Spec.EventStreams, streams.Items[0].Spec.EventStreams) {
|
if match, _ := sameStreams(streams.Items[0].Spec.EventStreams, result.Spec.EventStreams); !match {
|
||||||
t.Errorf("Malformed FabricEventStream, expected %#v, got %#v", streams.Items[0], result)
|
t.Errorf("Malformed FabricEventStream, expected %#v, got %#v", streams.Items[0], result)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -174,6 +174,9 @@ func (c *Controller) importConfigurationFromCRD(fromCRD *acidv1.OperatorConfigur
|
||||||
result.LogicalBackupSchedule = util.Coalesce(fromCRD.LogicalBackup.Schedule, "30 00 * * *")
|
result.LogicalBackupSchedule = util.Coalesce(fromCRD.LogicalBackup.Schedule, "30 00 * * *")
|
||||||
result.LogicalBackupDockerImage = util.Coalesce(fromCRD.LogicalBackup.DockerImage, "registry.opensource.zalan.do/acid/logical-backup:v1.8.2")
|
result.LogicalBackupDockerImage = util.Coalesce(fromCRD.LogicalBackup.DockerImage, "registry.opensource.zalan.do/acid/logical-backup:v1.8.2")
|
||||||
result.LogicalBackupProvider = util.Coalesce(fromCRD.LogicalBackup.BackupProvider, "s3")
|
result.LogicalBackupProvider = util.Coalesce(fromCRD.LogicalBackup.BackupProvider, "s3")
|
||||||
|
result.LogicalBackupAzureStorageAccountName = fromCRD.LogicalBackup.AzureStorageAccountName
|
||||||
|
result.LogicalBackupAzureStorageAccountKey = fromCRD.LogicalBackup.AzureStorageAccountKey
|
||||||
|
result.LogicalBackupAzureStorageContainer = fromCRD.LogicalBackup.AzureStorageContainer
|
||||||
result.LogicalBackupS3Bucket = fromCRD.LogicalBackup.S3Bucket
|
result.LogicalBackupS3Bucket = fromCRD.LogicalBackup.S3Bucket
|
||||||
result.LogicalBackupS3Region = fromCRD.LogicalBackup.S3Region
|
result.LogicalBackupS3Region = fromCRD.LogicalBackup.S3Region
|
||||||
result.LogicalBackupS3Endpoint = fromCRD.LogicalBackup.S3Endpoint
|
result.LogicalBackupS3Endpoint = fromCRD.LogicalBackup.S3Endpoint
|
||||||
|
|
@ -183,9 +186,10 @@ func (c *Controller) importConfigurationFromCRD(fromCRD *acidv1.OperatorConfigur
|
||||||
result.LogicalBackupS3RetentionTime = fromCRD.LogicalBackup.RetentionTime
|
result.LogicalBackupS3RetentionTime = fromCRD.LogicalBackup.RetentionTime
|
||||||
result.LogicalBackupGoogleApplicationCredentials = fromCRD.LogicalBackup.GoogleApplicationCredentials
|
result.LogicalBackupGoogleApplicationCredentials = fromCRD.LogicalBackup.GoogleApplicationCredentials
|
||||||
result.LogicalBackupJobPrefix = util.Coalesce(fromCRD.LogicalBackup.JobPrefix, "logical-backup-")
|
result.LogicalBackupJobPrefix = util.Coalesce(fromCRD.LogicalBackup.JobPrefix, "logical-backup-")
|
||||||
result.LogicalBackupAzureStorageAccountName = fromCRD.LogicalBackup.AzureStorageAccountName
|
result.LogicalBackupCPURequest = fromCRD.LogicalBackup.CPURequest
|
||||||
result.LogicalBackupAzureStorageAccountKey = fromCRD.LogicalBackup.AzureStorageAccountKey
|
result.LogicalBackupMemoryRequest = fromCRD.LogicalBackup.MemoryRequest
|
||||||
result.LogicalBackupAzureStorageContainer = fromCRD.LogicalBackup.AzureStorageContainer
|
result.LogicalBackupCPULimit = fromCRD.LogicalBackup.CPULimit
|
||||||
|
result.LogicalBackupMemoryLimit = fromCRD.LogicalBackup.MemoryLimit
|
||||||
|
|
||||||
// debug config
|
// debug config
|
||||||
result.DebugLogging = fromCRD.OperatorDebug.DebugLogging
|
result.DebugLogging = fromCRD.OperatorDebug.DebugLogging
|
||||||
|
|
|
||||||
|
|
@ -128,6 +128,9 @@ type LogicalBackup struct {
|
||||||
LogicalBackupSchedule string `name:"logical_backup_schedule" default:"30 00 * * *"`
|
LogicalBackupSchedule string `name:"logical_backup_schedule" default:"30 00 * * *"`
|
||||||
LogicalBackupDockerImage string `name:"logical_backup_docker_image" default:"registry.opensource.zalan.do/acid/logical-backup:v1.8.2"`
|
LogicalBackupDockerImage string `name:"logical_backup_docker_image" default:"registry.opensource.zalan.do/acid/logical-backup:v1.8.2"`
|
||||||
LogicalBackupProvider string `name:"logical_backup_provider" default:"s3"`
|
LogicalBackupProvider string `name:"logical_backup_provider" default:"s3"`
|
||||||
|
LogicalBackupAzureStorageAccountName string `name:"logical_backup_azure_storage_account_name" default:""`
|
||||||
|
LogicalBackupAzureStorageContainer string `name:"logical_backup_azure_storage_container" default:""`
|
||||||
|
LogicalBackupAzureStorageAccountKey string `name:"logical_backup_azure_storage_account_key" default:""`
|
||||||
LogicalBackupS3Bucket string `name:"logical_backup_s3_bucket" default:""`
|
LogicalBackupS3Bucket string `name:"logical_backup_s3_bucket" default:""`
|
||||||
LogicalBackupS3Region string `name:"logical_backup_s3_region" default:""`
|
LogicalBackupS3Region string `name:"logical_backup_s3_region" default:""`
|
||||||
LogicalBackupS3Endpoint string `name:"logical_backup_s3_endpoint" default:""`
|
LogicalBackupS3Endpoint string `name:"logical_backup_s3_endpoint" default:""`
|
||||||
|
|
@ -137,9 +140,10 @@ type LogicalBackup struct {
|
||||||
LogicalBackupS3RetentionTime string `name:"logical_backup_s3_retention_time" default:""`
|
LogicalBackupS3RetentionTime string `name:"logical_backup_s3_retention_time" default:""`
|
||||||
LogicalBackupGoogleApplicationCredentials string `name:"logical_backup_google_application_credentials" default:""`
|
LogicalBackupGoogleApplicationCredentials string `name:"logical_backup_google_application_credentials" default:""`
|
||||||
LogicalBackupJobPrefix string `name:"logical_backup_job_prefix" default:"logical-backup-"`
|
LogicalBackupJobPrefix string `name:"logical_backup_job_prefix" default:"logical-backup-"`
|
||||||
LogicalBackupAzureStorageAccountName string `name:"logical_backup_azure_storage_account_name" default:""`
|
LogicalBackupCPURequest string `name:"logical_backup_cpu_request"`
|
||||||
LogicalBackupAzureStorageContainer string `name:"logical_backup_azure_storage_container" default:""`
|
LogicalBackupMemoryRequest string `name:"logical_backup_memory_request"`
|
||||||
LogicalBackupAzureStorageAccountKey string `name:"logical_backup_azure_storage_account_key" default:""`
|
LogicalBackupCPULimit string `name:"logical_backup_cpu_limit"`
|
||||||
|
LogicalBackupMemoryLimit string `name:"logical_backup_memory_limit"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Operator options for connection pooler
|
// Operator options for connection pooler
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue