Skip to content

Commit

Permalink
add restore singleton subscription (#1918)
Browse files Browse the repository at this point in the history
* add a new step to restore singleton subscription

Signed-off-by: Allen Li <[email protected]>

* keep filename consistency

Signed-off-by: Allen Li <[email protected]>

---------

Signed-off-by: Allen Li <[email protected]>
  • Loading branch information
qpdpQ authored Apr 22, 2024
1 parent 9e62d36 commit eeb9045
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 23 deletions.
1 change: 1 addition & 0 deletions velero/backup/backup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ spec:
operator: In
values:
- catalog
- singleton-subscription
- subscription
- operand
- data
Expand Down
20 changes: 20 additions & 0 deletions velero/restore/restore-singleton-subscriptions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: velero.io/v1
kind: Restore
metadata:
name: restore-singleton-subscription
namespace: velero
spec:
backupName: __BACKUP_NAME__
excludedResources:
- nodes
- events
- events.events.k8s.io
- backups.velero.io
- restores.velero.io
- resticrepositories.velero.io
hooks: {}
includedNamespaces:
- '*'
labelSelector:
matchLabels:
foundationservices.cloudpak.ibm.com: singleton-subscription
65 changes: 42 additions & 23 deletions velero/restore/restore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,48 @@ done
echo "CHECK THE OPERATORHUB on the openshift console and see if the foundational services are available in the catalog. Hit Enter once you see them:"
read ANS

# Restore singleton subscription
# This restores cert-manager and licensing subscription
echo "Restoring the subscriptions..."
sed -i s/__BACKUP_NAME__/$BACKUP_NAME/g restore-singleton-subscriptions.yaml
oc apply -f restore--singleton-subscriptions.yaml
sleep 5
sed -i s/$BACKUP_NAME/__BACKUP_NAME__/g restore-singleton-subscriptions.yaml

echo "You can watch the subscriptions come up in the Openshift Console. Go to Operators -> Installed Operators make sure the project selected is $CERT_MGR_NAMESPACE."
oc get pod -A | grep cert-manager-controller | grep Running
while [ $? -ne 0 ]
do
echo "Waiting for cert-manager-controller pod to be running..."
oc get pod -A | grep cert-manager
sleep 15
oc get pod -A | grep cert-manager-controller | grep Running
done

# Restore licensing and cert-manager data
# There are a number of configmaps, CRDs, Issuers, and Certificates that get restored here
# Certificates usually take the longest, so we watch for those.
echo "Now restoring licensing and cert-manager data. Hit Enter:"
read ANS
sed -i s/__BACKUP_NAME__/$BACKUP_NAME/g restore-licensing.yaml
oc apply -f restore-licensing.yaml
sleep 5
sed -i s/$BACKUP_NAME/__BACKUP_NAME__/g restore-licensing.yaml

sed -i s/__BACKUP_NAME__/$BACKUP_NAME/g restore-cert-manager.yaml
oc apply -f restore-cert-manager.yaml
sleep 5
sed -i s/$BACKUP_NAME/__BACKUP_NAME__/g restore-cert-manager.yaml
## Wait on certificates to populate
oc get certificates -n $CS_NAMESPACE | grep cs-ca-certificate
while [ $? -ne 0 ]
do
echo "Waiting on certificates to be populated..."
sleep 10
oc get certificates -n $CS_NAMESPACE | grep cs-ca-certificate
done


# Restore subscription
# This just restores the common-services subscription
# It's done restoring once ODLM is running
Expand Down Expand Up @@ -166,29 +208,6 @@ sed -i s/$BACKUP_NAME/__BACKUP_NAME__/g restore-commonservice.yaml
##Check status of common-service, should be Phase: Succeeded
oc get commonservice common-service -n $CS_NAMESPACE

# Restore licensing and cert-manager data
# There are a number of configmaps, CRDs, Issuers, and Certificates that get restored here
# Certificates usually take the longest, so we watch for those.
echo "Now restoring licensing and cert-manager data. Hit Enter:"
read ANS
sed -i s/__BACKUP_NAME__/$BACKUP_NAME/g restore-licensing.yaml
oc apply -f restore-licensing.yaml
sleep 5
sed -i s/$BACKUP_NAME/__BACKUP_NAME__/g restore-licensing.yaml

sed -i s/__BACKUP_NAME__/$BACKUP_NAME/g restore-cert-manager.yaml
oc apply -f restore-cert-manager.yaml
sleep 5
sed -i s/$BACKUP_NAME/__BACKUP_NAME__/g restore-cert-manager.yaml
## Wait on certificates to populate
oc get certificates -n $CS_NAMESPACE | grep cs-ca-certificate
while [ $? -ne 0 ]
do
echo "Waiting on certificates to be populated..."
sleep 10
oc get certificates -n $CS_NAMESPACE | grep cs-ca-certificate
done

echo "Now restoring the operand request. Hit Enter:"
read ANS

Expand Down
1 change: 1 addition & 0 deletions velero/schedule/schedule-common-services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ spec:
values:
- catalog
- subscription
- singleton-subscription
- operand
- zen-data
- mongo-data
Expand Down

0 comments on commit eeb9045

Please sign in to comment.