Note:
- This tutorial requires access to Oracle Cloud. To sign up for a free account, see Get started with Oracle Cloud Infrastructure Free Tier.
- It uses example values for Oracle Cloud Infrastructure credentials, tenancy, and compartments. When completing your lab, substitute these values with ones specific to your cloud environment.
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
-
Access to an Oracle Cloud Tenancy
-
OKE cluster with Longhorn deployed in your tenancy
-
All the policy setups for OKE and OCI Object Storage in place
Task 1: Enable S3 compatible API
-
Make sure you have S3 compatibility API enabled in your tenancy. For more information, follow this documentation.
Task 2: Generate secret keys
-
Generate the secret keys. For more information, follow this documentation.
-
Keep the generated keys safe. We will require them in a later step.
Task 3: Create Bucket
-
Create a Bucket in the S3 compatible compartment you selected in Task 1.
-
Also make sure you add all the required policies for the Kubernetes service to be able to access this bucket.
Task 4: Create a Kubernetes secret
-
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 theregion
placeholders. Virtual host-style access is not supported. -
Create a Kubernetes spec file that will use this information to create a new Kubernetes secret.
nano oci-secret.yaml
-
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>
-
Save the file and run the following command to apply.
kubectl apply -f oci-secret.yaml
Once successful, you will see the following output.
Task 5: Configure Longhorn
-
Open Longhorn UI in a browser and go to Setting, General.
-
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. -
Go to the Backup section and make sure you do not see any error.
Task 6: Create a backup and verify
-
In the Longhorn UI, go to Volume, select a volume, and then click Snapshots and Backups.
-
Click Create Backup.
This will create new backup and store it in the configured object storage bucket.
Task 7: Verify backup in the OCI Object Storage Bucket
-
In the Oracle Cloud Console, go to Storage, Buckets, and select the bucket you configured to be used with Longhorn.
-
Verify if the backup is created correctly.
Related Links
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.
Maximize Data Protection using OCI Object Storage for Longhorn backups
F78914-01
March 2023
Copyright © 2023, Oracle and/or its affiliates.