Back to Tech Corner
DevOps

(DevOps August 2023) Kubernetes Persistent Volumes Backup using OADP

Most Kubernetes projects in production already have a way to be recreated; however, when it comes to restoring data from persistent volumes, that requires a separate solution. Red Hat OpenShift offers a solution, OADP that lets you backup and restore all Kubernetes resources, including persistent volumes.

What is OADP?

OpenShift APIs for Data Protection (OADP) is an operator that allows backup and restore workloads including persistent volumes.

OADP Mechanics

Back up and restoring volumes are done via Restic or CSI snapshots. Restic is a modern backup program that can back up your files, from Linux, BSD, Mac and Windows to many different storage types, including self-hosted and online services. Restic is a single executable that you can run without a server or complex setup effectively transferring the parts that actually changed in the files you back up by careful use of cryptography in every part of the process. This ensures that files can be restored when needed freely. Restic is entirely free to use and completely open source.

The Container Storage Interface (CSI) is a standard for exposing arbitrary block and file storage systems to containerized workloads on Container Orchestration Systems (COs) like Kubernetes. Container Storage Interface (CSI) snapshots does not need to specify a snapshot location as VolumeSnapshotClass CR to register the CSI driver is created as part of the setup.

Are there any limitations of backing up data with OADP?

  1. Pods need to be running for the corresponding persistent volumes to be backed up.
  2. Emptydir volumes cannot be backed up. Your workloads should not be storing important data in emptydir volumes, as these volumes are ephemeral.
  3. Persistent volumes cannot exist when doing a restore. This means that the corresponding persistent volume claims will need to be deleted explicitly before doing a restore.

Prerequisites for using OADP

  1. OpenShift cluster configured (using 4.12 for this demo)
  2. oc (OpenShift client) CLI
  3. Amazon Web Services (AWS) account
  4. AWS CLI

Process Overview

At a higher level, following are the steps at a high level how the process would go:

  • Install the OADP Operator
  • Create an S3 bucket for backups
  • Configure OADP to use S3 for backups
  • Deploy sample application
  • Back up the sample application
  • Simulate disaster event
  • Restore sample application from backup