Skip to content

Commit

Permalink
Merge branch 'main' into proxysql-scheduler
Browse files Browse the repository at this point in the history
  • Loading branch information
tplavcic committed Nov 14, 2022
2 parents 333cf06 + 17d7ed2 commit e53f236
Show file tree
Hide file tree
Showing 47 changed files with 1,798 additions and 806 deletions.
2 changes: 1 addition & 1 deletion build/liveness-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ MYSQL_PASSWORD="${mysql_pass:-$MONITOR_PASSWORD}"
DEFAULTS_EXTRA_FILE=${DEFAULTS_EXTRA_FILE:-/etc/my.cnf}
NODE_IP=$(hostname -I | awk ' { print $1 } ')
#Timeout exists for instances where mysqld may be hung
TIMEOUT=${LIVENESS_CHECK_TIMEOUT:-5}
TIMEOUT=$((${LIVENESS_CHECK_TIMEOUT:-5} - 1))

EXTRA_ARGS=""
if [[ -n $MYSQL_USERNAME ]]; then
Expand Down
2 changes: 1 addition & 1 deletion build/readiness-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ AVAILABLE_WHEN_DONOR=${AVAILABLE_WHEN_DONOR:-1}
NODE_IP=$(hostname -I | awk ' { print $1 } ')

#Timeout exists for instances where mysqld may be hung
TIMEOUT=${READINESS_CHECK_TIMEOUT:-10}
TIMEOUT=$((${READINESS_CHECK_TIMEOUT:-10} - 1))

