|
| 1 | +# Guide: back up and restore persistent workloads on OpenShift using OADP and ODF |
| 2 | +<!-- |
| 3 | +We want to publish a blog that contains a guided example of backing up and restoring a CSI-based workload. This should contain: |
| 4 | +
|
| 5 | +- OADP Overview |
| 6 | +- Installation |
| 7 | +- Application Overview |
| 8 | +- Backup/Restore of app showing CSI functionality |
| 9 | +- Upcoming features (Data Mover) |
| 10 | +--> |
| 11 | + |
| 12 | +OpenShift API for Data Protection (OADP) enables backup, restore, and disaster recovery of applications on an OpenShift cluster. Data that can be protected with OADP include k8s resource objects, persistent volumes, and internal images. |
| 13 | +The OpenShift API for Data Protection (OADP) is designed to protect Application Workloads on a single OpenShift cluster. |
| 14 | + |
| 15 | +Red Hat® OpenShift® Data Foundation—previously Red Hat OpenShift Container Storage—is software-defined storage for containers. Engineered as the data and storage services platform for Red Hat OpenShift, Red Hat OpenShift Data Foundation helps teams develop and deploy applications quickly and efficiently across clouds. |
| 16 | + |
| 17 | +In this guide, we will cover: |
| 18 | +- Operators installation |
| 19 | + <!-- - Local Storage Operator --> |
| 20 | + - OpenShift Data Foundation |
| 21 | + - OpenShift API for Data Protection Operator |
| 22 | +- Application deployment |
| 23 | +- Application protection |
| 24 | +- A disaster scenario |
| 25 | +- Application recovery from disaster |
| 26 | +## Pre-requisites |
| 27 | +- Terminal environment |
| 28 | + - Your terminal has the following commands |
| 29 | + - [oc](https://access.redhat.com/documentation/en-us/openshift_container_platform/4.9/html/cli_tools/openshift-cli-oc) binary |
| 30 | + - [git](https://git-scm.com/downloads) binary |
| 31 | + - Alternatively enter prepared environment in your terminal with `docker run -it ghcr.io/kaovilai/oadp-cli:v1.0.1 bash` |
| 32 | + - source can be found at https://github.com/kaovilai/oadp-cli |
| 33 | +- [Authenticate as Cluster Admin inside your environment](https://access.redhat.com/documentation/en-us/openshift_container_platform/4.9/html/cli_tools/openshift-cli-oc#cli-logging-in_cli-developer-commands) of an OpenShift 4.9 Cluster. |
| 34 | +- Your cluster meets the minimum requirement for [OpenShift Data Foundation](https://access.redhat.com/documentation/en-us/red_hat_openshift_data_foundation/4.9/html/planning_your_deployment/infrastructure-requirements_rhodf#minimum-deployment-resource-requirements) in Internal Mode deployment |
| 35 | + - 3 worker nodes, each with at least: |
| 36 | + - 8 logical CPU |
| 37 | + - 24 GiB memory |
| 38 | + - 1+ storage devices |
| 39 | + |
| 40 | +## Installing OpenShift Data Foundation Operator |
| 41 | +We will be using OpenShift Data Foundation to simplify application deployment across cloud providers which will be covered in the next section. |
| 42 | + |
| 43 | +1. Open the OpenShift Web Console by navigating to the url below, make sure you are in Administrator view, not Developer. |
| 44 | + |
| 45 | + ``` |
| 46 | + oc get route console -n openshift-console -ojsonpath="{.spec.host}" |
| 47 | + ``` |
| 48 | + Authenticate with your credentials if necessary. |
| 49 | + |
| 50 | +<!-- 2. Navigate to *OperatorHub* from the side menu and install **Local Storage Operator** |
| 51 | + |
| 52 | +  |
| 53 | + |
| 54 | + Leaving everything as default, click through until the installation finished. --> |
| 55 | +2. Navigate to *OperatorHub*, search for and install **OpenShift Data Foundation** |
| 56 | + |
| 57 | +  |
| 58 | + |
| 59 | +### Creating StorageSystem |
| 60 | + |
| 61 | + |
| 62 | + |
| 63 | +3. Click *Create StorageSystem* button after it turned blue. |
| 64 | + |
| 65 | +<!-- 4. Select *Create a new StorageClass using local storage devices* and click *Next*. |
| 66 | +  --> |
| 67 | +4. Select *Create a new StorageClass* and follow the *Creating an OpenShift Data Foundation cluster* steps for your cloud provider. |
| 68 | + - [Amazon Web Services(AWS)](https://access.redhat.com/documentation/en-us/red_hat_openshift_data_foundation/4.9/html/deploying_openshift_data_foundation_using_amazon_web_services/deploy-using-dynamic-storage-devices-aws#creating-an-openshift-data-foundation-service_cloud-storage) |
| 69 | + - [Google Cloud (GCP)](https://access.redhat.com/documentation/en-us/red_hat_openshift_data_foundation/4.9/html/deploying_and_managing_openshift_data_foundation_using_google_cloud/deploying_openshift_data_foundation_on_google_cloud#creating-an-openshift-data-foundation-service_gcp) |
| 70 | + - [Microsoft Azure](https://access.redhat.com/documentation/en-us/red_hat_openshift_data_foundation/4.9/html/deploying_openshift_data_foundation_using_microsoft_azure_and_azure_red_hat_openshift/deploying-openshift-data-foundation-on-microsoft-azure_azure#creating-an-openshift-data-foundation-service_azure) |
| 71 | + - [VMware vSphere](https://access.redhat.com/documentation/en-us/red_hat_openshift_data_foundation/4.9/html/deploying_openshift_data_foundation_on_vmware_vsphere/deploy-using-dynamic-storage-devices-vmware#creating-an-openshift-data-foundation-service_cloud-storage) |
| 72 | + |
| 73 | +5. Navigate to *Storage* > *Object Bucket CLaim* and click *Create Object Bucket CLaim* |
| 74 | +  |
| 75 | + |
| 76 | +6. set the following values: |
| 77 | + - ObjectBucketClaim Name: `oadp-bucket` |
| 78 | + - StorageClass: `openshift-storage.noobaa.io` |
| 79 | + - BucketClass: `noobaa-default-bucket-class` |
| 80 | + |
| 81 | +  |
| 82 | + |
| 83 | +7. Click *Create* |
| 84 | + |
| 85 | +  |
| 86 | + When the *Status* is *Bound*, the bucket is ready. |
| 87 | + |
| 88 | +8. Click on oadp-secret in the bottom left to view bucket secrets |
| 89 | +9. Click Reveal values to see the bucket secret values. Copy data from *AWS_ACCESS_KEY_ID* and *AWS_SECRET_ACCESS_KEY* and save it as we'll need it later when installing the OADP Operator. |
| 90 | +## Deploying an application |
| 91 | +Since we are using OpenShift Data Foundation, we can use common application definition across cloud providers. |
| 92 | + |
| 93 | +Clone our demo apps repository and enter the cloned repository. |
| 94 | +```sh |
| 95 | +git clone https://github.com/kaovilai/mig-demo-apps --single-branch -b oadp-blog-rocketchat |
| 96 | +cd mig-demo-apps |
| 97 | +``` |
| 98 | + |
| 99 | +Apply rocket chat manifests. |
| 100 | +```sh |
| 101 | +oc apply -f apps/rocket-chat/manifests/ |
| 102 | +``` |
| 103 | + |
| 104 | +Navigate to rocket-chat setup wizard url obtained by this command into your browser. |
| 105 | +``` |
| 106 | +oc get route rocket-chat -n rocket-chat -ojsonpath="{.spec.host}" |
| 107 | +``` |
| 108 | + |
| 109 | +Enter your setup information. remember it as we may need it later. |
| 110 | + |
| 111 | +Skip to step 4, select "Keep standalone", and "continue". |
| 112 | + |
| 113 | +Press "Go to your workspace" |
| 114 | + |
| 115 | + |
| 116 | + |
| 117 | +"Enter" |
| 118 | + |
| 119 | +Go to Channel #general and type some message |
| 120 | + |
| 121 | + |
| 122 | + |
| 123 | +## Installing OpenShift API for Data Protection Operator |
| 124 | +You can install the OADP Operator from the Openshift's OperatorHub. |
| 125 | +You can search for the operator using keywords such as `oadp` or `velero`. |
| 126 | + |
| 127 | + |
| 128 | + |
| 129 | +Now click on `Install` |
| 130 | + |
| 131 | +<!--  --> |
| 132 | + |
| 133 | +Finally, click on `Install` again. This will create namespace `openshift-adp` |
| 134 | +if it does not exist, and install the OADP operator in it. |
| 135 | + |
| 136 | +<!--  --> |
| 137 | + |
| 138 | +### Create credentials secret for OADP Operator to use |
| 139 | +We will now create secret `cloud-credentials` using values obtained from Object Bucket Claim in namespace `openshift-adp`. |
| 140 | + |
| 141 | +From OpenShift Web Console side bar navigate to *Workloads* > *Secrets* and click *Create* > Key/value secret |
| 142 | + |
| 143 | + |
| 144 | +Fill out the following fields: |
| 145 | +- Secret name: `cloud-credentials` |
| 146 | +- Value: |
| 147 | + - Replace the values with your own values and enter it in the value field. |
| 148 | + ``` |
| 149 | + [default] |
| 150 | + aws_access_key_id=<INSERT_VALUE> |
| 151 | + aws_secret_access_key=<INSERT_VALUE> |
| 152 | + ``` |
| 153 | + *Note:* Do not use quotes while putting values in place of INSERT_VALUE Placeholders |
| 154 | +
|
| 155 | + |
| 156 | +
|
| 157 | +<!-- ``` |
| 158 | +$ oc create secret generic cloud-credentials --namespace openshift-adp --from-file cloud=<CREDENTIALS_FILE_PATH> |
| 159 | +``` --> |
| 160 | +
|
| 161 | +### Create the DataProtectionApplication Custom Resource |
| 162 | +
|
| 163 | +Create an instance of the DataProtectionApplication (DPA) CR by clicking on `Create Instance` as highlighted below: |
| 164 | +
|
| 165 | + |
| 166 | +
|
| 167 | +The Velero instance can be created by selecting configurations using the OCP Web UI or by using a YAML file as mentioned below. |
| 168 | +
|
| 169 | +Finally, set the CR spec values appropriately, and click on `Create`. |
| 170 | +
|
| 171 | +The CR values are mentioned for ease of use. Please remember to mention `default: true` in backupStorageLocations if you intend on using the default backup storage location as shown below. |
| 172 | +
|
| 173 | +``` |
| 174 | +apiVersion: oadp.openshift.io/v1alpha1 |
| 175 | +kind: DataProtectionApplication |
| 176 | +metadata: |
| 177 | + name: dpa-sample |
| 178 | +spec: |
| 179 | + configuration: |
| 180 | + velero: |
| 181 | + defaultPlugins: |
| 182 | + - openshift |
| 183 | + - aws |
| 184 | + restic: |
| 185 | + enable: true |
| 186 | + backupLocations: |
| 187 | + - name: default |
| 188 | + velero: |
| 189 | + provider: aws |
| 190 | + default: true |
| 191 | + objectStorage: |
| 192 | + bucket: my-bucket |
| 193 | + prefix: my-prefix |
| 194 | + config: |
| 195 | + region: us-east-1 |
| 196 | + profile: "default" |
| 197 | + credential: |
| 198 | + name: cloud-credentials |
| 199 | + key: cloud |
| 200 | + snapshotLocations: |
| 201 | + - name: default |
| 202 | + velero: |
| 203 | + provider: aws |
| 204 | + config: |
| 205 | + region: us-west-2 |
| 206 | + profile: "default" |
| 207 | + |
| 208 | +``` |
| 209 | +
|
| 210 | + |
| 211 | +
|
| 212 | +### Verify install |
| 213 | +
|
| 214 | +To verify all of the correct resources have been created, the following command |
| 215 | +`oc get all -n openshift-adp` should look similar to: |
| 216 | +
|
| 217 | +``` |
| 218 | +NAME READY STATUS RESTARTS AGE |
| 219 | +pod/oadp-operator-controller-manager-67d9494d47-6l8z8 2/2 Running 0 2m8s |
| 220 | +pod/oadp-velero-sample-1-aws-registry-5d6968cbdd-d5w9k 1/1 Running 0 95s |
| 221 | +pod/restic-9cq4q 1/1 Running 0 94s |
| 222 | +pod/restic-m4lts 1/1 Running 0 94s |
| 223 | +pod/restic-pv4kr 1/1 Running 0 95s |
| 224 | +pod/velero-588db7f655-n842v 1/1 Running 0 95s |
| 225 | + |
| 226 | +NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE |
| 227 | +service/oadp-operator-controller-manager-metrics-service ClusterIP 172.30.70.140 <none> 8443/TCP 2m8s |
| 228 | +service/oadp-velero-sample-1-aws-registry-svc ClusterIP 172.30.130.230 <none> 5000/TCP 95s |
| 229 | + |
| 230 | +NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE |
| 231 | +daemonset.apps/restic 3 3 3 3 3 <none> 96s |
| 232 | + |
| 233 | +NAME READY UP-TO-DATE AVAILABLE AGE |
| 234 | +deployment.apps/oadp-operator-controller-manager 1/1 1 1 2m9s |
| 235 | +deployment.apps/oadp-velero-sample-1-aws-registry 1/1 1 1 96s |
| 236 | +deployment.apps/velero 1/1 1 1 96s |
| 237 | + |
| 238 | +NAME DESIRED CURRENT READY AGE |
| 239 | +replicaset.apps/oadp-operator-controller-manager-67d9494d47 1 1 1 2m9s |
| 240 | +replicaset.apps/oadp-velero-sample-1-aws-registry-5d6968cbdd 1 1 1 96s |
| 241 | +replicaset.apps/velero-588db7f655 1 1 1 96s |
| 242 | +``` |
| 243 | +
|
| 244 | +## Back up application |
| 245 | +
|
| 246 | +## Uhh what? Disasters? |
| 247 | +
|
| 248 | +## Restore application |
| 249 | +
|
| 250 | +## Conclusion |
| 251 | +
|
| 252 | +### Remove workloads from this guide |
| 253 | +```sh |
| 254 | +oc delete ns openshift-adp rocket-chat openshift-storage |
| 255 | +``` |
| 256 | + |
| 257 | +If openshift-storage namespace is stuck, follow [troubleshooting guide](https://access.redhat.com/documentation/en-us/red_hat_openshift_data_foundation/4.9/html/troubleshooting_openshift_data_foundation/troubleshooting-and-deleting-remaining-resources-during-uninstall_rhodf). |
0 commit comments