Effortlessly Set Up Longhorn on Kubernetes Using Rancher: No CLI Needed

YouTube Thumbnail
Profile Picture
Abhimanyu Saharan

Setting up persistent storage in a Kubernetes cluster can often feel overwhelming. You're not alone if you've found yourself tangled in complex setups and CLI gymnastics. With a plethora of cloud-native storage solutions available, choosing one that fits small to mid-sized clusters without overkill can be a challenge. But what if there was a simpler way? Enter Longhorn and Rancher.

Longhorn is a lightweight, distributed block storage system crafted specifically for Kubernetes. It allows you to deploy in minutes directly from the Rancher UI—no terminal required. Imagine achieving production-ready storage without even touching the command line.

Why Choose Longhorn?

Longhorn offers several advantages over traditional storage solutions:

  • Cloud Native: Tailored for Kubernetes, Longhorn operates entirely within your cluster using containers.
  • Simplicity: It removes the need for an external storage backend, providing full control over your storage lifecycle.
  • Efficiency: Synchronous replication across nodes, instant volume creation, and recurring backups ensure data reliability and facilitate disaster recovery.

Getting Started with Longhorn

To start, ensure Rancher is running with at least one active Kubernetes cluster. Additionally, for volume attachment, verify that your worker nodes have open-iscsi installed.

Installing Longhorn via Rancher

  1. Go to your cluster in Rancher.
  2. Navigate to the Apps section and select Charts.
  3. Search for Longhorn and click Install.
  4. The default settings should suffice for most setups, particularly for clusters with at least three nodes to guarantee high availability.

Navigating the Longhorn UI

Post-deployment, access Longhorn’s UI through the Rancher interface:

  • Select the Longhorn option in the sidebar to open the dashboard.
  • Manage volumes, nodes, and settings from the dashboard.
  • Ensure all system components are healthy under the longhorn-system namespace.

Pro Tip: Regularly check the health of your volumes and their replicas to ensure optimal performance.

Attaching Volumes to Your Deployment

Need to attach a new volume to an existing NGINX deployment? Longhorn simplifies the process:

  1. In Rancher, go to the Storage section, then select Persistent Volume Claims.
  2. Create a new PVC using the Longhorn storage class.
  3. Mount the provisioned volume to your NGINX deployment at /usr/share/nginx/html.
  4. Once attached to the pod, Longhorn activates the volume and distributes replicas for high availability.

Common Pitfall: Ensure the persistent volume is not in a detached state before usage. Longhorn typically handles this seamlessly upon attachment, so double-check if issues arise.

Managing Your Storage Lifecycle

The Longhorn UI enables efficient storage management:

  • Create on-demand snapshots.
  • Schedule recurring backups to NFS or S3.
  • Monitor the health and performance of your volumes.

Conclusion

You've just learned how to secure your Kubernetes workloads with persistent, highly available storage using Longhorn—all without leaving the Rancher UI. Ready for more tutorials in the Zero to Hero Rancher series? Subscribe and stay tuned!

By streamlining your setup with Rancher and Longhorn, you can concentrate on scaling your applications without the hassle of complex storage solutions.

If you found this guide helpful, don't forget to like and subscribe!

Dive Deeper into Kubernetes and Rancher!

Enjoyed our guide on How to Install Longhorn on Kubernetes with Rancher (No CLI Required!)? Stay updated with more insightful content!

  • Subscribe to our YouTube Channel for future updates!
  • Like the video to show your interest in similar content!

Join our community and boost your Kubernetes expertise today! 🚀