EXTRA_ARGS=""
if [[ -n "$MYSQL_USERNAME" ]]; then
Expand Down
42 changes: 30 additions & 12 deletions deploy/backup/copy-backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ usage() {

get_backup_dest() {
local backup=$1
local secret

if $ctrl get "pxc-backup/$backup" 1>/dev/null 2>/dev/null; then
BASE64_DECODE_CMD=""
Expand All @@ -54,11 +55,27 @@ get_backup_dest() {
exit 1
fi

local secret=$($ctrl get "pxc-backup/$backup" -o 'jsonpath={.status.s3.credentialsSecret}' 2>/dev/null)
ENDPOINT=$($ctrl get "pxc-backup/$backup" -o 'jsonpath={.status.s3.endpointUrl}' 2>/dev/null)
ACCESS_KEY_ID=$($ctrl get "secret/$secret" -o 'jsonpath={.data.AWS_ACCESS_KEY_ID}' 2>/dev/null | eval "${BASE64_DECODE_CMD}")
SECRET_ACCESS_KEY=$($ctrl get "secret/$secret" -o 'jsonpath={.data.AWS_SECRET_ACCESS_KEY}' 2>/dev/null | eval "${BASE64_DECODE_CMD}")
export CREDENTIALS="ENDPOINT=$ENDPOINT ACCESS_KEY_ID=$ACCESS_KEY_ID SECRET_ACCESS_KEY=$SECRET_ACCESS_KEY DEFAULT_REGION=$DEFAULT_REGION"
secret=$($ctrl get "pxc-backup/$backup" -o 'jsonpath={.status.s3.credentialsSecret}' 2>/dev/null)
if [ -n "$secret" ]; then
ENDPOINT=$($ctrl get "pxc-backup/$backup" -o 'jsonpath={.status.s3.endpointUrl}' 2>/dev/null)
ACCESS_KEY_ID=$($ctrl get "secret/$secret" -o 'jsonpath={.data.AWS_ACCESS_KEY_ID}' 2>/dev/null | eval "${BASE64_DECODE_CMD}")
SECRET_ACCESS_KEY=$($ctrl get "secret/$secret" -o 'jsonpath={.data.AWS_SECRET_ACCESS_KEY}' 2>/dev/null | eval "${BASE64_DECODE_CMD}")
export CREDENTIALS="ENDPOINT=$ENDPOINT ACCESS_KEY_ID=$ACCESS_KEY_ID SECRET_ACCESS_KEY=$SECRET_ACCESS_KEY DEFAULT_REGION=$DEFAULT_REGION"

$ctrl get "pxc-backup/$backup" -o jsonpath='{.status.destination}'
return
fi

secret=$($ctrl get "pxc-backup/$backup" -o 'jsonpath={.status.azure.credentialsSecret}' 2>/dev/null)
if [ -n "$secret" ]; then
AZURE_STORAGE_ACCOUNT=$($ctrl get "secret/$secret" -o 'jsonpath={.data.AZURE_STORAGE_ACCOUNT_NAME}' 2>/dev/null | eval "${BASE64_DECODE_CMD}")
AZURE_ACCESS_KEY=$($ctrl get "secret/$secret" -o 'jsonpath={.data.AZURE_STORAGE_ACCOUNT_KEY}' 2>/dev/null | eval "${BASE64_DECODE_CMD}")
AZURE_STORAGE_CLASS=$($ctrl get "pxc-backup/$backup" -o 'jsonpath={.data.storageClass}' 2>/dev/null | eval "${BASE64_DECODE_CMD}")
export CREDENTIALS="AZURE_STORAGE_ACCOUNT=$AZURE_STORAGE_ACCOUNT AZURE_ACCESS_KEY=$AZURE_ACCESS_KEY AZURE_STORAGE_CLASS=$AZURE_STORAGE_CLASS"
echo "azure://$($ctrl get "pxc-backup/$backup" -o jsonpath='{.status.destination}')"
return
fi

$ctrl get "pxc-backup/$backup" -o jsonpath='{.status.destination}'
else
# support direct PVC name here
Expand Down Expand Up @@ -101,8 +118,8 @@ check_input_destination() {
printf "[ERROR] '%s' PVC doesn't exists.\n\n" "$backup_dest"
usage
fi
elif [ "${backup_dest:0:5}" = "s3://" ]; then
env -i $CREDENTIALS "$xbcloud" get "${backup_dest}" xtrabackup_info 1>/dev/null
elif [ "${backup_dest:0:5}" = "s3://" ] || [ "${backup_dest:0:8}" = "azure://" ]; then
env -i "${CREDENTIALS} ${xbcloud} get ${backup_dest} xtrabackup_info" 1>/dev/null
else
echo "Can't find $backup_dest backup"
usage
Expand Down Expand Up @@ -149,7 +166,8 @@ start_tmp_pod() {

copy_files_pvc() {
local dest_dir=$1
local real_dest_dir=$(
local real_dest_dir
real_dest_dir=$(
cd "$dest_dir"
pwd -P
)
Expand All @@ -160,13 +178,13 @@ copy_files_pvc() {
echo "Downloading finished"
}

copy_files_s3() {
copy_files_xbcloud() {
local backup_path=$1
local dest_dir=$2

echo ""
echo "Downloading started"
env -i $CREDENTIALS "$xbcloud" get "${backup_path}" --parallel=10 1>"$dest_dir/xtrabackup.stream" 2>"$dest_dir/transfer.log"
env -i "${CREDENTIALS} ${xbcloud} get ${backup_path} --parallel=10" 1>"$dest_dir/xtrabackup.stream" 2>"$dest_dir/transfer.log"
echo "Downloading finished"
}

Expand All @@ -191,8 +209,8 @@ main() {
start_tmp_pod "$backup_dest"
copy_files_pvc "$dest_dir"
stop_tmp_pod
elif [ "${backup_dest:0:5}" = "s3://" ]; then
copy_files_s3 "$backup_dest" "$dest_dir"
elif [ "${backup_dest:0:5}" = "s3://" ] || [ "${backup_dest:0:8}" = "azure://" ]; then
copy_files_xbcloud "$backup_dest" "$dest_dir"
fi

cat - <<-EOF
Expand Down
82 changes: 82 additions & 0 deletions deploy/bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9002,6 +9002,17 @@ spec:
additionalProperties:
type: string
type: object
azure:
properties:
container:
type: string
credentialsSecret:
type: string
endpointUrl:
type: string
storageClass:
type: string
type: object
containerSecurityContext:
properties:
allowPrivilegeEscalation:
Expand Down Expand Up @@ -11616,6 +11627,14 @@ spec:
type: object
type: object
type: object
ignoreAnnotations:
items:
type: string
type: array
ignoreLabels:
items:
type: string
type: array
initImage:
type: string
logCollectorSecretName:
Expand Down Expand Up @@ -16739,11 +16758,24 @@ spec:
type: object
status:
properties:
azure:
properties:
container:
type: string
credentialsSecret:
type: string
endpointUrl:
type: string
storageClass:
type: string
type: object
completed:
format: date-time
type: string
destination:
type: string
image:
type: string
lastscheduled:
format: date-time
type: string
Expand All @@ -16758,10 +16790,18 @@ spec:
region:
type: string
type: object
sslInternalSecretName:
type: string
sslSecretName:
type: string
state:
type: string
storage_type:
type: string
storageName:
type: string
vaultSecretName:
type: string
type: object
type: object
served: true
Expand Down Expand Up @@ -16820,11 +16860,24 @@ spec:
type: string
backupSource:
properties:
azure:
properties:
container:
type: string
credentialsSecret:
type: string
endpointUrl:
type: string
storageClass:
type: string
type: object
completed:
format: date-time
type: string
destination:
type: string
image:
type: string
lastscheduled:
format: date-time
type: string
Expand All @@ -16839,20 +16892,41 @@ spec:
region:
type: string
type: object
sslInternalSecretName:
type: string
sslSecretName:
type: string
state:
type: string
storage_type:
type: string
storageName:
type: string
vaultSecretName:
type: string
type: object
pitr:
properties:
backupSource:
properties:
azure:
properties:
container:
type: string
credentialsSecret:
type: string
endpointUrl:
type: string
storageClass:
type: string
type: object
completed:
format: date-time
type: string
destination:
type: string
image:
type: string
lastscheduled:
format: date-time
type: string
Expand All @@ -16867,10 +16941,18 @@ spec:
region:
type: string
type: object
sslInternalSecretName:
type: string
sslSecretName:
type: string
state:
type: string
storage_type:
type: string
storageName:
type: string
vaultSecretName:
type: string
type: object
date:
type: string
Expand Down
11 changes: 11 additions & 0 deletions deploy/cr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ metadata:
# percona.com/issue-vault-token: "true"
spec:
crVersion: 1.12.0
# ignoreAnnotations:
# - iam.amazonaws.com/role
# ignoreLabels:
# - rack
# secretsName: cluster1-secrets
# vaultSecretName: keyring-secret-vault
# sslSecretName: cluster1-ssl
Expand Down Expand Up @@ -539,6 +543,13 @@ spec:
bucket: S3-BACKUP-BUCKET-NAME-HERE
credentialsSecret: my-cluster-name-backup-s3
region: us-west-2
azure-blob:
type: azure
azure:
credentialsSecret: azure-secret
container: test
# endpointUrl: https://accountName.blob.core.windows.net
# storageClass: Hot
fs-pvc:
type: filesystem
# nodeSelector:
Expand Down
Loading

0 comments on commit e53f236

Please sign in to comment.