Skip to content

Commit

Permalink
Merge pull request #26 from odra/product-name-param
Browse files Browse the repository at this point in the history
PRODUCT_NAME var
  • Loading branch information
odra authored Mar 11, 2019
2 parents 95ceaca + 94b1728 commit 5799f31
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion image/tools/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ if [[ "$encryption_engine" ]]; then
else
encrypted_files="$ARCHIVES_DEST/*"
fi
upload_archive "${encrypted_files}" $DATESTAMP backups/$component
upload_archive "${encrypted_files}" $DATESTAMP backups/$PRODUCT_NAME/$component
echo '==> Archive upload completed'

echo "[$DATESTAMP] Backup completed"
Expand Down
12 changes: 1 addition & 11 deletions image/tools/lib/backend/s3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ function get_s3_bucket_name {
echo "`oc get secret -n default ${BACKEND_SECRET_NAME} -o jsonpath='{.data.AWS_S3_BUCKET_NAME}' | base64 --decode`"
}

function get_s3_bucket_suffix {
echo "`oc get secret -n default ${BACKEND_SECRET_NAME} -o jsonpath='{.data.AWS_S3_BUCKET_SUFFIX}' | base64 --decode`"
}

function get_s3_key_id {
echo "`oc get secret -n default ${BACKEND_SECRET_NAME} -o jsonpath='{.data.AWS_ACCESS_KEY_ID}' | base64 --decode`"
}
Expand All @@ -32,18 +28,12 @@ function upload_archive {

local file_list=$1
local datestamp=$2
local bucket_folder=$3

local AWS_S3_BUCKET_NAME=$(get_s3_bucket_name)
local AWS_S3_BUCKET_SUFFIX="$(get_s3_bucket_suffix)"
local AWS_ACCESS_KEY_ID="$(get_s3_key_id)"
local AWS_SECRET_ACCESS_KEY="$(get_s3_access_key)"

if [[ "$AWS_S3_BUCKET_SUFFIX" ]]; then
bucket_folder="$3/$AWS_S3_BUCKET_SUFFIX"
else
bucket_folder=$3
fi

for fname in ${file_list}; do
s3cmd put --access_key ${AWS_ACCESS_KEY_ID} --secret_key ${AWS_SECRET_ACCESS_KEY} --progress ${fname} "s3://$AWS_S3_BUCKET_NAME/$bucket_folder/$datestamp/$(basename ${fname})"
rc=$?
Expand Down
11 changes: 8 additions & 3 deletions templates/openshift/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ oc new-app \
-p 'ENCRYPTION_SECRET_NAME=sample-gpg-secret' \
-p 'IMAGE=quay.io/integreatly/backup-container:master' \
-p 'CRON_SCHEDULE=* */1 * * *' \
-p 'NAME=mysql-backup'
-p 'NAME=mysql-backup' \
-p 'PRODUCT_NAME=3scale'
```

Note: There is knonwn issue in openshift 3.11 around using cronjobs in templates where you may get the following error: `error: no kind "CronJob" is registered for version "batch/v1" in scheme "k8s.io/kubernetes/pkg/api/legacyscheme/scheme.go:29"`, you will need to process the template first and then piping process command output to `oc apply` command:
Expand All @@ -43,14 +44,16 @@ oc process \
-p 'ENCRYPTION_SECRET_NAME=sample-gpg-secret' \
-p 'IMAGE=quay.io/integreatly/backup-container:master' \
-p 'CRON_SCHEDULE=* */1 * * *' \
-p 'NAME=mysql-backup' | oc apply -f -
-p 'NAME=mysql-backup' \
-p 'PRODUCT_NAME=3scale' | oc apply -f -
```

Parameters:

```
NAME DESCRIPTION GENERATOR VALUE
NAME Unique job name to be used in several resource name(s) integreatly-cronjob-backup
PRODUCT_NAME Middleware product name to have its data archived
COMPONENT Component name to run the backup
BACKEND Backend engine to upload the component archive s3
ENCRYPTION Encryption engine to encrypt component archive before uploading it gpg
Expand All @@ -75,14 +78,16 @@ oc new-app \
-p 'BACKEND_SECRET_NAME=sample-s3-secret' \
-p 'ENCRYPTION_SECRET_NAME=sample-gpg-secret' \
-p 'IMAGE=quay.io/integreatly/backup-container:master' \
-p 'NAME=mysql-backup'
-p 'NAME=mysql-backup' \
-p 'PRODUCT_NAME=3scale'
```

Parameters:

```
NAME DESCRIPTION GENERATOR VALUE
NAME Unique job name to be used in several resource name(s) integreatly-job-backup
PRODUCT_NAME Middleware product name to have its data archived
COMPONENT Component name to run the backup
BACKEND Backend engine to upload the component archive s3
ENCRYPTION Encryption engine to encrypt component archive before uploading it gpg
Expand Down
3 changes: 3 additions & 0 deletions templates/openshift/backup-cronjob-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ parameters:
- name: NAME
description: Unique job name to be used in several resource name(s)
value: integreatly-cronjob-backup
- name: PRODUCT_NAME
description: Middleware product name to have its data archived
required: true
- name: COMPONENT
description: Component name to run the backup
required: true
Expand Down
5 changes: 5 additions & 0 deletions templates/openshift/backup-job-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,16 @@ objects:
value: "${ENCRYPTION_SECRET_NAME}"
- name: COMPONENT_SECRET_NAME
value: "${COMPONENT_SECRET_NAME}"
- name: PRODUCT_NAME
value: "${PRODUCT_NAME}"
restartPolicy: Never
parameters:
- name: NAME
description: Unique job name to be used in several resource name(s)
value: integreatly-job-backup
- name: PRODUCT_NAME
description: Middleware product name to have its data archived
required: true
- name: COMPONENT
description: Component name to run the backup
required: true
Expand Down

0 comments on commit 5799f31

Please sign in to comment.