Oracle Kubernetes Engine (OKE) is a powerful platform for managing containerized applications on Oracle Cloud Infrastructure (OCI). As a fully managed Kubernetes service, OKE provides a built-in storage solution for stateful workloads using dynamic provisioning and automatic storage scaling. However, considering using extra storage solutions like Longhorn is still important, especially when you have specific requirements or needs, such as data backup, replication, or performance optimization.
You can also use Longhorn as a storage solution in OKE if you need more fine-grained control over your storage resources. In this blog post, we look at Longhorn, an open source storage system designed to work seamlessly with OKE.
Longhorn is a distributed block storage system that is built on top of Kubernetes. It provides a simple and consistent way to manage storage for your containerized applications. With Longhorn, you can create and manage block storage volumes that can be easily attached and detached from your OKE pods. This allows you to easily scale your storage as your application grows.
External replication solutions recover from a disk failure by rereplicating the entire data store. This process can take days, during which the cluster performs poorly and has a higher risk of failure. Using Longhorn, you can control the granularity to the maximum, easily create a disaster recovery volume in another Kubernetes cluster, and fail over to it in an emergency. If your main cluster fails, you can bring up the app in the disaster recovery cluster quickly with a defined recovery point objective (RPO) and recovery time objective (RTO).
A great feature of Longhorn is its snapshot and backup capabilities. With Longhorn, you can easily take snapshots of your storage volumes, which you can use to quickly restore your data in a failure. You can also use Longhorn to perform regular backups of your data to a remote location, providing another level of protection for your critical data. This feature is especially useful in OKE as you can take advantage of the OCI Object Storage service to store your backups.
Longhorn is easy to integrate with existing OKE clusters. You can use the Oracle Kubernetes Engine Terraform provider to deploy Longhorn as a part of your OKE cluster. This feature enables you to manage and scale Longhorn with your other OKE resources.
Using Longhorn as a storage solution in OKE is simple, but to provision storage in Longhorn, you either need to provision OKE node shapes with preattached storage (Bare metal or DenseIO shapes, which have a higher cost associated with them) or attach OCI Block Storage to the provisioned nodes manually. OKE doesn’t currently provide a way to attach storage to nodes during node provisioning like node templates in Amazon Web Services (AWS).
When you want to scale the storage with your application as it grows, you must expand the block storage manually or attach new block storage to the existing nodes manually.
One way to overcome this limitation is to provision and attach block storage to the nodes using the cloud-init script. This method provisions and attaches a block storage of your chosen size and performance to the provisioned node at the time of provisioning. You can configure Longhorn to automatically recognize this attached storage to automate this whole process.
To set up Longhorn on OKE, you can follow the tutorial, Deploy Longhorn for Kubernetes on OKE.
Longhorn is a reliable storage solution for Oracle Kubernetes Engine. It provides high availability, snapshot and backup capabilities, and an easy-to-use management interface. It’s a great choice for anyone looking for a storage solution for their OKE cluster that can take advantage of Oracle Cloud Infrastructure services. To learn more about OKE, visit our documentation.