From eeb9045bfe75ecbc331ac1aa0b15cdd4546f914b Mon Sep 17 00:00:00 2001 From: Allen Li <46284272+qpdpQ@users.noreply.github.com> Date: Mon, 22 Apr 2024 08:20:13 -0600 Subject: [PATCH] add restore singleton subscription (#1918) * add a new step to restore singleton subscription Signed-off-by: Allen Li * keep filename consistency Signed-off-by: Allen Li --------- Signed-off-by: Allen Li --- velero/backup/backup.yaml | 1 + .../restore-singleton-subscriptions.yaml | 20 ++++++ velero/restore/restore.sh | 65 ++++++++++++------- velero/schedule/schedule-common-services.yaml | 1 + 4 files changed, 64 insertions(+), 23 deletions(-) create mode 100644 velero/restore/restore-singleton-subscriptions.yaml diff --git a/velero/backup/backup.yaml b/velero/backup/backup.yaml index 69dfdd67f..e66768fa4 100644 --- a/velero/backup/backup.yaml +++ b/velero/backup/backup.yaml @@ -18,6 +18,7 @@ spec: operator: In values: - catalog + - singleton-subscription - subscription - operand - data diff --git a/velero/restore/restore-singleton-subscriptions.yaml b/velero/restore/restore-singleton-subscriptions.yaml new file mode 100644 index 000000000..2ae1bc9eb --- /dev/null +++ b/velero/restore/restore-singleton-subscriptions.yaml @@ -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 diff --git a/velero/restore/restore.sh b/velero/restore/restore.sh index e0c197c22..9a8c76ca2 100755 --- a/velero/restore/restore.sh +++ b/velero/restore/restore.sh @@ -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 @@ -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 diff --git a/velero/schedule/schedule-common-services.yaml b/velero/schedule/schedule-common-services.yaml index 051ad541c..fb47102fc 100644 --- a/velero/schedule/schedule-common-services.yaml +++ b/velero/schedule/schedule-common-services.yaml @@ -21,6 +21,7 @@ spec: values: - catalog - subscription + - singleton-subscription - operand - zen-data - mongo-data