parent
c756cb2f8a
commit
bb2617a53f
|
|
@ -498,6 +498,12 @@ 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:
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ RUN apt-get update \
|
||||||
gnupg \
|
gnupg \
|
||||||
gcc \
|
gcc \
|
||||||
libffi-dev \
|
libffi-dev \
|
||||||
|
&& curl -sL https://aka.ms/InstallAzureCLIDeb | bash \
|
||||||
&& pip3 install --upgrade pip \
|
&& pip3 install --upgrade pip \
|
||||||
&& pip3 install --no-cache-dir awscli --upgrade \
|
&& pip3 install --no-cache-dir awscli --upgrade \
|
||||||
&& pip3 install --no-cache-dir gsutil --upgrade \
|
&& pip3 install --no-cache-dir gsutil --upgrade \
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,12 @@ function compress {
|
||||||
pigz
|
pigz
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function az_upload {
|
||||||
|
PATH_TO_BACKUP=$LOGICAL_BACKUP_S3_BUCKET"/spilo/"$SCOPE$LOGICAL_BACKUP_S3_BUCKET_SCOPE_SUFFIX"/logical_backups/"$(date +%s).sql.gz
|
||||||
|
|
||||||
|
az storage blob upload --file "$1" --account-name "$LOGICAL_BACKUP_AZURE_STORAGE_ACCOUNT_NAME" --account-key "$LOGICAL_BACKUP_AZURE_STORAGE_ACCOUNT_KEY" -c "$LOGICAL_BACKUP_AZURE_STORAGE_CONTAINER" -n "$PATH_TO_BACKUP"
|
||||||
|
}
|
||||||
|
|
||||||
function aws_delete_objects {
|
function aws_delete_objects {
|
||||||
args=(
|
args=(
|
||||||
"--bucket=$LOGICAL_BACKUP_S3_BUCKET"
|
"--bucket=$LOGICAL_BACKUP_S3_BUCKET"
|
||||||
|
|
@ -120,7 +126,7 @@ function upload {
|
||||||
"gcs")
|
"gcs")
|
||||||
gcs_upload
|
gcs_upload
|
||||||
;;
|
;;
|
||||||
*)
|
"aws")
|
||||||
aws_upload $(($(estimate_size) / DUMP_SIZE_COEFF))
|
aws_upload $(($(estimate_size) / DUMP_SIZE_COEFF))
|
||||||
aws_delete_outdated
|
aws_delete_outdated
|
||||||
;;
|
;;
|
||||||
|
|
@ -174,8 +180,13 @@ for search in "${search_strategy[@]}"; do
|
||||||
done
|
done
|
||||||
|
|
||||||
set -x
|
set -x
|
||||||
dump | compress | upload
|
if [ "$LOGICAL_BACKUP_PROVIDER" == "az" ]; then
|
||||||
[[ ${PIPESTATUS[0]} != 0 || ${PIPESTATUS[1]} != 0 || ${PIPESTATUS[2]} != 0 ]] && (( ERRORCOUNT += 1 ))
|
dump | compress > /tmp/azure-backup.sql.gz
|
||||||
set +x
|
az_upload /tmp/azure-backup.sql.gz
|
||||||
|
else
|
||||||
|
dump | compress | upload
|
||||||
|
[[ ${PIPESTATUS[0]} != 0 || ${PIPESTATUS[1]} != 0 || ${PIPESTATUS[2]} != 0 ]] && (( ERRORCOUNT += 1 ))
|
||||||
|
set +x
|
||||||
|
|
||||||
exit $ERRORCOUNT
|
exit $ERRORCOUNT
|
||||||
|
fi
|
||||||
|
|
|
||||||
|
|
@ -765,6 +765,15 @@ 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.
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,9 @@ 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}"
|
||||||
|
|
|
||||||
|
|
@ -496,6 +496,12 @@ 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:
|
||||||
|
|
|
||||||
|
|
@ -163,6 +163,9 @@ 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
|
||||||
|
|
|
||||||
|
|
@ -1655,6 +1655,15 @@ 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": {
|
||||||
|
|
|
||||||
|
|
@ -227,6 +227,9 @@ 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"`
|
||||||
|
AzureStorageContainer string `json:"logical_backup_azure_storage_container,omitempty"`
|
||||||
|
AzureStorageAccountKey string `json:"logical_backup_azure_storage_account_key,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// PatroniConfiguration defines configuration for Patroni
|
// PatroniConfiguration defines configuration for Patroni
|
||||||
|
|
|
||||||
|
|
@ -2262,6 +2262,18 @@ func (c *Cluster) generateLogicalBackupPodEnvVars() []v1.EnvVar {
|
||||||
Name: "LOGICAL_BACKUP_GOOGLE_APPLICATION_CREDENTIALS",
|
Name: "LOGICAL_BACKUP_GOOGLE_APPLICATION_CREDENTIALS",
|
||||||
Value: c.OpConfig.LogicalBackup.LogicalBackupGoogleApplicationCredentials,
|
Value: c.OpConfig.LogicalBackup.LogicalBackupGoogleApplicationCredentials,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "LOGICAL_BACKUP_AZURE_STORAGE_ACCOUNT_NAME",
|
||||||
|
Value: c.OpConfig.LogicalBackup.LogicalBackupAzureStorageAccountName,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "LOGICAL_BACKUP_AZURE_STORAGE_CONTAINER",
|
||||||
|
Value: c.OpConfig.LogicalBackup.LogicalBackupAzureStorageContainer,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "LOGICAL_BACKUP_AZURE_STORAGE_ACCOUNT_KEY",
|
||||||
|
Value: c.OpConfig.LogicalBackup.LogicalBackupAzureStorageAccountKey,
|
||||||
|
},
|
||||||
// Postgres env vars
|
// Postgres env vars
|
||||||
{
|
{
|
||||||
Name: "PG_VERSION",
|
Name: "PG_VERSION",
|
||||||
|
|
|
||||||
|
|
@ -183,6 +183,9 @@ 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.LogicalBackupAzureStorageAccountKey = fromCRD.LogicalBackup.AzureStorageAccountKey
|
||||||
|
result.LogicalBackupAzureStorageContainer = fromCRD.LogicalBackup.AzureStorageContainer
|
||||||
|
|
||||||
// debug config
|
// debug config
|
||||||
result.DebugLogging = fromCRD.OperatorDebug.DebugLogging
|
result.DebugLogging = fromCRD.OperatorDebug.DebugLogging
|
||||||
|
|
|
||||||
|
|
@ -137,6 +137,9 @@ 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:""`
|
||||||
|
LogicalBackupAzureStorageContainer string `name:"logical_backup_azure_storage_container" default:""`
|
||||||
|
LogicalBackupAzureStorageAccountKey string `name:"logical_backup_azure_storage_account_key" default:""`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Operator options for connection pooler
|
// Operator options for connection pooler
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue