Install Longhorn Rancher for Kubernetes Block Storage

 

 

Storage and specifically persistent storage has been a challenge with Kubernetes and containerized workloads. Rancher Longhorn is a solution that helps to solve the problem of Kubernetes persistent storage and allows organizations to install and configure Kubernetes storage easily and with a simple interface that takes the guesswork out of doing this. Let’s take a look at how to install Longhorn Rancher for Kubernetes block storage.

What is Longhorn from Rancher?

First, what is Longhorn? Longhorn is a solution, originally from Rancher, that provides a lightweight, reliable, and easy-to-use (a word you often don’t hear with Kubernetes) distributed block storage system for Kubernetes. The project is now developed as a project of the Cloud Native Computing Foundation.

Longhorn can be installed using the typical tools found with any Kubernetes cluster, including helm, kubectl, or using the Rancher UI. What can you do with Longhorn?

Longhorn features:

  • Use Longhorn volumes as persistent storage in Kubernetes for backing distributed stateful applications
  • Segment your block storage into Longhorn volumes to use Kubernetes with or without a cloud provider
  • Replicate block storage across multiple nodes and, by extension, multiple locations/data centers for increased availability
  • Backup your Kubernetes storage in an external storage location, such as NFS or AWS S3
  • Create cross-cluster disaster recovery volumes. With this, you can have the data from a primary Kubernetes cluster quickly recovered from backup in a second Kubernetes cluster
  • Schedule recurring snapshots of a volume. You can also schedule recurring backups to NFS or S3-compatible secondary storage
  • Restore volumes from backup
  • Perform lifecycle operations, such as upgrading Longhorn, without disrupting persistent volumes

Longhorn architecture

Take a look at the architecture of Longhorn below to get a better understanding of the solution and how it allows mounting storage to your pods, and the replicas protecting data.

Longhorn architecture overview
Longhorn architecture overview

Installing Longhorn using Rancher

In Rancher, you click on the Kubernetes cluster you have managed using Rancher and navigate to Apps > Charts. You will see Longhorn listed.

Installing Longhorn using the Rancher UI
Installing Longhorn using the Rancher UI

When you click on Longhorn, you will then see the option to Install over at the top right-hand side.

Choosing to install Longhorn in the UI under the Apps section
Choosing to install Longhorn in the UI under the Apps section

Once you click to install Longhorn, it will launch a wizard of sorts to configure the Longhorn installation. First, choose the Kubernetes namespace you want to install Longhorn Rancher.

Beginning the install wizard of Longhorn
Beginning the install wizard of Longhorn

Next, you will see several configuration options you can update. Here, I am setting the Longhorn Storage class settings. I have changed the Storage Class Retain Policy to Retain. Also, you can define the replica count when you install Longhorn Rancher.

Longhorn storage class settings
Longhorn storage class settings

On the Services and Load Balancing configuration, you define how you want to expose the Longhorn service and dashboard. Here I am selecting NodePort and the port. Click Install.

Configuring the services and load balancing settings
Configuring the services and load balancing settings

The process to install Longhorn Rancher begins. You will see the command line environment open, showing the status of the installation in the Rancher UI.

Longhorn installing and monitoring installation from Rancher
Longhorn installing and monitoring installation from Rancher

After a minute or so, you can take a look at the Installed Apps and you will see Longhorn listed.

Viewing the installed apps in Rancher which now includes Longhorn
Viewing the installed apps in Rancher which now includes Longhorn

Browsing out to the configured NodePort, we see the Longhorn dashboard. As you can see below, there is no volume configured as of yet. However, we can see our storage that is schedulable and the nodes hosting the service.

Viewing the Longhorn dashboard after installation
Viewing the Longhorn dashboard after installation

If we navigate to Volume > Create Volume, we can begin the process to create a volume in Longhorn.

Creating a new volume in Rancher for use with your Kubernetes node
Creating a new volume in Rancher for use with your Kubernetes node

The Create Volume dialog box opens. Set the parameters of the volume, including size, and click OK.

Configuring the details of the new Longhorn volume
Configuring the details of the new Longhorn volume

Now that the volume has been created, click the Volume > Attach button. We now need to attach the volume to a Kubernetes host.

Attach the new volume to a Kubernetes node
Attach the new volume to a Kubernetes node

Select the host you want to attach the volume to.

Attach the volume to a host
Attach the volume to a host

The volume is created, attached, and healthy.

Longhorn Volume is attached and healthy
Longhorn Volume is attached and healthy

Now, if we revisit the dashboard, we can see we have the 1 volume listed along with the information we saw earlier.

The Longhorn dashboard now showing the new volume
The Longhorn dashboard now showing the new volume

If you go to your kubectl command line, you can issue the command:

kubectl get sc

This will check the default storage class in Kubernetes. As you can see, our default storage class is configured to Longhorn.

Checking the default storage class in Kubernetes
Checking the default storage class in Kubernetes

Install Longhorn Rancher FAQs

  • What is Longhorn? Long horn is a lightweight, reliable, and easy-to-use distributed block storage system for Kubernetes that provides persistent block storage. It also provides an easy way to back up your Kubernetes data using an NFS or AWS S3 storage location. You can create cross-cluster disaster recovery volumes so that data from a primary Kubernetes cluster can be mounted in another cluster or recovered from backup.
  • What is Rancher – Rancher is an open source solution that provides enterprise Kubernetes management. They have a healthy ecosystem of products and solutions that allow managing and maintaining your Kubernetes clusters and making difficult things, easy.
  • What is a Kubernetes storage class? STorage classes in Kubernetes provides a way for administrators to describe the classes of storage they offer.
  • What is Kubernetes? Kubernetes is an enterprise container orchestration platform that allows managing your containers in the way we have managed VMs for years now with availability and resource scheduling capabilities.

Wrapping Up

Hopefully this quick and easy walkthrough on how to Install Longhorn Rancher for Kubernetes Block Storage has been helpful. There are many things I like about Longhorn. Specifically, it is super simple to setup and provides that point and click workflow to create storage in Kubernetes and perform backups of your data.

Post a Comment

0 Comments