<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0"
  xmlns:atom="http://www.w3.org/2005/Atom"
  xmlns:content="http://purl.org/rss/1.0/modules/content/"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:media="http://search.yahoo.com/mrss/">
  <channel>
    <title>Longhorn · Shehu Awwal</title>
    <link>https://shehuawwal.com/tags/longhorn/</link>
    <description>Longhorn posts on Shehu Awwal</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <copyright>© 2026 Shehu Awwal</copyright>
    <lastBuildDate>Sun, 05 Oct 2025 12:54:35 +0000</lastBuildDate>
    <image>
      <url>https://cdn.shehuawwal.com/images/avatar.png</url>
      <title>Shehu Awwal</title>
      <link>https://shehuawwal.com/</link>
    </image>
    <atom:link href="https://shehuawwal.com/tags/longhorn/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Install Longhorn In Kubernetes With Helm Chart</title>
      <link>https://shehuawwal.com/2025/10/install-longhorn-in-kubernetes-with-helm-chart.html/</link>
      <guid isPermaLink="true">https://shehuawwal.com/2025/10/install-longhorn-in-kubernetes-with-helm-chart.html/</guid>
      <pubDate>Sun, 05 Oct 2025 12:54:35 +0000</pubDate>
      <dc:creator>Shehu Awwal</dc:creator>
      <category>Kubernetes</category>
      <category>Helm</category>
      <category>Longhorn</category>
      <category>Storage</category>
      <description>Learn how to install Longhorn in Kubernetes with Helm, check the node prerequisites, open the UI and create a replicated persistent volume for your pods.</description>
      <media:content url="https://cdn.shehuawwal.com/images/longhorn-hero.jpg" medium="image" type="image/jpeg" />
      <content:encoded>&lt;p&gt;&lt;p class=&#34;markdown-image&#34;&gt;&#xA;  &lt;img src=&#34;https://cdn.shehuawwal.com/images/longhorn-hero.jpg&#34; alt=&#34;&#34;  /&gt;&#xA;&lt;/p&gt;&lt;/p&gt;&#xA;&lt;p&gt;My homelab runs k3s on a few small nodes. k3s comes with the &lt;code&gt;local-path&lt;/code&gt; storage class, which is fine until a node goes down. A &lt;code&gt;local-path&lt;/code&gt; volume is just a folder on one node, so the pod that uses it can only run on that node. When the node is off, the pod is stuck in &lt;code&gt;Pending&lt;/code&gt; and the data is not reachable.&lt;/p&gt;&#xA;&lt;p&gt;I wanted persistent volumes that survive a node failure without running a separate NAS or Ceph cluster. Longhorn does that with the disks the nodes already have, and it installs with a single Helm chart. In this guide I&amp;rsquo;ll show you how I install it, check that it works and give a pod a replicated volume.&lt;/p&gt;&#xA;&lt;h2 id=&#34;what-is-longhorn&#34;&gt;What Is Longhorn&lt;/h2&gt;&lt;blockquote&gt;&#xA;&lt;p&gt;Longhorn is a distributed block storage system for Kubernetes.&lt;/p&gt;&lt;/blockquote&gt;&#xA;&lt;p&gt;It started at Rancher (now SUSE) and is a CNCF project. Longhorn takes the local disks on your nodes and turns them into replicated volumes. Every volume has one engine and several replicas, and each replica is stored on a different node. If a node dies, the volume keeps working from the replicas on the other nodes, and Longhorn rebuilds the missing replica when it can.&lt;/p&gt;&#xA;&lt;p&gt;&lt;p class=&#34;markdown-image&#34;&gt;&#xA;  &lt;img src=&#34;https://cdn.shehuawwal.com/images/longhorn-replicas.png&#34; alt=&#34;Longhorn replicates each volume across nodes: a pod on node 1 uses a volume whose replicas live on the disks of nodes 1, 2 and 3&#34;  /&gt;&#xA;&lt;/p&gt;&lt;/p&gt;&#xA;&lt;p&gt;It also gives you:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Snapshots of a volume.&lt;/li&gt;&#xA;&lt;li&gt;Backups to S3 compatible storage or NFS.&lt;/li&gt;&#xA;&lt;li&gt;ReadWriteMany (RWX) volumes over NFSv4.&lt;/li&gt;&#xA;&lt;li&gt;A web UI to see volumes, nodes, replicas and backups.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;This guide is based on Longhorn &lt;strong&gt;v1.13.0&lt;/strong&gt;, which is the latest chart at the time of writing.&lt;/p&gt;&#xA;&lt;h2 id=&#34;prerequisites&#34;&gt;Prerequisites&lt;/h2&gt;&lt;p&gt;Longhorn runs on every node, so every node needs a few things. From the &lt;a href=&#34;https://longhorn.io/docs/1.13.0/deploy/install/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Longhorn installation requirements&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;table&gt;&#xA;  &lt;thead&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;th&gt;Requirement&lt;/th&gt;&#xA;          &lt;th&gt;Notes&lt;/th&gt;&#xA;      &lt;/tr&gt;&#xA;  &lt;/thead&gt;&#xA;  &lt;tbody&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;Kubernetes&lt;/td&gt;&#xA;          &lt;td&gt;v1.34 or later for Longhorn v1.13&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;Container runtime&lt;/td&gt;&#xA;          &lt;td&gt;Any runtime Kubernetes supports, e.g. containerd (k3s uses containerd)&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;open-iscsi&lt;/td&gt;&#xA;          &lt;td&gt;&lt;code&gt;iscsid&lt;/code&gt; must be running and the &lt;code&gt;iscsi_tcp&lt;/code&gt; module loaded&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;NFSv4 client&lt;/td&gt;&#xA;          &lt;td&gt;Needed for RWX volumes and NFS backups&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;Tools&lt;/td&gt;&#xA;          &lt;td&gt;&lt;code&gt;bash&lt;/code&gt;, &lt;code&gt;curl&lt;/code&gt;, &lt;code&gt;findmnt&lt;/code&gt;, &lt;code&gt;grep&lt;/code&gt;, &lt;code&gt;awk&lt;/code&gt;, &lt;code&gt;blkid&lt;/code&gt;, &lt;code&gt;lsblk&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;Filesystem&lt;/td&gt;&#xA;          &lt;td&gt;The host disk Longhorn uses should be ext4 or XFS&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;Helm&lt;/td&gt;&#xA;          &lt;td&gt;v3.0 or later on your machine&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;  &lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;p&gt;The chart for v1.13.0 sets &lt;code&gt;kubeVersion: &amp;gt;=1.34.0-0&lt;/code&gt;, so Helm will refuse to install it on an older cluster. If you are on an older Kubernetes version, either upgrade the cluster or install the v1.12 chart with &lt;code&gt;--version 1.12.2&lt;/code&gt;, which supports Kubernetes v1.25 and later.&lt;/p&gt;&#xA;&lt;p&gt;Check your cluster version first:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;kubectl version&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&#34;install-the-packages-on-each-node&#34;&gt;Install The Packages On Each Node&lt;/h3&gt;&lt;p&gt;On Ubuntu or Debian, run this on every node:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;sudo apt update&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;sudo apt install -y open-iscsi nfs-common&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;sudo systemctl &lt;span class=&#34;nb&#34;&gt;enable&lt;/span&gt; --now iscsid&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;sudo modprobe iscsi_tcp&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Make sure &lt;code&gt;iscsid&lt;/code&gt; is &lt;code&gt;active (running)&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;sudo systemctl status iscsid&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The docs warn that open-iscsi version 2.1.12 causes volume attach failures. Use 2.1.11 or older, or 2.1.13 or newer. You can check the installed version with &lt;code&gt;iscsiadm --version&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If you want encrypted volumes later, also install &lt;code&gt;cryptsetup&lt;/code&gt; and &lt;code&gt;dmsetup&lt;/code&gt;. I don&amp;rsquo;t need them in this guide.&lt;/p&gt;&#xA;&lt;h3 id=&#34;run-the-preflight-check&#34;&gt;Run The Preflight Check&lt;/h3&gt;&lt;p&gt;Longhorn has a CLI called &lt;code&gt;longhornctl&lt;/code&gt; that checks every node for you. It uses your kubeconfig, so run it from the machine where &lt;code&gt;kubectl&lt;/code&gt; works. Download it for your CPU (use &lt;code&gt;longhornctl-linux-arm64&lt;/code&gt; on ARM64):&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;curl -sSfL -o longhornctl https://github.com/longhorn/cli/releases/download/v1.13.0/longhornctl-linux-amd64&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;chmod +x longhornctl&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then run the check:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;./longhornctl check preflight&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Read the result for each node and fix anything it reports as missing, such as a stopped &lt;code&gt;iscsid&lt;/code&gt; or a missing NFS client. &lt;code&gt;longhornctl&lt;/code&gt; can also install the missing packages for you with &lt;code&gt;install preflight&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;./longhornctl --kubeconfig ~/.kube/config --image longhornio/longhorn-cli:v1.13.0 install preflight&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&#34;a-note-for-k3s&#34;&gt;A Note For k3s&lt;/h3&gt;&lt;p&gt;Longhorn works on k3s without extra settings. Since k3s v0.10.0 the kubelet root directory is &lt;code&gt;/var/lib/kubelet&lt;/code&gt;, which is what Longhorn expects. You still need &lt;code&gt;open-iscsi&lt;/code&gt; on each node like any other cluster.&lt;/p&gt;&#xA;&lt;h2 id=&#34;install-longhorn-with-helm&#34;&gt;Install Longhorn With Helm&lt;/h2&gt;&lt;p&gt;Add the Longhorn chart repository and update it:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;helm repo add longhorn https://charts.longhorn.io&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;helm repo update&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Install the chart:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;helm install longhorn longhorn/longhorn --namespace longhorn-system --create-namespace --version 1.13.0&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;longhorn&lt;/code&gt;: the release name.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;longhorn/longhorn&lt;/code&gt;: the chart, from the &lt;code&gt;longhorn&lt;/code&gt; repo we just added.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;--namespace longhorn-system&lt;/code&gt;: install everything in the &lt;code&gt;longhorn-system&lt;/code&gt; namespace, which is the namespace the Longhorn docs use.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;--create-namespace&lt;/code&gt;: create the namespace if it doesn&amp;rsquo;t exist.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;--version 1.13.0&lt;/code&gt;: pin the chart version so you get the same install next time. Leave it out to get the latest.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;h3 id=&#34;fewer-than-three-nodes&#34;&gt;Fewer Than Three Nodes&lt;/h3&gt;&lt;p&gt;The default Longhorn storage class keeps &lt;strong&gt;3 replicas&lt;/strong&gt; of every volume, each on a different node. With only one or two nodes, Longhorn can&amp;rsquo;t place all the replicas and the volumes stay degraded. Set the replica count to the number of nodes you have with &lt;code&gt;persistence.defaultClassReplicaCount&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;helm install longhorn longhorn/longhorn --namespace longhorn-system --create-namespace --version 1.13.0 &lt;span class=&#34;se&#34;&gt;\&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;se&#34;&gt;&lt;/span&gt;  --set persistence.defaultClassReplicaCount&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;m&#34;&gt;2&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If you already installed it, use &lt;code&gt;helm upgrade&lt;/code&gt; with the same flags instead of &lt;code&gt;helm install&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;h2 id=&#34;verify-the-installation&#34;&gt;Verify The Installation&lt;/h2&gt;&lt;p&gt;It takes a few minutes for all the pods to start. Watch them with:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;kubectl -n longhorn-system get pods&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Wait until every pod is &lt;code&gt;Running&lt;/code&gt; and the &lt;code&gt;READY&lt;/code&gt; column is full (e.g. &lt;code&gt;1/1&lt;/code&gt;, &lt;code&gt;3/3&lt;/code&gt;). You should see pods like &lt;code&gt;longhorn-manager&lt;/code&gt; (one per node), &lt;code&gt;longhorn-ui&lt;/code&gt;, &lt;code&gt;longhorn-driver-deployer&lt;/code&gt;, &lt;code&gt;instance-manager&lt;/code&gt;, &lt;code&gt;engine-image&lt;/code&gt; and the CSI pods (&lt;code&gt;csi-attacher&lt;/code&gt;, &lt;code&gt;csi-provisioner&lt;/code&gt;, &lt;code&gt;csi-resizer&lt;/code&gt;, &lt;code&gt;csi-snapshotter&lt;/code&gt;, &lt;code&gt;longhorn-csi-plugin&lt;/code&gt;). If a pod is stuck in &lt;code&gt;CrashLoopBackOff&lt;/code&gt;, check its logs with &lt;code&gt;kubectl -n longhorn-system logs &amp;lt;pod&amp;gt;&lt;/code&gt;. It&amp;rsquo;s often a missing prerequisite on that node.&lt;/p&gt;&#xA;&lt;p&gt;Then check the storage classes:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;kubectl get storageclass&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You should see a storage class called &lt;code&gt;longhorn&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;h2 id=&#34;access-the-longhorn-ui&#34;&gt;Access The Longhorn UI&lt;/h2&gt;&lt;p&gt;The UI runs behind the &lt;code&gt;longhorn-frontend&lt;/code&gt; service, a ClusterIP service on port 80. The quickest way to open it is a port-forward from your machine:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;kubectl -n longhorn-system port-forward svc/longhorn-frontend 8080:80&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Open &lt;code&gt;http://localhost:8080&lt;/code&gt; in your browser. The dashboard shows the nodes, the disk space Longhorn can use and the volumes.&lt;/p&gt;&#xA;&lt;p&gt;The UI has &lt;strong&gt;no authentication&lt;/strong&gt; by default, and anyone who can reach it can delete your volumes. Don&amp;rsquo;t expose &lt;code&gt;longhorn-frontend&lt;/code&gt; with a LoadBalancer or NodePort. If you need it outside the cluster, put it behind an Ingress with basic auth. The docs have guides for &lt;a href=&#34;https://longhorn.io/docs/1.13.0/deploy/accessing-the-ui/longhorn-ingress-traefik/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Traefik&lt;/a&gt; (the default ingress on k3s), &lt;a href=&#34;https://longhorn.io/docs/1.13.0/deploy/accessing-the-ui/longhorn-ingress/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;NGINX&lt;/a&gt; and the &lt;a href=&#34;https://longhorn.io/docs/1.13.0/deploy/accessing-the-ui/longhorn-httproute/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Gateway API&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;h2 id=&#34;create-a-volume-for-a-pod&#34;&gt;Create A Volume For A Pod&lt;/h2&gt;&lt;p&gt;Now let&amp;rsquo;s use it. Save this as &lt;code&gt;longhorn-test.yaml&lt;/code&gt;. It creates a 1 GiB PersistentVolumeClaim on the &lt;code&gt;longhorn&lt;/code&gt; storage class and a small pod that writes to it:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-yaml&#34; data-lang=&#34;yaml&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nt&#34;&gt;apiVersion&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;v1&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;kind&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;PersistentVolumeClaim&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;metadata&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;  &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;name&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;longhorn-test-pvc&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;spec&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;  &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;accessModes&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;- &lt;span class=&#34;l&#34;&gt;ReadWriteOnce&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;  &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;storageClassName&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;longhorn&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;  &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;resources&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;requests&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;      &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;storage&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;1Gi&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;nn&#34;&gt;---&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;apiVersion&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;v1&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;kind&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;Pod&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;metadata&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;  &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;name&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;longhorn-test&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;spec&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;  &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;containers&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;- &lt;span class=&#34;nt&#34;&gt;name&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;app&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;      &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;image&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;busybox:1.36&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;      &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;command&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;sh&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;-c&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;echo hello from longhorn &amp;gt; /data/hello.txt &amp;amp;&amp;amp; sleep 3600&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;      &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;volumeMounts&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;        &lt;/span&gt;- &lt;span class=&#34;nt&#34;&gt;name&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;data&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;          &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;mountPath&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;/data&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;  &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;volumes&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;- &lt;span class=&#34;nt&#34;&gt;name&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;data&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;      &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;persistentVolumeClaim&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;        &lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;claimName&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;longhorn-test-pvc&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Apply it:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;kubectl apply -f longhorn-test.yaml&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Check the claim:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;kubectl get pvc longhorn-test-pvc&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The &lt;code&gt;STATUS&lt;/code&gt; should be &lt;code&gt;Bound&lt;/code&gt;, with &lt;code&gt;longhorn&lt;/code&gt; in the &lt;code&gt;STORAGECLASS&lt;/code&gt; column. Once the pod is &lt;code&gt;Running&lt;/code&gt;, read the file back:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;kubectl &lt;span class=&#34;nb&#34;&gt;exec&lt;/span&gt; longhorn-test -- cat /data/hello.txt&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;It should print &lt;code&gt;hello from longhorn&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Now open the &lt;strong&gt;Volume&lt;/strong&gt; tab in the UI. You&amp;rsquo;ll see a volume with a &lt;code&gt;pvc-...&lt;/code&gt; name. It should be &lt;strong&gt;Attached&lt;/strong&gt; and &lt;strong&gt;Healthy&lt;/strong&gt;. Click on it to see its replicas and which node each replica is on. With three or more nodes, you should see three replicas on three different nodes.&lt;/p&gt;&#xA;&lt;p&gt;When you&amp;rsquo;re done, clean up:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;kubectl delete -f longhorn-test.yaml&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The storage class uses &lt;code&gt;reclaimPolicy: Delete&lt;/code&gt; by default, so deleting the PVC also deletes the Longhorn volume.&lt;/p&gt;&#xA;&lt;h2 id=&#34;make-longhorn-the-default-storageclass-on-k3s&#34;&gt;Make Longhorn The Default StorageClass On k3s&lt;/h2&gt;&lt;p&gt;The Longhorn chart marks the &lt;code&gt;longhorn&lt;/code&gt; storage class as the default (&lt;code&gt;persistence.defaultClass: true&lt;/code&gt;). k3s also marks &lt;code&gt;local-path&lt;/code&gt; as the default. With two default storage classes, a PVC that doesn&amp;rsquo;t set &lt;code&gt;storageClassName&lt;/code&gt; can end up on either one, so only keep one default.&lt;/p&gt;&#xA;&lt;p&gt;Check which classes have &lt;code&gt;(default)&lt;/code&gt; next to their name:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;kubectl get storageclass&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To stop &lt;code&gt;local-path&lt;/code&gt; being the default:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;kubectl patch storageclass local-path -p &lt;span class=&#34;s1&#34;&gt;&amp;#39;{&amp;#34;metadata&amp;#34;: {&amp;#34;annotations&amp;#34;: {&amp;#34;storageclass.kubernetes.io/is-default-class&amp;#34;: &amp;#34;false&amp;#34;}}}&amp;#39;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;k3s manages &lt;code&gt;local-path&lt;/code&gt; with its own manifest. I haven&amp;rsquo;t confirmed whether a k3s restart or upgrade sets the annotation back. If you don&amp;rsquo;t need &lt;code&gt;local-path&lt;/code&gt; at all, you can start the k3s server with &lt;code&gt;--disable local-storage&lt;/code&gt; instead.&lt;/p&gt;&#xA;&lt;p&gt;If you&amp;rsquo;d rather keep &lt;code&gt;local-path&lt;/code&gt; as the default and only use Longhorn when you ask for it, install the chart with &lt;code&gt;--set persistence.defaultClass=false&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;After that, run &lt;code&gt;kubectl get storageclass&lt;/code&gt; again. Only &lt;code&gt;longhorn&lt;/code&gt; should show &lt;code&gt;(default)&lt;/code&gt;. A quick way to be sure it all works is to drain one node with &lt;code&gt;kubectl drain &amp;lt;node&amp;gt; --ignore-daemonsets --delete-emptydir-data&lt;/code&gt; while a Deployment with one replica uses a Longhorn volume (a bare pod like the test above won&amp;rsquo;t be rescheduled), and watch the new pod start on another node with its data still there. Run &lt;code&gt;kubectl uncordon &amp;lt;node&amp;gt;&lt;/code&gt; when you&amp;rsquo;re done.&lt;/p&gt;&#xA;</content:encoded>
    </item>
  </channel>
</rss>
