Restoring 3scale API Management by using OADP
Restore Red Hat 3scale API Management components by restoring the backed up 3scale operator resources, MySQL database, and Redis database. This helps you to recover your 3scale deployment and resume API management services.
After the data has been restored, you can scale up the 3scale operator and deployment.
Restoring the 3scale API Management operator, secrets, and APIManager
Restore the Red Hat 3scale API Management operator resources, including the Secret and APIManager custom resources (CRs). This helps you to recover your 3scale operator configuration on the same or a different cluster.
Prerequisites
- You backed up the 3scale operator.
- You backed up the MySQL and Redis databases.
- You are restoring the database on the same cluster, where it was backed up.
If you are restoring the operator to a different cluster that you backed up from, install and configure OADP with
nodeAgentenabled on the destination cluster. Ensure that the OADP configuration is same as it was on the source cluster.
Procedure
-
Delete the 3scale operator custom resource definitions (CRDs) along with the
threescalenamespace by running the following command:$ oc delete project threescale"threescale" project deleted successfully -
Create a YAML file with the following configuration to restore the 3scale operator:
apiVersion: velero.io/v1kind: Restoremetadata:name: operator-installation-restorenamespace: openshift-adpspec:backupName: operator-install-backupexcludedResources:- nodes- events- events.events.k8s.io- backups.velero.io- restores.velero.io- resticrepositories.velero.io- csinodes.storage.k8s.io- volumeattachments.storage.k8s.io- backuprepositories.velero.ioitemOperationTimeout: 4h0m0swhere:
operator-install-backup- Specifies the name of the backup to restore the 3scale operator.
-
Restore the 3scale operator by running the following command:
$ oc create -f restore.yamlrestore.velerio.io/operator-installation-restore created -
Manually create the
s3-credentialsSecretobject by running the following command:$ oc apply -f - <<EOF---apiVersion: v1kind: Secretmetadata:name: s3-credentialsnamespace: threescalestringData:AWS_ACCESS_KEY_ID: <ID_123456>AWS_SECRET_ACCESS_KEY: <ID_98765544>AWS_BUCKET: <mybucket.example.com>AWS_REGION: <us-east-1>type: OpaqueEOFwhere:
<AWS_ACCESS_KEY_ID>- Specifies your AWS credentials ID.
<AWS_SECRET_ACCESS_KEY>- Specifies your AWS credentials KEY.
<mybucket.example.com>- Specifies your target bucket name.
<us-east-1>- Specifies the AWS region of your bucket.
-
Scale down the 3scale operator by running the following command:
$ oc scale deployment threescale-operator-controller-manager-v2 --replicas=0 -n threescaledeployment.apps/threescale-operator-controller-manager-v2 scaled -
Create a YAML file with the following configuration to restore the
Secret:apiVersion: velero.io/v1kind: Restoremetadata:name: operator-resources-secretsnamespace: openshift-adpspec:backupName: operator-resources-secretsexcludedResources:- nodes- events- events.events.k8s.io- backups.velero.io- restores.velero.io- resticrepositories.velero.io- csinodes.storage.k8s.io- volumeattachments.storage.k8s.io- backuprepositories.velero.ioitemOperationTimeout: 4h0m0swhere:
operator-resources-secrets- Specifies the name of the backup to restore the
Secret.
-
Restore the
Secretby running the following command:$ oc create -f restore-secrets.yamlrestore.velerio.io/operator-resources-secrets created -
Create a YAML file with the following configuration to restore APIManager:
Example restore-apimanager.yaml fileapiVersion: velero.io/v1kind: Restoremetadata:name: operator-resources-apimnamespace: openshift-adpspec:backupName: operator-resources-apimexcludedResources:- nodes- events- events.events.k8s.io- backups.velero.io- restores.velero.io- resticrepositories.velero.io- csinodes.storage.k8s.io- volumeattachments.storage.k8s.io- backuprepositories.velero.ioitemOperationTimeout: 4h0m0swhere:
operator-resources-apim- Specifies the name of the backup to restore the APIManager.
excludedResources- Specifies the resources that you do not want to restore.
-
Restore the APIManager by running the following command:
$ oc create -f restore-apimanager.yamlrestore.velerio.io/operator-resources-apim created -
Scale up the 3scale operator by running the following command:
$ oc scale deployment threescale-operator-controller-manager-v2 --replicas=1 -n threescaledeployment.apps/threescale-operator-controller-manager-v2 scaled
Restoring a MySQL database
Restore a MySQL database by scaling down Red Hat 3scale API Management components and creating a Velero Restore custom resource (CR). This helps you to recover your 3scale MySQL data, persistent volumes, and associated resources.
Do not delete the default PV and PVC associated with the database. If you do, your backups are deleted.
Prerequisites
- You restored the
Secretand APIManager custom resources (CRs).
Procedure
-
Scale down the Red Hat 3scale API Management operator by running the following command:
$ oc scale deployment threescale-operator-controller-manager-v2 --replicas=0 -n threescaleExample outputdeployment.apps/threescale-operator-controller-manager-v2 scaled -
Create the following script to scale down the 3scale operator:
$ vi ./scaledowndeployment.shExample script:for deployment in apicast-production apicast-staging backend-cron backend-listener backend-redis backend-worker system-app system-memcache system-mysql system-redis system-searchd system-sidekiq zync zync-database zync-que; dooc scale deployment/$deployment --replicas=0 -n threescaledone -
Scale down all the deployment 3scale components by running the following script:
$ ./scaledowndeployment.shExample outputdeployment.apps.openshift.io/apicast-production scaleddeployment.apps.openshift.io/apicast-staging scaleddeployment.apps.openshift.io/backend-cron scaleddeployment.apps.openshift.io/backend-listener scaleddeployment.apps.openshift.io/backend-redis scaleddeployment.apps.openshift.io/backend-worker scaleddeployment.apps.openshift.io/system-app scaleddeployment.apps.openshift.io/system-memcache scaleddeployment.apps.openshift.io/system-mysql scaleddeployment.apps.openshift.io/system-redis scaleddeployment.apps.openshift.io/system-searchd scaleddeployment.apps.openshift.io/system-sidekiq scaleddeployment.apps.openshift.io/zync scaleddeployment.apps.openshift.io/zync-database scaleddeployment.apps.openshift.io/zync-que scaled -
Delete the
system-mysqlDeploymentobject by running the following command:$ oc delete deployment system-mysql -n threescaleExample outputWarning: apps.openshift.io/v1 deployment is deprecated in v4.14+, unavailable in v4.10000+deployment.apps.openshift.io "system-mysql" deleted -
Create the following YAML file to restore the MySQL database:
Example restore-mysql.yaml fileapiVersion: velero.io/v1kind: Restoremetadata:name: restore-mysqlnamespace: openshift-adpspec:backupName: mysql-backupexcludedResources:- nodes- events- events.events.k8s.io- backups.velero.io- restores.velero.io- csinodes.storage.k8s.io- volumeattachments.storage.k8s.io- backuprepositories.velero.io- resticrepositories.velero.iohooks:resources:- name: restoreDBpostHooks:- exec:command:- /bin/sh- '-c'- >sleep 30mysql -h 127.0.0.1 -D system -u root--password=$MYSQL_ROOT_PASSWORD </var/lib/mysqldump/data/dump.sqlcontainer: system-mysqlexecTimeout: 80sonError: FailwaitTimeout: 5mitemOperationTimeout: 1h0m0srestorePVs: truewhere:
mysql-backup- Specifies the name of the MySQL backup to restore.
/var/lib/mysqldump/data/dump.sql- Specifies the path where the data is restored from.
-
Restore the MySQL database by running the following command:
$ oc create -f restore-mysql.yamlrestore.velerio.io/restore-mysql created
Verification
-
Verify that the
PodVolumeRestorerestore is completed by running the following command:$ oc get podvolumerestores.velero.io -n openshift-adpExample outputNAME NAMESPACE POD UPLOADER TYPE VOLUME STATUS TOTALBYTES BYTESDONE AGErestore-mysql-rbzvm threescale system-mysql-2-kjkhl kopia mysql-storage Completed 771879108 771879108 40mrestore-mysql-z7x7l threescale system-mysql-2-kjkhl kopia example-claim Completed 380415 380415 40m -
Verify that the additional PVC has been restored by running the following command:
$ oc get pvc -n threescaleExample outputNAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS VOLUMEATTRIBUTESCLASS AGEbackend-redis-storage Bound pvc-3dca410d-3b9f-49d4-aebf-75f47152e09d 1Gi RWO gp3-csi <unset> 68mexample-claim Bound pvc-cbaa49b0-06cd-4b1a-9e90-0ef755c67a54 1Gi RWO gp3-csi <unset> 57mmysql-storage Bound pvc-4549649f-b9ad-44f7-8f67-dd6b9dbb3896 1Gi RWO gp3-csi <unset> 68msystem-redis-storage Bound pvc-04dadafd-8a3e-4d00-8381-6041800a24fc 1Gi RWO gp3-csi <unset> 68msystem-searchd Bound pvc-afbf606c-d4a8-4041-8ec6-54c5baf1a3b9 1Gi RWO gp3-csi <unset> 68m
Restoring the back-end Redis database
Restore the back-end Redis database by creating a Restore custom resource (CR) that excludes non-essential cluster resources. This helps you to recover the Redis data store as part of the Red Hat 3scale API Management restoration process.
Prerequisites
- You restored the Red Hat 3scale API Management operator resources,
Secret, and APIManager custom resources. - You restored the MySQL database.
Procedure
-
Delete the
backend-redisdeployment by running the following command:$ oc delete deployment backend-redis -n threescaleWarning: apps.openshift.io/v1 deployment is deprecated in v4.14+, unavailable in v4.10000+deployment.apps.openshift.io "backend-redis" deleted -
Create a YAML file with the following configuration to restore the Redis database:
Example restore-backend.yaml fileapiVersion: velero.io/v1kind: Restoremetadata:name: restore-backendnamespace: openshift-adpspec:backupName: redis-backupexcludedResources:- nodes- events- events.events.k8s.io- backups.velero.io- restores.velero.io- resticrepositories.velero.io- csinodes.storage.k8s.io- volumeattachments.storage.k8s.io- backuprepositories.velero.ioitemOperationTimeout: 1h0m0srestorePVs: truewhere:
redis-backup- Specifies the name of the Redis backup to restore.
-
Restore the Redis database by running the following command:
$ oc create -f restore-backend.yamlrestore.velerio.io/restore-backend created
Verification
-
Verify that the
PodVolumeRestorerestore is completed by running the following command:$ oc get podvolumerestores.velero.io -n openshift-adpNAME NAMESPACE POD UPLOADER TYPE VOLUME STATUS TOTALBYTES BYTESDONE AGErestore-backend-jmrwx threescale backend-redis-1-bsfmv kopia backend-redis-storage Completed 76123 76123 21m
Scaling up the 3scale API Management operator and deployment
Scale up the Red Hat 3scale API Management operator and any deployment that was manually scaled down during the restore process. This helps you to bring your 3scale installation back to a fully functional state matching the backed-up configuration.
Prerequisites
- You restored the 3scale operator resources, and both the
Secretand APIManager custom resources (CRs). - You restored the MySQL and back-end Redis databases.
- Ensure that there are no scaled up deployments or no extra pods running. There might be some
system-mysqlorbackend-redispods running detached from deployments after restoration, which can be removed after the restoration is successful.
Procedure
-
Scale up the 3scale operator by running the following command:
$ oc scale deployment threescale-operator-controller-manager-v2 --replicas=1 -n threescaleExample outputdeployment.apps/threescale-operator-controller-manager-v2 scaled -
Ensure that the 3scale pod is running to verify if the 3scale operator was deployed by running the following command:
$ oc get pods -n threescaleExample outputNAME READY STATUS RESTARTS AGEthreescale-operator-controller-manager-v2-79546bd8c-b4qbh 1/1 Running 0 2m5s -
Create the following script to scale up the deployments:
$ vi ./scaledeployment.shExample script file:for deployment in apicast-production apicast-staging backend-cron backend-listener backend-redis backend-worker system-app system-memcache system-mysql system-redis system-searchd system-sidekiq zync zync-database zync-que; dooc scale deployment/$deployment --replicas=1 -n threescaledone -
Scale up the deployments by running the following script:
$ ./scaledeployment.shExample outputdeployment.apps.openshift.io/apicast-production scaleddeployment.apps.openshift.io/apicast-staging scaleddeployment.apps.openshift.io/backend-cron scaleddeployment.apps.openshift.io/backend-listener scaleddeployment.apps.openshift.io/backend-redis scaleddeployment.apps.openshift.io/backend-worker scaleddeployment.apps.openshift.io/system-app scaleddeployment.apps.openshift.io/system-memcache scaleddeployment.apps.openshift.io/system-mysql scaleddeployment.apps.openshift.io/system-redis scaleddeployment.apps.openshift.io/system-searchd scaleddeployment.apps.openshift.io/system-sidekiq scaleddeployment.apps.openshift.io/zync scaleddeployment.apps.openshift.io/zync-database scaleddeployment.apps.openshift.io/zync-que scaled -
Get the
3scale-adminroute to log in to the 3scale UI by running the following command:$ oc get routes -n threescaleExample outputNAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARDbackend backend-3scale.apps.custom-cluster-name.openshift.com backend-listener http edge/Allow Nonezync-3scale-api-b4l4d api-3scale-apicast-production.apps.custom-cluster-name.openshift.com apicast-production gateway edge/Redirect Nonezync-3scale-api-b6sns api-3scale-apicast-staging.apps.custom-cluster-name.openshift.com apicast-staging gateway edge/Redirect Nonezync-3scale-master-7sc4j master.apps.custom-cluster-name.openshift.com system-master http edge/Redirect Nonezync-3scale-provider-7r2nm 3scale-admin.apps.custom-cluster-name.openshift.com system-provider http edge/Redirect Nonezync-3scale-provider-mjxlb 3scale.apps.custom-cluster-name.openshift.com system-developer http edge/Redirect NoneIn this example,
3scale-admin.apps.custom-cluster-name.openshift.comis the 3scale-admin URL. -
Use the URL from this output to log in to the 3scale operator as an administrator. You can verify that the data, when you took backup, is available.