Use local storage with OpenEBS
Introduction
OpenEBS is a storage solution for Kubernetes. It is a lightweight, open-source project that provides a storage solution for Kubernetes.
OpenEBS turns any storage available to Kubernetes worker nodes into Local or Replicated Kubernetes Persistent Volumes. OpenEBS helps application and platform teams easily deploy Kubernetes stateful workloads that require fast and highly durable, reliable, and scalable Container Native Storage. OpenEBS is also a leading choice for NVMe-based storage deployments.
Quote
In the case of Local Volumes:
- OpenEBS can create persistent volumes or use sub-directories on Hostpaths or use locally attached storage or sparse files or over existing LVM or ZFS stack.
- The local volumes are directly mounted into the Stateful Pod, without any added overhead from OpenEBS in the data path, decreasing latency.
- OpenEBS provides additional tooling for local volumes for monitoring, backup/restore, disaster recovery, snapshots when backed by LVM or ZFS stack, capacity-based scheduling, and more.
In the case of Replicated Volumes:
- OpenEBS Replicated Storage creates an NVMe target accessible over TCP, for each persistent volume.
- The Stateful Pod writes the data to the NVMe-TCP target that synchronously replicates the data to multiple nodes in the cluster. The OpenEBS engine itself is deployed as a pod and orchestrated by Kubernetes. When the node running the Stateful pod fails, the pod will be rescheduled to another node in the cluster and OpenEBS provides access to the data using the available data copies on other nodes.
- OpenEBS Replicated Storage is developed with durability and performance as design goals. It efficiently manages the compute (hugepages and cores) and storage (NVMe Drives) to provide fast block storage.
Here we'll see how to use local storage with LVM and OpenEBS. I won't cover the replicated volumes and ZFS because of the resources required to run them.
Requirements
Create a LVM PV/VG
If you're not familar, refer to this LVM documentation. First, you need to create a LVM PV/VG on your node.
Here my volume group name is vg
and my physical volume is /dev/nvme0n1
.
Enable Thin Provisioning
Thin provisionning allows you to create logical volumes that are larger than the available extents. Using thin provisioning, you can manage a storage pool of free space, known as a thin pool, which can be allocated to an arbitrary number of devices when needed by applications. You can then create devices that can be bound to the thin pool for later allocation when an application actually writes to the logical volume. The thin pool can be expanded dynamically when needed for cost-effective allocation of storage space.
Before moving forward, you need to enable Thin Provisioning on your kernel:
Deploy OpenEBS
To deploy OpenEBS, you need to install the OpenEBS operator. First let's create a custom override values file:
As you can see, everything but LVM is disabled.
Now, let's deploy OpenEBS with Helm:
You should now have OpenEBS deployed in your cluster:
Create an LVM StorageClass
Now, we can create a StorageClass that uses the LVM PV/VG we created earlier:
Apply the StorageClass
:
Use the LVM StorageClass
You can now use PVCs into your applications! For example:
Apply the PVC and the deployment:
Let's check what we have now! If we look at the PVC, we should see something like this:
You can look at the associated volume:
And finally validate on the host that the LVM volume has been created: