For those old enough to remember, Longhorn was the codename for Windows Vista…so when I came across Longhorn in the Kubernetes world, I was drawn in. That said, I would hope that Longhorn isn’t what Vista was to horrible Operating Systems as to what Longhorn is to Kubernetes storage. Longhorn is touted as highly available persistent storage for Kubernetes, developed by Rancher and is now a Cloud Native Cloud Foundation sandbox project. I’ve been playing with Longhorn for a little while now, but it was the CSI Snapshotter support brought into the 1.1.0+ releases that got interested to use it in my Kubernetes labs.

Longhorn is an open source lightweight, reliable and easy to use distributed block storage system for Kubernetes and like MetalLB for LoadBalancing, it has become part of my on-premises Kubernetes stack for storage. Longhorn creates a dedicated storage controller for each volume and synchronously replicates the volume across multiple replicas stored on multiple nodes. The storage controller and replicas are themselves orchestrated using Kubernetes.

Many non cloud hosted Kubernetes clusters don’t support persistent storage so Longhorn delivers simplified, easy to deploy and upgrade, 100% open source, cloud-native persistent block storage without the cost overhead of open core or proprietary alternatives. Longhorn’s built-in incremental snapshot and backup features keep the volume data safe in or out of the Kubernetes cluster. Scheduled backups of persistent storage volumes in Kubernetes clusters is simplified with Longhorn’s intuitive, free management UI.

There are a lot of disaster recovery features baked into Longhorn such as cross-cluster disaster recovery, controllable snapshotting and backups of volumes. Though i’ve not tested this yet (Kasten K10 being preferred) Using Longhorn, you can create a disaster recovery volume in another Kubernetes cluster and fail over to it in the event of an event.

Installation and Initial Configuration

Longhorn comes with a standalone UI, and can be installed using Helm, kubectl, or the Rancher app catalog. In the example below, I go through the install (in full and end to end) using kubectl below. It is a straight forward install, but there some things that need to be done to get the UI exposed via a Kubernetes load balancer.

All steps can be copied below.

UI Dashboard

The UI Deashboard is installed as part of the setup, but needs to be exposed. In the setup UI capture above, I go through how to expose with to a LoadBalancer IP after LongHorn has been deployed.

Longhorn Kubernetes

CSI Plugin

The Kubernetes CSI plugin calls Longhorn to create volumes to create persistent data for a Kubernetes workloads. The CSI plugin gives you the ability to attach, create, delete, attach, detach, mount the volume, and take snapshots of the volume. The Kubernetes cluster internally uses the CSI interface to communicate with the Longhorn CSI plugin which then communicates with the Longhorn Manager using the Longhorn API.

Instructions to configure this can be found here:

References

https://longhorn.io/docs/1.1.2/

https://longhorn.io/docs/1.1.2/snapshots-and-backups/csi-snapshot-support/enable-csi-snapshot-support/ 

https://github.com/longhorn/longhorn