Note:

Maximize Data Protection using OCI Object Storage for Longhorn backups

Introduction

Data storage and backup are essential parts of any infrastructure. With the increasing demand for cloud-based solutions, it is important to choose a storage option that can keep up with the growing needs of organizations.

Oracle Cloud Infrastructure (OCI) Object Storage is an internet-scale, high-performance storage platform that offers reliable and cost-efficient data durability. The Object Storage service can store an unlimited amount of unstructured data of any content type, including analytic data and rich content, like images and videos.

Longhorn is an open-source, distributed block storage system for Kubernetes that provides persistent storage for stateful applications. Longhorn backups are a crucial part of any disaster recovery plan. They provide a way to protect your data in the event of data loss or corruption, making it possible to quickly recover from any unexpected incidents. By using Longhorn backups, you can reduce the risk of data loss and ensure that your data is always available when you need it.

Objective

Use Oracle Cloud S3 Compatible Object Storage to store Longhorn backups.

Prerequisites

Task 1: Enable S3 compatible API

Task 2: Generate secret keys

Task 3: Create Bucket

Task 4: Create a Kubernetes secret

  1. Convert the required information into Base64 format. Ensure to replace the below placeholders with the real values. The following code will give you Base64 converted string as the output.

    echo -n <OSS_URL> | base64
    echo -n <ACCESS_KEY> | base64
    echo -n <SECRET_KEY> | base64
    

    Note: : OSS_URL is the compatibility API URL: https://{bucketnamespace}.compat.objectstorage.{region}.oraclecloud.com, where you must replace the bucketnamespace and the region placeholders. Virtual host-style access is not supported.

  2. Create a Kubernetes spec file that will use this information to create a new Kubernetes secret.

    nano oci-secret.yaml
    
  3. Paste the following content and replace the placeholders.

    apiVersion: v1
    kind: Secret
    metadata:
      name: oci-secret
      namespace: longhorn-system
    type: Opaque
    data:
      AWS_ACCESS_KEY_ID: <base64_encoded_access_key>
      AWS_SECRET_ACCESS_KEY: <base64_encoded_secret_key>
      AWS_ENDPOINTS: <base64_encoded_bucket_url>
    
  4. Save the file and run the following command to apply.

    kubectl apply -f oci-secret.yaml
    

Once successful, you will see the following output.

secret output

Task 5: Configure Longhorn

  1. Open Longhorn UI in a browser and go to Setting, General.

  2. Scroll down to the Backup section. Set the Backup Target as s3://\<bucketname\>@\<oci-region\>/ and the Backup Target Credential Secret as  oci-secret and save.

  3. Go to the Backup section and make sure you do not see any error.

Configure Longhorn

Task 6: Create a backup and verify

  1. In the Longhorn UI, go to Volume, select a volume, and then click Snapshots and Backups.

  2. Click Create Backup.

This will create new backup and store it in the configured object storage bucket.

Volumes

Create Backup

Backup List

Task 7: Verify backup in the OCI Object Storage Bucket

Bucket Backup

Acknowledgments

Author - Mayank Kakani (OCI Cloud Architect)

More Learning Resources

Explore other labs on docs.oracle.com/learn or access more free learning content on the Oracle Learning YouTube channel. Additionally, visit education.oracle.com/learning-explorer to become an Oracle Learning Explorer.

For product documentation, visit Oracle Help Center.