Skip to content

Commit 0f63a35

Browse files
authored
automate OADP retore process for single tenant (#2597)
* automate restore process for single tenant Signed-off-by: Ben Luzarraga <[email protected]> * typo Signed-off-by: Ben Luzarraga <[email protected]> * typo Signed-off-by: Ben Luzarraga <[email protected]> * debugging restore Signed-off-by: Ben Luzarraga <[email protected]> * implement better cert manager wait function Signed-off-by: Ben Luzarraga <[email protected]> * change cm wait to check for running pod Signed-off-by: Ben Luzarraga <[email protected]> * update cert manager wait logic Signed-off-by: Ben Luzarraga <[email protected]> * typo Signed-off-by: Ben Luzarraga <[email protected]> * update im wait logic Signed-off-by: Ben Luzarraga <[email protected]> * update im wait logic Signed-off-by: Ben Luzarraga <[email protected]> * get rid of infinite loop Signed-off-by: Ben Luzarraga <[email protected]> * update restore job wait time Signed-off-by: Ben Luzarraga <[email protected]> * script prereqs and validations Signed-off-by: Ben Luzarraga <[email protected]> * debugging Signed-off-by: Ben Luzarraga <[email protected]> * debugging Signed-off-by: Ben Luzarraga <[email protected]> * debugging Signed-off-by: Ben Luzarraga <[email protected]> * support licensing and lsr restores, add lsr workaaround job Signed-off-by: Ben Luzarraga <[email protected]> * debugging Signed-off-by: Ben Luzarraga <[email protected]> * update lsr restore job Signed-off-by: Ben Luzarraga <[email protected]> * update wait time to allow for lsr instance to come ready Signed-off-by: Ben Luzarraga <[email protected]> * write relevant env vars to new file Signed-off-by: Ben Luzarraga <[email protected]> * debugging Signed-off-by: Ben Luzarraga <[email protected]> * troubleshooting file write Signed-off-by: Ben Luzarraga <[email protected]> * troubleshooting file write Signed-off-by: Ben Luzarraga <[email protected]> * troubleshooting file write Signed-off-by: Ben Luzarraga <[email protected]> * troubleshooting file write Signed-off-by: Ben Luzarraga <[email protected]> * troubleshooting file write Signed-off-by: Ben Luzarraga <[email protected]> * troubleshooting file write Signed-off-by: Ben Luzarraga <[email protected]> * troubleshooting file write Signed-off-by: Ben Luzarraga <[email protected]> * troubleshooting file write Signed-off-by: Ben Luzarraga <[email protected]> * troubleshooting file write Signed-off-by: Ben Luzarraga <[email protected]> * cleanup debugging Signed-off-by: Ben Luzarraga <[email protected]> * clean up pull secret before restore --------- Signed-off-by: Ben Luzarraga <[email protected]>
1 parent 61752f6 commit 0f63a35

File tree

8 files changed

+703
-9
lines changed

8 files changed

+703
-9
lines changed

br-testing-automation/auto-br.sh renamed to br-testing-automation/auto-br-fusion.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ RECIPE_NAMESPACE=""
3333

3434
BASE_DIR=$(cd $(dirname "$0")/$(dirname "$(readlink $0)") && pwd -P)
3535
. ../cp3pt0-deployment/common/utils.sh
36-
source ${BASE_DIR}/env.properties
36+
source ${BASE_DIR}/env-fusion.properties
3737

3838
function main(){
3939
parse_arguments "$@"
@@ -64,8 +64,8 @@ function print_usage(){
6464
echo " * Fusion setup was completed with the fusion-backup-setup.sh script"
6565
echo ""
6666
echo "Options:"
67-
echo " --oc string Optional. File path to oc CLI. Default uses oc in your PATH. Can also be set in env.properties."
68-
echo " --yq string Optional. File path to yq CLI. Default uses yq in your PATH. Can also be set in env.properties."
67+
echo " --oc string Optional. File path to oc CLI. Default uses oc in your PATH. Can also be set in env-fusion.properties."
68+
echo " --yq string Optional. File path to yq CLI. Default uses yq in your PATH. Can also be set in env-fusion.properties."
6969
echo " --backup Optional. Enable backup mode, it will trigger a backup job."
7070
echo " --backup-name Necessary. Name of backup. A unique name is required when --backup is enabled. An existing name is required when --restore is enabled"
7171
echo " --restore Optional. Enable restore mode, it will trigger a restore job."
@@ -202,15 +202,15 @@ function prereq() {
202202
#check fusion related variables
203203
#backup storage location name
204204
if [[ $BACKUP_STORAGE_LOCATION_NAME == "" ]]; then
205-
error "Backup Storage Location name not specified in env.properties."
205+
error "Backup Storage Location name not specified in env-fusion.properties."
206206
fi
207207
#application
208208
if [[ $APPLICATION == "" ]]; then
209-
error "Application not specified in env.properties."
209+
error "Application not specified in env-fusion.properties."
210210
fi
211211
#backup policy
212212
if [[ $BACKUP_POLICY == "" ]]; then
213-
error "Backup Policy not specified in env.properties."
213+
error "Backup Policy not specified in env-fusion.properties."
214214
fi
215215

216216
}

br-testing-automation/auto-br-oadp.sh

Lines changed: 579 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
OC="oc" #default, can be overridden with --oc option when calling script
2+
YQ="yq" #default, can be overridden with --yq option when calling script
3+
STORAGE_CLASS="rook-cephfs"
4+
5+
OPERATOR_NS="cs-op"
6+
SERVICES_NS="cs-serv"
7+
TETHERED_NS=""
8+
DOCKER_USER= #not currently used but listed as a prereq for some of the Fusion scripts so included for now
9+
DOCKER_PASS=
10+
11+
#only one of the following can be enabled at a time
12+
BACKUP="false" #script is in backup mode
13+
RESTORE="true" #script is in restore mode
14+
SETUP="false" #setup the OADP instance for the cluster
15+
16+
#install oadp
17+
OADP_INSTALL="false" #true has the script install oadp operator in velero namespace, false assumes operator already installed in velero namespace
18+
OADP_RESOURCE_CREATION="false" #true has script create OADP required resources (DataProtectionApplication and necessary Secret)
19+
OADP_NS="velero" #default is velero, currently only supports velero
20+
BACKUP_STORAGE_LOCATION_NAME="" #name of s3 storage
21+
STORAGE_BUCKET_NAME="" #name of existing s3 bucket
22+
S3_URL="https\:\/\/<the rest of the url>" #make sure to escape `/` and `:`
23+
STORAGE_SECRET_ACCESS_KEY= #secret access key from s3 storage
24+
STORAGE_SECRET_ACCESS_KEY_ID= #access key id from s3 storage
25+
26+
IM_ENABLED="true"
27+
ZEN_ENABLED="true"
28+
NSS_ENABLED="true"
29+
UMS_ENABLED="false"
30+
31+
#label-common-services specific env variables
32+
# disable labeling of cert manager, licensing, and LSR resources by changing value to 0
33+
CERT_MANAGER_NAMESPACE="ibm-cert-manager" #default
34+
LICENSING_NAMESPACE="ibm-licensing" #defaul
35+
LSR_NAMESPACE="ibm-ls-reporter" #default
36+
CPFS_VERSION="4.14" #default
37+
ZENSERVICE_NAME="lite-cr" #the name of the deployed zenservice, script assumes at least one is deployed
38+
ZEN_NAMESPACE="cs-serv"
39+
40+
# true false values
41+
ENABLE_CERT_MANAGER="true"
42+
ENABLE_LICENSING="true"
43+
ENABLE_LSR="true"
44+
45+
# Change to 1 to enable private catalog
46+
ENABLE_PRIVATE_CATALOG=0
47+
#change to 0 to disable labeling catalog sources in openshift-marketplace
48+
ENABLE_DEFAULT_CS=1
49+
# Add additional CatalogSources separated by comma which are withour ".spec.publisher: IBM"
50+
# For example: "my-catalog,my-catalog2,my-catalog3"
51+
ADDITIONAL_SOURCES="ibm-operator-catalog-latest"
52+
CONTROL_NS="" # Pass the control namespace if it is needed to be backed up
53+
54+
# ==============================================================================
55+
# variables for auto-br script
56+
BACKUP_CLU_SERVER=""
57+
BACKUP_CLU_TOKEN=""
58+
RESTORE_CLU_SERVER=""
59+
RESTORE_CLU_TOKEN=""
60+
TARGET_CLUSTER_TYPE="same" # determines if restoring to the same cluster or to a different cluster. Values are "same" and "diff"
61+
BACKUP_NAME="automationtest-20250806160542" # always necessary for either backup or restore

br-testing-automation/fusion-backup-setup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ RESTORE_SETUP="false"
2424

2525
BASE_DIR=$(cd $(dirname "$0")/$(dirname "$(readlink $0)") && pwd -P)
2626
. ../cp3pt0-deployment/common/utils.sh
27-
source ${BASE_DIR}/env.properties
27+
source ${BASE_DIR}/env-fusion.properties
2828

2929
function main(){
3030
parse_arguments "$@"

velero/restore/common-service-db/cs-db-restore-job.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ spec:
1111
- sh
1212
- -c
1313
- /cs-db/br_cs-db.sh restore <cs-db namespace>
14-
image: icr.io/cpopen/cpfs/cpfs-utils:4.3.0 #4.1.0 if using CS 4.1, 4.2.0 if using CS 4.2
14+
image: icr.io/cpopen/cpfs/cpfs-utils:4.6.0 #4.1.0 if using CS 4.1, 4.2.0 if using CS 4.2
1515
imagePullPolicy: Always
1616
name: cs-db-restore-job
1717
resources:
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
apiVersion: batch/v1
2+
kind: Job
3+
metadata:
4+
name: lsr-restore-job
5+
namespace: <lsr namespace>
6+
spec:
7+
template:
8+
spec:
9+
containers:
10+
- command:
11+
- sh
12+
- -c
13+
- /lsr/br_lsr.sh <lsr namespace> restore
14+
image: icr.io/cpopen/cpfs/cpfs-utils:4.6.0 #4.1.0 if using CS 4.1, 4.2.0 if using CS 4.2
15+
imagePullPolicy: Always
16+
name: lsr-restore-job
17+
resources:
18+
limits:
19+
cpu: 500m
20+
ephemeral-storage: 512Mi
21+
memory: 512Mi
22+
requests:
23+
cpu: 200m
24+
ephemeral-storage: 128Mi
25+
memory: 256Mi
26+
securityContext:
27+
allowPrivilegeEscalation: false
28+
capabilities:
29+
drop:
30+
- ALL
31+
runAsNonRoot: true
32+
terminationMessagePath: /dev/termination-log
33+
terminationMessagePolicy: File
34+
volumeMounts:
35+
- mountPath: /lsr/lsr-backup
36+
name: lsr-backup-mount
37+
- name: scripts
38+
mountPath: "/lsr"
39+
dnsPolicy: ClusterFirst
40+
restartPolicy: OnFailure
41+
schedulerName: default-scheduler
42+
securityContext:
43+
runAsNonRoot: true
44+
serviceAccount: lsr-backup-sa
45+
serviceAccountName: lsr-backup-sa
46+
terminationGracePeriodSeconds: 30
47+
volumes:
48+
- name: lsr-backup-mount
49+
persistentVolumeClaim:
50+
claimName: lsr-backup-pvc
51+
- name: scripts
52+
configMap:
53+
name: lsr-br-configmap
54+
defaultMode: 0777

velero/restore/zen/zen5-restore-job.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ spec:
1111
- sh
1212
- -c
1313
- /zen5/restore_zen5.sh <zenservice namespace> <zenservice name>
14-
image: icr.io/cpopen/cpfs/cpfs-utils:4.3.0 #4.1.0 if using CS 4.1, 4.2.0 if using CS 4.2
14+
image: icr.io/cpopen/cpfs/cpfs-utils:4.6.0 #4.1.0 if using CS 4.1, 4.2.0 if using CS 4.2
1515
imagePullPolicy: Always
1616
name: zen5-restore-job
1717
resources:

0 commit comments

Comments
 (0)