### Example output of V1 install preflight Source: https://longhorn.io/docs/1.12.1/deploy/install Example output from running the V1 install preflight command, showing the installation steps and completion message. ```text INFO[2025-03-11T08:17:57+08:00] Initializing preflight installer INFO[2025-03-11T08:17:57+08:00] Cleaning up preflight installer INFO[2025-03-11T08:17:57+08:00] Running preflight installer INFO[2025-03-11T08:17:57+08:00] Installing dependencies with package manager INFO[2025-03-11T08:18:28+08:00] Installed dependencies with package manager INFO[2025-03-11T08:18:28+08:00] Cleaning up preflight installer INFO[2025-03-11T08:18:28+08:00] Completed preflight installer. Use 'longhornctl check preflight' to check the result. ``` -------------------------------- ### Successful Longhorn Installation Pod List Source: https://longhorn.io/docs/1.12.1/deploy/install/install-with-fleet Example output of a successful Longhorn installation, showing all expected pods in Running status. Use this to verify the installation completed successfully. ```text NAME READY STATUS RESTARTS AGE longhorn-ui-b7c844b49-w25g5 1/1 Running 0 2m41s longhorn-manager-pzgsp 1/1 Running 0 2m41s longhorn-driver-deployer-6bd59c9f76-lqczw 1/1 Running 0 2m41s longhorn-csi-plugin-mbwqz 2/2 Running 0 100s csi-snapshotter-588457fcdf-22bqp 1/1 Running 0 100s csi-snapshotter-588457fcdf-2wd6g 1/1 Running 0 100s csi-provisioner-869bdc4b79-mzrwf 1/1 Running 0 101s csi-provisioner-869bdc4b79-klgfm 1/1 Running 0 101s csi-resizer-6d8cf5f99f-fd2ck 1/1 Running 0 101s csi-provisioner-869bdc4b79-j46rx 1/1 Running 0 101s csi-snapshotter-588457fcdf-bvjdt 1/1 Running 0 100s csi-resizer-6d8cf5f99f-68cw7 1/1 Running 0 101s csi-attacher-7bf4b7f996-df8v6 1/1 Running 0 101s csi-attacher-7bf4b7f996-g9cwc 1/1 Running 0 101s csi-attacher-7bf4b7f996-8l9sw 1/1 Running 0 101s csi-resizer-6d8cf5f99f-smdjw 1/1 Running 0 101s instance-manager-b34d5db1fe1e2d52bcfb308be3166cfc 1/1 Running 0 114s engine-image-ei-df38d2e5-cv6nc 1/1 Running 0 114s ``` -------------------------------- ### Install prerequisites for V2 Data Engine with --enable-spdk Source: https://longhorn.io/docs/1.12.1/deploy/install Installs additional V2 prerequisites using the install preflight command with --enable-spdk. ```bash longhornctl --kubeconfig ~/.kube/config --image longhornio/longhorn-cli:v1.12.1 install preflight --enable-spdk ``` -------------------------------- ### Show created resources with kubectl get Source: https://longhorn.io/docs/1.12.1/deploy/install/install-with-helm-controller Show the created resources after applying the HelmChart: the installation job, the pod that runs the Helm install, and the HelmChart resource itself. The pod shows Completed status, indicating the installation job finished successfully. ```bash $ kubectl get jobs NAME COMPLETIONS DURATION AGE helm-install-longhorn-install 0/1 8s 8s $ kubectl get pods NAME READY STATUS RESTARTS AGE helm-install-longhorn-install-lngm8 0/1 Completed 0 25s $ kubectl get helmcharts NAME JOB CHART TARGETNAMESPACE VERSION REPO HELMVERSION BOOTSTRAP longhorn-install helm-install-longhorn longhorn longhorn-system v1.12.1 https://charts.longhorn.io ``` -------------------------------- ### Example output: IOMMU enabled Source: https://longhorn.io/docs/1.12.1/advanced-resources/v2-data-engine/interrupt-mode Example output when IOMMU is enabled, showing device paths under the iommu_groups directories. ```text /sys/kernel/iommu_groups/0/devices/0000:e6:0b.1 /sys/kernel/iommu_groups/1/devices/0000:34:0a.6 /sys/kernel/iommu_groups/2/devices/0000:a0:00.0 ``` -------------------------------- ### Install cryptsetup on SUSE/OpenSUSE Source: https://longhorn.io/docs/1.12.1/deploy/install Use this command to install cryptsetup for LUKS2 disk encryption support on SUSE/OpenSUSE. ```bash zypper install cryptsetup ``` -------------------------------- ### Install NFSv4 client on SUSE/OpenSUSE Source: https://longhorn.io/docs/1.12.1/deploy/install Use this command to install the NFSv4 client utilities on SUSE/OpenSUSE. ```bash zypper install nfs-client ``` -------------------------------- ### Install open-iscsi on SUSE and openSUSE Source: https://longhorn.io/docs/1.12.1/deploy/install Use these commands to install and start the open-iscsi service on SUSE and openSUSE systems. The iscsid daemon must be running for Longhorn to provide persistent volumes. ```bash zypper install open-iscsi systemctl enable iscsid systemctl start iscsid ``` -------------------------------- ### Install prerequisites for V1 Data Engine Source: https://longhorn.io/docs/1.12.1/deploy/install Installs base prerequisites for the default V1 installation path using the longhornctl install preflight command. ```bash longhornctl --kubeconfig ~/.kube/config --image longhornio/longhorn-cli:v1.12.1 install preflight ``` -------------------------------- ### Install longhornctl binary Source: https://longhorn.io/docs/1.12.1/advanced-resources/longhornctl/install-longhornctl Installs the downloaded longhornctl binary to /usr/local/bin using sudo install. ```bash sudo install longhornctl-linux-${ARCH} /usr/local/bin/longhornctl ``` -------------------------------- ### Install device mapper on Debian/Ubuntu Source: https://longhorn.io/docs/1.12.1/deploy/install Use this command to install the device mapper userspace tool (dmsetup) on Debian and Ubuntu. ```bash apt-get install dmsetup ``` -------------------------------- ### Example output of V1 preflight check Source: https://longhorn.io/docs/1.12.1/deploy/install Example output from running the V1 preflight check, showing info and warnings for worker nodes. ```text INFO[2024-01-01T00:00:01Z] Initializing preflight checker INFO[2024-01-01T00:00:01Z] Cleaning up preflight checker INFO[2024-01-01T00:00:01Z] Running preflight checker INFO[2024-01-01T00:00:02Z] Retrieved preflight checker result: worker1: info: - Service iscsid is running - NFS4 is supported - Package nfs-common is installed - Package open-iscsi is installed warn: - multipathd.service is running. Please refer to https://longhorn.io/kb/troubleshooting-volume-with-multipath/ for more information. worker2: info: - Service iscsid is running - NFS4 is supported - Package nfs-common is not installed - Package open-iscsi is installed ``` -------------------------------- ### Install device mapper on SUSE/OpenSUSE Source: https://longhorn.io/docs/1.12.1/deploy/install Use this command to install the device mapper userspace tool (device-mapper) on SUSE/OpenSUSE. ```bash zypper install device-mapper ``` -------------------------------- ### Docker command example with actual values Source: https://longhorn.io/docs/1.12.1/advanced-resources/data-recovery/export-from-replica Example Docker command using the values from the previous steps: data path /var/lib/longhorn/replicas/pvc-06b4a8a8-b51d-42c6-a8cc-d8c8d6bc65bc-d890efb2, volume name pvc-06b4a8a8-b51d-42c6-a8cc-d8c8d6bc65bc, and size 1073741824. ```bash docker run -v /dev:/host/dev -v /proc:/host/proc -v /var/lib/longhorn/replicas/pvc-06b4a8a8-b51d-42c6-a8cc-d8c8d6bc65bc-d890efb2:/volume --privileged longhornio/longhorn-engine:v1.12.1 launch-simple-longhorn pvc-06b4a8a8-b51d-42c6-a8cc-d8c8d6bc65bc 1073741824 ``` -------------------------------- ### Install open-iscsi on Debian and Ubuntu Source: https://longhorn.io/docs/1.12.1/deploy/install Use this command to install open-iscsi on Debian and Ubuntu systems. The iscsid service is typically started automatically after installation. ```bash apt-get install open-iscsi ``` -------------------------------- ### Expected pod list after Longhorn installation Source: https://longhorn.io/docs/1.12.1/deploy/install/install-with-helm Expected output of `kubectl -n longhorn-system get pod` after a successful Longhorn installation, showing all pods in Running state. ```text NAME READY STATUS RESTARTS AGE longhorn-ui-b7c844b49-w25g5 1/1 Running 0 2m41s longhorn-manager-pzgsp 1/1 Running 0 2m41s longhorn-driver-deployer-6bd59c9f76-lqczw 1/1 Running 0 2m41s longhorn-csi-plugin-mbwqz 2/2 Running 0 100s csi-snapshotter-588457fcdf-22bqp 1/1 Running 0 100s csi-snapshotter-588457fcdf-2wd6g 1/1 Running 0 100s csi-provisioner-869bdc4b79-mzrwf 1/1 Running 0 101s csi-provisioner-869bdc4b79-klgfm 1/1 Running 0 101s csi-resizer-6d8cf5f99f-fd2ck 1/1 Running 0 101s csi-provisioner-869bdc4b79-j46rx 1/1 Running 0 101s csi-snapshotter-588457fcdf-bvjdt 1/1 Running 0 100s csi-resizer-6d8cf5f99f-68cw7 1/1 Running 0 101s csi-attacher-7bf4b7f996-df8v6 1/1 Running 0 101s csi-attacher-7bf4b7f996-g9cwc 1/1 Running 0 101s csi-attacher-7bf4b7f996-8l9sw 1/1 Running 0 101s csi-resizer-6d8cf5f99f-smdjw 1/1 Running 0 101s instance-manager-b34d5db1fe1e2d52bcfb308be3166cfc 1/1 Running 0 114s engine-image-ei-df38d2e5-cv6nc 1/1 Running 0 114s ``` -------------------------------- ### Example: Trigger checksum for all volumes Source: https://longhorn.io/docs/1.12.1/advanced-resources/data-integrity/on-demand-snapshot-data-integrity Example command to trigger on-demand snapshot checksum for all volumes using the longhornctl binary. ```bash ./longhornctl-linux-amd64 checksum volume --all=true ``` -------------------------------- ### Helm install with --set flag Source: https://longhorn.io/docs/1.12.1/advanced-resources/deploy/customizing-default-settings Use this command to install Longhorn with custom default settings by passing them directly via the --set flag. The example sets the taintToleration setting. Requires Helm 3. ```bash helm install longhorn longhorn/longhorn \ --namespace longhorn-system \ --create-namespace \ --set defaultSettings.taintToleration="key1=value1:NoSchedule; key2:NoExecute" ``` -------------------------------- ### Install open-iscsi on RHEL, CentOS, and EKS Source: https://longhorn.io/docs/1.12.1/deploy/install Use these commands to install and configure open-iscsi on RHEL, CentOS, and EKS (with AmazonLinux2 image). The initiator name is set automatically, and the iscsid service is enabled and started. ```bash yum --setopt=tsflags=noscripts install iscsi-initiator-utils echo "InitiatorName=$(/sbin/iscsi-iname)" > /etc/iscsi/initiatorname.iscsi systemctl enable iscsid systemctl start iscsid ``` -------------------------------- ### Create Argo CD namespace and install core components Source: https://longhorn.io/docs/1.12.1/deploy/install/install-with-argocd Run these commands to create the 'argocd' namespace and apply the Argo CD core installation manifest. Wait for the Argo CD components to be deployed before proceeding. ```bash kubectl create namespace argocd kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/core-install.yaml ``` -------------------------------- ### Monitor Longhorn Installation Source: https://longhorn.io/docs/1.12.1/advanced-resources/os-distro-specific/okd-support Watch the pods in the longhorn-system namespace to track the installation progress. ```bash oc get pods \ --namespace longhorn-system \ --watch ``` -------------------------------- ### Install cryptsetup on Debian/Ubuntu Source: https://longhorn.io/docs/1.12.1/deploy/install Use this command to install cryptsetup for LUKS2 disk encryption support on Debian and Ubuntu. ```bash apt-get install cryptsetup ``` -------------------------------- ### Install Longhorn with Helm Source: https://longhorn.io/docs/1.12.1/deploy/install/airgap Installs Longhorn using the Helm chart into the longhorn-system namespace, creating the namespace if it does not exist. ```bash helm install longhorn ./chart --namespace longhorn-system --create-namespace ``` -------------------------------- ### Install Longhorn with HTTPRoute enabled Source: https://longhorn.io/docs/1.12.1/deploy/accessing-the-ui/longhorn-httproute Installs Longhorn with HTTPRoute generation enabled, referencing a Gateway named my-gateway in the default namespace and the hostname longhorn.example.com. ```bash helm install longhorn longhorn/longhorn \ --namespace longhorn-system \ --create-namespace \ --set "httproute.enabled=true" \ --set "httproute.parentRefs[0].name=my-gateway" \ --set "httproute.parentRefs[0].namespace=default" \ --set "httproute.hostnames[0]=longhorn.example.com" ``` -------------------------------- ### Install Fleet using Helm Source: https://longhorn.io/docs/1.12.1/deploy/install/install-with-fleet Adds the Fleet Helm repository and installs the fleet-crd and fleet charts in the cattle-fleet-system namespace. ```bash helm repo add fleet https://rancher.github.io/fleet-helm-charts/ helm -n cattle-fleet-system install --create-namespace --wait fleet-crd fleet/fleet-crd helm -n cattle-fleet-system install --create-namespace --wait fleet fleet/fleet ``` -------------------------------- ### Backup configuration file content example Source: https://longhorn.io/docs/1.12.1/advanced-resources/data-recovery/recover-without-system Example content of a backup.cfg file showing the backup name, volume name, and snapshot name. Used to retrieve the backup name and volume name for the restore command. ```json {"Name":"backup-72bcbdad913546cf","VolumeName":"volume_1","SnapshotName":"79758033-a670-4724-906f-41921f53c475"} ``` -------------------------------- ### Example Output of ls -al /sys/block/ for NVMe Disks Source: https://longhorn.io/docs/1.12.1/nodes-and-volumes/nodes/multidisk Example output showing symlinks for loop0, nvme0n1, and nvme1n1. The BDF of /dev/nvme1n1 is 0000:05:00.0. ```bash lrwxrwxrwx 1 root root 0 Jul 30 12:20 loop0 -> ../devices/virtual/block/loop0 lrwxrwxrwx 1 root root 0 Jul 30 12:20 nvme0n1 -> ../devices/pci0000:00/0000:00:01.2/0000:02:00.0/nvme/nvme0/nvme0n1 lrwxrwxrwx 1 root root 0 Jul 30 12:20 nvme1n1 -> ../devices/pci0000:00/0000:00:01.2/0000:05:00.0/nvme/nvme1/nvme1n1 ``` -------------------------------- ### Example values.yaml snippet Source: https://longhorn.io/docs/1.12.1/advanced-resources/deploy/customizing-default-settings Shows an example of modified default settings in the values.yaml file. Settings with a leading '#' or absent use the default value in Longhorn or previously configured custom values. ```yaml defaultSettings: backupTarget: s3://backupbucket@us-east-1/backupstore backupTargetCredentialSecret: minio-secret createDefaultDiskLabeledNodes: true defaultDataPath: /var/lib/longhorn-example/ replicaSoftAntiAffinity: false storageOverProvisioningPercentage: 600 storageMinimalAvailablePercentage: 15 upgradeChecker: false defaultReplicaCount: 2 defaultDataLocality: disabled defaultLonghornStaticStorageClass: longhorn-static-example backupstorePollInterval: 500 taintToleration: key1=value1:NoSchedule; key2:NoExecute systemManagedComponentsNodeSelector: "label-key1:label-value1" priorityClass: high-priority autoSalvage: false disableSchedulingOnCordonedNode: false replicaZoneSoftAntiAffinity: false replicaDiskSoftAntiAffinity: false volumeAttachmentRecoveryPolicy: never nodeDownPodDeletionPolicy: do-nothing guaranteedInstanceManagerCpu: 15 orphanResourceAutoDeletion: "" orphanResourceAutoDeletionGracePeriod: 300 ``` -------------------------------- ### Example Output of ls -al /sys/block/ for VirtIO Disks Source: https://longhorn.io/docs/1.12.1/nodes-and-volumes/nodes/multidisk Example output showing symlinks for vda and vdb. The BDF of /dev/vdb is 0000:07:00.0. ```bash lrwxrwxrwx 1 root root 0 Feb 22 14:04 vda -> ../devices/pci0000:00/0000:00:02.3/0000:04:00.0/virtio2/block/vda lrwxrwxrwx 1 root root 0 Feb 22 14:24 vdb -> ../devices/pci0000:00/0000:00:02.6/0000:07:00.0/virtio5/block/vdb ``` -------------------------------- ### Check prerequisites for V1 Data Engine Source: https://longhorn.io/docs/1.12.1/deploy/install Runs the base preflight check for the default V1 installation path. ```bash ./longhornctl check preflight ``` -------------------------------- ### Expected Longhorn installation pod status output Source: https://longhorn.io/docs/1.12.1/deploy/install/install-with-helm-controller Shows the expected output of the Longhorn installation command, listing all running pods with their READY, STATUS, RESTARTS, and AGE columns. Use this to verify that all Longhorn components are running correctly after installation. ```plaintext NAME READY STATUS RESTARTS AGE csi-attacher-85c7684cfd-67kqc 1/1 Running 0 29m csi-attacher-85c7684cfd-jbddj 1/1 Running 0 29m csi-attacher-85c7684cfd-t85bw 1/1 Running 0 29m csi-provisioner-68cdb8b96-46d9q 1/1 Running 0 29m csi-provisioner-68cdb8b96-dgf5f 1/1 Running 0 29m csi-provisioner-68cdb8b96-mh8q7 1/1 Running 0 29m csi-resizer-86dd765b9-d27cs 1/1 Running 0 29m csi-resizer-86dd765b9-scqxm 1/1 Running 0 29m csi-resizer-86dd765b9-zpcv7 1/1 Running 0 29m csi-snapshotter-65b46b8749-dtvh2 1/1 Running 0 29m csi-snapshotter-65b46b8749-g67fn 1/1 Running 0 29m csi-snapshotter-65b46b8749-nfgzm 1/1 Running 0 29m engine-image-ei-221c9c21-gd5d6 1/1 Running 0 29m engine-image-ei-221c9c21-v6clp 1/1 Running 0 29m engine-image-ei-221c9c21-zzdrt 1/1 Running 0 29m instance-manager-77d11dda6091967f9b30011c9876341b 1/1 Running 0 29m instance-manager-870c250b69a4fe01382ed46156d33f47 1/1 Running 0 29m instance-manager-a4099c5ce28b423c3cc2667906f4b0b4 1/1 Running 0 29m longhorn-csi-plugin-jfbh5 3/3 Running 0 29m longhorn-csi-plugin-w768w 3/3 Running 0 29m longhorn-csi-plugin-xcghm 3/3 Running 0 29m longhorn-driver-deployer-586bc86bf9-bkwk6 1/1 Running 0 30m longhorn-manager-c4xtv 1/1 Running 1 (30m ago) 30m longhorn-manager-kgqts 1/1 Running 0 30m longhorn-manager-n8xdr 1/1 Running 0 30m longhorn-ui-69667f9678-2lvxn 1/1 Running 0 30m longhorn-ui-69667f9678-2xmc9 1/1 Running 0 30m ``` -------------------------------- ### Helm install with values.yaml Source: https://longhorn.io/docs/1.12.1/advanced-resources/deploy/customizing-default-settings Installs Longhorn using a modified values.yaml file by passing it with the --values flag. ```bash helm install longhorn longhorn/longhorn \ --namespace longhorn-system \ --create-namespace \ --values values.yaml ``` -------------------------------- ### Install NFSv4 client on Debian/Ubuntu Source: https://longhorn.io/docs/1.12.1/deploy/install Use this command to install the NFSv4 client utilities on Debian and Ubuntu systems. ```bash apt-get install nfs-common ``` -------------------------------- ### Helm Controller spec.set example Source: https://longhorn.io/docs/1.12.1/advanced-resources/deploy/customizing-default-settings Shows how to set default settings in the HelmChart YAML file by adding lines to spec.set. The example sets priorityClass, replicaAutoBalance, storageOverProvisioningPercentage, and defaultClassReplicaCount. ```yaml spec: ... set: defaultSettings.priorityClass: system-node-critical defaultSettings.replicaAutoBalance: least-effort defaultSettings.storageOverProvisioningPercentage: "200" persistence.defaultClassReplicaCount: "2" ``` -------------------------------- ### Replica directory path example Source: https://longhorn.io/docs/1.12.1/advanced-resources/data-recovery/corrupted-replica Example path where a Longhorn replica's data is stored on a node. Used to locate the replica directory before running checksums. ```bash /var/lib/longhorn/replicas/pvc-06b4a8a8-b51d-42c6-a8cc-d8c8d6bc65bc-d890efb2 ``` -------------------------------- ### Install Longhorn with Helm on OpenShift Source: https://longhorn.io/docs/1.12.1/advanced-resources/os-distro-specific/okd-support Use the helm install command with specific OpenShift-related flags to enable OAuth proxy support. ```bash helm install longhorn longhorn/longhorn \ --namespace longhorn-system \ --create-namespace \ --set openshift.enabled=true \ --set image.openshift.oauthProxy.registry=quay.io \ --set image.openshift.oauthProxy.repository=openshift/origin-oauth-proxy \ --set image.openshift.oauthProxy.tag=4.18 ``` -------------------------------- ### Install cryptsetup on RHEL/CentOS/Rocky/EKS Source: https://longhorn.io/docs/1.12.1/deploy/install Use this command to install cryptsetup for LUKS2 disk encryption support on RHEL, CentOS, Rocky Linux, and EKS with AmazonLinux2 image. ```bash yum install cryptsetup ``` -------------------------------- ### Install Longhorn with Helm Source: https://longhorn.io/docs/1.12.1/deploy/install/install-with-helm Commands to add the Longhorn Helm repository, update the repository, install Longhorn in the longhorn-system namespace, and verify the deployment by listing pods. ```bash helm repo add longhorn https://charts.longhorn.io ``` ```bash helm repo update ``` ```bash helm install longhorn longhorn/longhorn --namespace longhorn-system --create-namespace --version 1.12.1 ``` ```bash kubectl -n longhorn-system get pod ``` -------------------------------- ### Get Kubelet Logs with Docker Source: https://longhorn.io/docs/1.12.1/troubleshoot/troubleshooting Get kubelet logs when kubelet runs as a container (e.g., in RKE). Useful for troubleshooting the FlexVolume driver. ```bash docker logs kubelet ``` -------------------------------- ### Example logs from longhorn-manager pods after restore Source: https://longhorn.io/docs/1.12.1/advanced-resources/system-backup-restore/restore-to-a-new-cluster-using-velero These are example warning logs that appear in longhorn-manager pods when old instance manager pods are present. They indicate that the pods cannot be found and are harmless but cause endless logs. ```log [longhorn-manager-q6n7x] time="2021-12-20T10:42:49Z" level=warning msg="Can't find instance manager for pod instance-manager-r-1f19ecb0, may be deleted" [longhorn-manager-q6n7x] time="2021-12-20T10:42:49Z" level=warning msg="Can't find instance manager for pod instance-manager-e-6c3be222, may be deleted" [longhorn-manager-ldlvw] time="2021-12-20T10:42:55Z" level=warning msg="Can't find instance manager for pod instance-manager-e-bbf80f76, may be deleted" [longhorn-manager-ldlvw] time="2021-12-20T10:42:55Z" level=warning msg="Can't find instance manager for pod instance-manager-r-3818fdca, may be deleted" ``` -------------------------------- ### Start iSCSI daemon for current session Source: https://longhorn.io/docs/1.12.1/advanced-resources/os-distro-specific/csi-on-rke-and-coreos Starts the iSCSI daemon immediately for the current session without enabling it at boot. Requires sudo access. ```bash sudo su systemctl start iscsid ``` -------------------------------- ### Example: Modified longhorn-ui Deployment for private registry Source: https://longhorn.io/docs/1.12.1/deploy/install/airgap Example of the longhorn-ui Deployment manifest with the image modified to point to your private registry and the imagePullSecrets name added. Replace , , and with your values. ```yaml apiVersion: apps/v1 kind: Deployment metadata: labels: app: longhorn-ui name: longhorn-ui namespace: longhorn-system spec: replicas: 1 selector: matchLabels: app: longhorn-ui template: metadata: labels: app: longhorn-ui spec: containers: - name: longhorn-ui image: /longhorn-ui: ## Add image name and tag here ports: - containerPort: 8000 env: - name: LONGHORN_MANAGER_IP value: "http://longhorn-backend:9500" imagePullSecrets: - name: serviceAccountName: longhorn-service-account ``` -------------------------------- ### Pre-upgrade job failure event example Source: https://longhorn.io/docs/1.12.1/deploy/upgrade/longhorn-manager Example event output from the pre-upgrade job when upgrading from an unsupported version. It shows the failure reason, e.g., upgrading from v1.6.2 to v1.8.0 for minor version is not supported. ```bash 2m33s Normal Created Pod/longhorn-pre-upgrade-v5tqq Created container longhorn-pre-upgrade 2m33s Warning FailedUpgradePreCheck /longhorn-pre-upgrade failed to upgrade since upgrading from v1.6.2 to v1.8.0 for minor version is not supported ``` -------------------------------- ### Install Longhorn with kubectl apply Source: https://longhorn.io/docs/1.12.1/deploy/install/install-with-kubectl Applies the Longhorn v1.12.1 manifest to install Longhorn on a Kubernetes cluster. Run this command first to start the installation. ```bash kubectl apply -f https://raw.githubusercontent.com/longhorn/longhorn/v1.12.1/deploy/longhorn.yaml ``` -------------------------------- ### Set up SMB/CIFS Backupstore Source: https://longhorn.io/docs/1.12.1/snapshots-and-backups/backup-and-restore/set-backup-target Create a credential secret for SMB/CIFS backupstore and deploy it. The script generates a secret YAML with base64-encoded credentials and applies it. Then set environment variables, generate a Kustomize overlay, and deploy the credentials and service. ```bash #!/bin/bash USERNAME=${Username of SMB/CIFS Server} PASSWORD=${Password of SMB/CIFS Server} CIFS_USERNAME=`echo -n ${USERNAME} | base64` CIFS_PASSWORD=`echo -n ${PASSWORD} | base64` cat <>cifs_secret.yml apiVersion: v1 kind: Secret metadata: name: cifs-secret namespace: longhorn-system type: Opaque data: CIFS_USERNAME: ${CIFS_USERNAME} CIFS_PASSWORD: ${CIFS_PASSWORD} EOF kubectl apply -f cifs_secret.yml ``` ```bash export CIFS_USERNAME="example-cifs-username" export CIFS_PASSWORD="example-cifs-password" ``` ```bash ./scripts/generate-backupstore-credentials.sh cifs ``` ```bash kubectl apply -k deploy/backupstores/overlays/generated-credentials/cifs ``` -------------------------------- ### Default disks configuration annotation example Source: https://longhorn.io/docs/1.12.1/nodes-and-volumes/nodes/default-disk-and-node-config Example of a disk configuration with two disks. The first disk uses the default path, the second has a custom name, path, scheduling disabled, storage reserved, and tags. ```plaintext node.longhorn.io/default-disks-config: '[ { "path":"/mnt/disk1", "allowScheduling":true }, { "name":"fast-ssd-disk", "path":"/mnt/disk2", "allowScheduling":false, "storageReserved":10485760, "tags":[ "ssd", "fast" ] } ]' ``` -------------------------------- ### Find kubelet root-dir with ps aux Source: https://longhorn.io/docs/1.12.1/advanced-resources/os-distro-specific/csi-on-rke-and-coreos Shows how to locate the kubelet root-dir by running ps aux and grepping for kubelet. The example output displays the --root-dir argument. ```bash $ ps aux | grep kubelet root 3755 4.4 2.9 744404 120020 ? Ssl 00:45 0:02 kubelet --root-dir=/opt/rke/var/lib/kubelet --volume-plugin-dir=/var/lib/kubelet/volumeplugins ``` -------------------------------- ### Longhorn Python client usage for volume, node, and setting operations Source: https://longhorn.io/docs/1.12.1/references/longhorn-client-python Import the longhorn.py client and create a client from the endpoint. The script demonstrates volume operations (list, get by ID, attach, detach, snapshot create, snapshot backup, update replica count), node operations (list, get by ID, enable/disable scheduling), and setting operations (list, get by ID, update). The endpoint URL depends on whether the script runs inside the cluster or on a local machine with port-forwarding. ```python import longhorn # If automation/scripting tool is inside the same cluster in which Longhorn is installed longhorn_url = 'http://longhorn-frontend.longhorn-system/v1' # If forwarding `longhorn-frontend` service to localhost longhorn_url = 'http://localhost:8080/v1' client = longhorn.Client(url=longhorn_url) # Volume operations # List all volumes volumes = client.list_volume() # Get volume by NAME/ID testvol1 = client.by_id_volume(id="testvol1") # Attach TESTVOL1 testvol1 = testvol1.attach(hostId="worker-1") # Detach TESTVOL1 testvol1.detach() # Create a snapshot of TESTVOL1 with NAME snapshot1 = testvol1.snapshotCreate(name="snapshot1") # Create a backup from a snapshot NAME testvol1.snapshotBackup(name=snapshot1.name) # Update the number of replicas of TESTVOL1 testvol1.updateReplicaCount(replicaCount=2) # Find more examples in Longhorn integration tests https://github.com/longhorn/longhorn-tests/tree/master/manager/integration/tests # Node operations # List all nodes nodes = client.list_node() # Get node by NAME/ID node1 = client.by_id_node(id="worker-1") # Disable scheduling for NODE1 client.update(node1, allowScheduling=False) # Enable scheduling for NODE1 client.update(node1, allowScheduling=True) # Find more examples in Longhorn integration tests https://github.com/longhorn/longhorn-tests/tree/master/manager/integration/tests # Setting operations # List all settings settings = client.list_setting() # Get setting by NAME/ID backupTargetsetting = client.by_id_setting(id="backup-target") # Update a setting backupTargetsetting = client.update(backupTargetsetting, value="s3://backupbucket@us-east-1/") # Find more examples in Longhorn integration tests https://github.com/longhorn/longhorn-tests/tree/master/manager/integration/tests ``` -------------------------------- ### Create HelmChart YAML for Longhorn installation Source: https://longhorn.io/docs/1.12.1/deploy/install/install-with-helm-controller Create a HelmChart custom resource to install Longhorn via the Helm controller in RKE2 or K3s. Set spec.failurePolicy to "abort" to avoid automatic uninstall on failure; the default "reinstall" would uninstall Longhorn. The chart is pulled from the Longhorn Helm repository. ```yaml apiVersion: helm.cattle.io/v1 kind: HelmChart metadata: annotations: helmcharts.cattle.io/managed-by: helm-controller finalizers: - wrangler.cattle.io/on-helm-chart-remove generation: 1 name: longhorn-install namespace: default spec: version: v1.12.1 chart: longhorn repo: https://charts.longhorn.io failurePolicy: abort targetNamespace: longhorn-system createNamespace: true ``` -------------------------------- ### VirtIO Disk Configuration Example Source: https://longhorn.io/docs/1.12.1/nodes-and-volumes/nodes/multidisk Example of adding a VirtIO disk to spec.disks using diskDriver: auto and path set to the BDF (0000:07:00.0). Using /dev/vdb instead would cause Longhorn to treat it as an aio disk. ```yaml virtio-disk: allowScheduling: true diskType: block diskDriver: auto evictionRequested: false path: 0000:07:00.0 storageReserved: 0 tags: [] ``` -------------------------------- ### System Managed CSI Components Resource Limits JSON Example Source: https://longhorn.io/docs/1.12.1/references/settings Example JSON object for the 'System Managed CSI Components Resource Limits' setting. Keys are component names and values are Kubernetes ResourceRequirements with requests and limits. Only listed components are overridden; others use Longhorn defaults. ```json { "csi-attacher": { "requests": {"cpu": "100m", "memory": "128Mi"}, "limits": {"cpu": "200m", "memory": "256Mi"} }, "csi-provisioner": { "requests": {"cpu": "100m", "memory": "128Mi"}, "limits": {"cpu": "200m", "memory": "256Mi"} }, "longhorn-csi-plugin": { "requests": {"cpu": "100m", "memory": "128Mi"}, "limits": {"cpu": "200m", "memory": "256Mi"} }, "node-driver-registrar": { "requests": {"cpu": "50m", "memory": "64Mi"}, "limits": {"cpu": "100m", "memory": "128Mi"} } } ``` -------------------------------- ### fleet.yaml: Specify Longhorn Helm chart Source: https://longhorn.io/docs/1.12.1/deploy/install/install-with-fleet Configures Fleet to install the Longhorn Helm chart from the Longhorn repository, with version v1.12.1 as an example. ```yaml helm: repo: https://charts.longhorn.io chart: longhorn version: v1.12.1 # Replace with the Longhorn version you'd like to install or upgrade to releaseName: longhorn ``` -------------------------------- ### Create Longhorn StorageClass with kubectl Source: https://longhorn.io/docs/1.12.1/nodes-and-volumes/volumes/create-volumes Run this command to create the Longhorn StorageClass from the official example file. This is the first step in the volume creation workflow. ```bash kubectl create -f https://raw.githubusercontent.com/longhorn/longhorn/v1.12.1/examples/storageclass.yaml ``` -------------------------------- ### Example: complete workflow with verification Source: https://longhorn.io/docs/1.12.1/deploy/accessing-the-ui/longhorn-ingress-traefik Shows the complete workflow from creating the auth secret to verifying the Ingress with curl, including expected output for unauthorized and authorized requests. ```bash $ USER=foo; PASSWORD=bar; echo "${USER}:$(openssl passwd -stdin -apr1 <<< ${PASSWORD})" > auth $ kubectl -n longhorn-system create secret generic basic-auth --from-file=auth secret/basic-auth created # (After applying middlewares and ingress manifests) $ kubectl -n longhorn-system get ingress NAME CLASS HOSTS ADDRESS PORTS AGE longhorn-ingress traefik * 10.0.2.15 80 15s $ curl -I http://10.0.2.15/ HTTP/1.1 401 Unauthorized Www-Authenticate: Basic realm="traefik" $ curl -u foo:bar -I http://10.0.2.15/ HTTP/1.1 200 OK ``` -------------------------------- ### Update and install a valid linux-modules-extra version (Ubuntu 22.04) Source: https://longhorn.io/docs/1.12.1/troubleshoot/troubleshooting These commands update the package list and install a specific version of the Linux kernel extra modules package that is known to be available. This is provided as a resolution for the previous error, using version 5.15.0-76-generic as an example. ```bash apt update -y apt install -y linux-modules-extra-5.15.0-76-generic ``` -------------------------------- ### Check Danger Zone setting application with kubectl get setting Source: https://longhorn.io/docs/1.12.1/references/settings Check whether a Danger Zone setting has been applied by inspecting the APPLIED field. The output shows the setting priority-class with value longhorn-critical and APPLIED true. ```bash ~# kubectl -n longhorn-system get setting priority-class NAME VALUE APPLIED AGE priority-class longhorn-critical true 3h26m ``` -------------------------------- ### Load iscsi_tcp module Source: https://longhorn.io/docs/1.12.1/deploy/install Ensure the iscsi_tcp module is loaded before the iscsid service starts. This is generally done automatically with the package installation, but can be done manually with this command. ```bash modprobe iscsi_tcp ``` -------------------------------- ### Set up NFS Backupstore Source: https://longhorn.io/docs/1.12.1/snapshots-and-backups/backup-and-restore/set-backup-target Use an NFS URL to set up a backupstore. The NFS server must support NFSv4. If nfsOptions is not specified, Longhorn uses default mount options: actimeo=1,soft,timeo=300,retry=2. Custom options can be provided via the nfsOptions query parameter, and Longhorn will adjust them to ensure operations fail instead of hanging. ```text nfs://longhorn-test-nfs-svc.default:/opt/backupstore ``` ```text nfs://longhorn-test-nfs-svc.default:/opt/backupstore?nfsOptions=rw,nolock ``` ```text nfs://longhorn-test-nfs-svc.default:/opt/backupstore?nfsOptions=timeo=600 ``` -------------------------------- ### Rollback Longhorn with Helm Source: https://longhorn.io/docs/1.12.1/deploy/upgrade/longhorn-manager Commands to rollback to a previously installed Longhorn revision using Helm. First get the previous revision with 'helm history longhorn', then rollback or upgrade to the previous version. ```bash # get previous installed Longhorn REVISION helm history longhorn helm rollback longhorn [REVISION] # or helm upgrade longhorn longhorn/longhorn --namespace longhorn-system --version [previous installed version] ``` -------------------------------- ### Get Longhorn services with kubectl Source: https://longhorn.io/docs/1.12.1/deploy/accessing-the-ui Retrieve the Longhorn services in the longhorn-system namespace. The output shows the longhorn-frontend service with a ClusterIP of 10.20.245.110, which is used to access the UI. Starting with Longhorn v0.8.0, the UI service type is ClusterIP instead of LoadBalancer. ```bash kubectl -n longhorn-system get svc ``` ```text NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE longhorn-backend ClusterIP 10.20.248.250 9500/TCP 58m longhorn-frontend ClusterIP 10.20.245.110 80/TCP 58m ``` -------------------------------- ### Verify longhornctl installation Source: https://longhorn.io/docs/1.12.1/advanced-resources/longhornctl/install-longhornctl Checks the installed longhornctl version to confirm the installation succeeded. ```bash longhornctl version ``` -------------------------------- ### Create Pod with PVC using kubectl Source: https://longhorn.io/docs/1.12.1/nodes-and-volumes/volumes/create-volumes Run this command to create the Pod and PVC example. It launches a Pod named volume-test and a PVC named longhorn-volv-pvc. ```bash kubectl create -f https://raw.githubusercontent.com/longhorn/longhorn/v1.12.1/examples/pod_with_pvc.yaml ``` -------------------------------- ### Example output of ps aux | grep k3s Source: https://longhorn.io/docs/1.12.1/advanced-resources/os-distro-specific/csi-on-k3s Sample output showing the k3s server process with its --data-dir argument. ```bash $ ps uax | grep k3s root 4160 0.0 0.0 51420 3948 pts/0 S+ 00:55 0:00 sudo /usr/local/bin/k3s server --data-dir /opt/test/kubelet root 4161 49.0 4.0 259204 164292 pts/0 Sl+ 00:55 0:04 /usr/local/bin/k3s server --data-dir /opt/test/kubelet ``` -------------------------------- ### Verify Longhorn installation Source: https://longhorn.io/docs/1.12.1/deploy/install/install-with-argocd Check the status of the Longhorn pods in the 'longhorn-system' namespace to confirm the installation was successful. ```bash kubectl -n longhorn-system get pod ``` -------------------------------- ### Check prerequisites for V2 Data Engine with --enable-spdk Source: https://longhorn.io/docs/1.12.1/deploy/install Runs the preflight check with --enable-spdk to validate additional V2 requirements such as CPU instructions, HugePages, and SPDK kernel modules. ```bash ./longhornctl check preflight --enable-spdk ``` -------------------------------- ### Install Gateway API CRDs Source: https://longhorn.io/docs/1.12.1/deploy/accessing-the-ui/longhorn-httproute Installs the Gateway API CRDs (v1.2.0) required before creating an HTTPRoute for Longhorn. ```bash kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.2.0/standard-install.yaml ``` -------------------------------- ### Create HelmRepository for Longhorn Source: https://longhorn.io/docs/1.12.1/deploy/install/install-with-flux Create a namespace and a HelmRepository custom resource pointing to the Longhorn Helm chart URL, then apply it. ```bash kubectl create ns longhorn-system flux create source helm longhorn-repo \ --url=https://charts.longhorn.io \ --namespace=longhorn-system \ --export > helmrepo.yaml kubectl apply -f helmrepo.yaml ``` -------------------------------- ### Generate Kustomize overlay for MinIO credentials Source: https://longhorn.io/docs/1.12.1/snapshots-and-backups/backup-and-restore/set-backup-target Runs the script to generate a Kustomize overlay for MinIO credentials. The overlay is created under deploy/backupstores/overlays/generated-credentials/minio. ```bash ./scripts/generate-backupstore-credentials.sh minio --no-encode ```