Home

Awesome

Cloud Native Backup - Hands-On Lab

Introduction

This project is a hands-on lab to demo how to back up a cloud native application. For this lab we will add and test a backup tool to the inventory database of the BlueCompute reference application.

Why is backup important for Cloud Native applications?

Well, you might be wondering if you really need a backup, if your application is truly cloud native. Although your application can be highly available and supports disaster recovery, backup can still be needed:

Hands-on lab architecture

For this hands-on lab, we will use the following architecture:

Graph

This is a simple backup solution, as we backup and restore the MySQL work directory

In a true production environment, it is very important to understand the business and technical requirements for high-availability to design the right architecture. There is no "one-size fits all" solution!

Pre-requisites

Summary of the hands-on labs steps

The main steps of this lab are:

  1. deploy the Bluecompute application
  2. configure Cloud Object Storage for backups
  3. do a backup of the inventory database to Cloud Object Storage
  4. simulate a problem with MySQL data
  5. restore the MySQL data from Cloud Object Storage
  6. verify that the database data is correctly restored

1 - Deploy the BlueCompute application

Follow the instructions on this project to deploy BlueCompute in the US South region: Deploy BlueCompute

When the deployment is finished, you should be able to access BlueCompute web page and see the catalog with 12 items, including the ones displayed in the following screen:

Catalog

2 - Configure Cloud Object Storage for backups

Create a Cloud Object Storage account

Follow these steps to create a Cloud Object Storage account:

Storage name

Bind the Object Storage credentials to the Kubernetes cluster

bx cf services | grep Object-Storage
export CLUSTER_NAME=`bx cs clusters | grep normal | awk '{print $1;}'`
bx cs cluster-service-bind $CLUSTER_NAME default bluecompute-storage

3 - Do a backup of the inventory database to Cloud Object Storage

git clone https://github.com/ibm-cloud-architecture/refarch-cloudnative-resiliency.git
cd refarch-cloudnative-resiliency
git checkout kube-int
cd mysql/chart
helm upgrade \
  --reuse-values \
  --set mysql.backup.enabled=true \
  --set mysql.backup.backupName=bluecompute-storage \
  --set mysql.backup.objStoreSecretName=binding-bluecompute-storage \
  $(helm list -q inventory-mysql) \
  ibmcase-mysql

You can validate that the backup container has been created by checking the number of containers in the inventory-mysql POD:

kubectl get po | grep inventory-mysql

You should see the following result:

default-inventory-mysql-ibmcase-mysql-4154021736-qh5l7   2/2       Running   0          5m
kubectl logs $(kubectl get po | grep inventory-mysql | awk '{print $1;}') -c inventory-backup-container

The backup has completed successfully if you see an output similar to the following:

[2017-06-23 13:54:27,570] [backup : 117] [INFO] Full backup completed

If you look now at the Cloud Object Storage, you'll see a few Object Containers created:

Storage screenshot

4 - Simulate a problem with MySQL data

Remove database records

Run the following steps to simulate a database corruption:

Refresh cache

Now the database records are cached in ElasticSearch, so we need to destroy the ElasticSearch POD in order to refresh the data.

5 - Restore the MySQL data from Cloud Object Storage

To restore the backup we will stop the MySQL database, deploy a restore job to kubernetes, restart MySQL and kill the cache.

6 - Verify that the database data is correctly restored

Catalog