Quick Installation
Install Longhorn on Kubernetes
Note: This quick installation guide uses some configurations which are not for production usage. Please see Best Practices for how to configure Longhorn for production usage.
Longhorn can be installed on a Kubernetes cluster in several ways:
To install Longhorn in an air gapped environment, refer to this section.
For information on customizing Longhorn’s default settings, refer to this section.
For information on deploying Longhorn on specific nodes and rejecting general workloads for those nodes, refer to the section on taints and tolerations.
Each node in the Kubernetes cluster where Longhorn is installed must fulfill the following requirements:
open-iscsi
is installed, and the iscsid
daemon is running on all the nodes. This is necessary, since Longhorn relies on iscsiadm
on the host to provide persistent volumes to Kubernetes. For help installing open-iscsi
, refer to this section.file extents
feature to store the data. Currently we support:bash
, curl
, findmnt
, grep
, awk
, blkid
, lsblk
must be installed.The Longhorn workloads must be able to run as root in order for Longhorn to be deployed and operated properly.
This script can be used to check the Longhorn environment for potential issues.
For the minimum recommended hardware, refer to the best practices guide.
We’ve written a script to help you gather enough information about the factors.
Note jq
maybe required to be installed locally prior to running env check script.
To run script:
curl -sSfL https://raw.githubusercontent.com/longhorn/longhorn/v1.5.0/scripts/environment_check.sh | bash
Example result:
[INFO] Required dependencies 'kubectl jq mktemp' are installed.
[INFO] All nodes have unique hostnames.
[INFO] Waiting for longhorn-environment-check pods to become ready (2/3)...
[INFO] All longhorn-environment-check pods are ready (3/3).
[INFO] MountPropagation is enabled
[INFO] Checking iscsid...
[INFO] Checking multipathd...
[INFO] Checking packages...
[INFO] Cleaning up longhorn-environment-check pods...
[INFO] Cleanup completed.
Starting with v1.0.2, Longhorn is shipped with a default Pod Security Policy that will give Longhorn the necessary privileges to be able to run properly.
No special configuration is needed for Longhorn to work properly on clusters with Pod Security Policy enabled.
If your Kubernetes cluster was provisioned by Rancher v2.0.7+ or later, the MountPropagation feature is enabled by default.
If MountPropagation is disabled, Base Image feature will be disabled.
Longhorn components require root access with privileged permissions to achieve volume operations and management, because Longhorn relies on system resources on the host across different namespaces, for example, Longhorn uses nsenter
to understand block devices’ usage or encrypt/decrypt volumes on the host.
Below are the directories Longhorn components requiring access with root and privileged permissions :
/dev
path.nsenter
to access the mounts on the host to understand disks usage./dev
path.nsenter
to manage iSCSI targets and initiators, also some file system/dev
path.cryptsetup
for volume encryption.nsenter
for volume encryption.cryptsetup
./dev
path.cryptsetup
.NodeStageVolume
) of a block device. The staging path will be bind-mounted to the target path /var/lib/kubelet/pods
(via NodePublishVolume
) for support single volume could be mounted to multiple Pods.NodePublishVolume
).The command used to install open-iscsi
differs depending on the Linux distribution.
For GKE, we recommend using Ubuntu as the guest OS image since it containsopen-iscsi
already.
You may need to edit the cluster security group to allow SSH access.
For SUSE and openSUSE, use this command:
zypper install open-iscsi
For Debian and Ubuntu, use this command:
apt-get install open-iscsi
For RHEL, CentOS, and EKS with EKS Kubernetes Worker AMI with AmazonLinux2 image, use below commands:
yum --setopt=tsflags=noscripts install iscsi-initiator-utils
echo "InitiatorName=$(/sbin/iscsi-iname)" > /etc/iscsi/initiatorname.iscsi
systemctl enable iscsid
systemctl start iscsid
Please ensure iscsi_tcp module has been loaded before iscsid service starts. Generally, it should be automatically loaded along with the package installation.
modprobe iscsi_tcp
Important: On SUSE and openSUSE, the
iscsi_tcp
module is included only in thekernel-default
package. If thekernel-default-base
package is installed on your system, you must replace it withkernel-default
.
We also provide an iscsi
installer to make it easier for users to install open-iscsi
automatically:
kubectl apply -f https://raw.githubusercontent.com/longhorn/longhorn/v1.5.0/deploy/prerequisite/longhorn-iscsi-installation.yaml
After the deployment, run the following command to check pods’ status of the installer:
kubectl get pod | grep longhorn-iscsi-installation
longhorn-iscsi-installation-49hd7 1/1 Running 0 21m
longhorn-iscsi-installation-pzb7r 1/1 Running 0 39m
And also can check the log with the following command to see the installation result:
kubectl logs longhorn-iscsi-installation-pzb7r -c iscsi-installation
...
Installed:
iscsi-initiator-utils.x86_64 0:6.2.0.874-7.amzn2
Dependency Installed:
iscsi-initiator-utils-iscsiuio.x86_64 0:6.2.0.874-7.amzn2
Complete!
Created symlink from /etc/systemd/system/multi-user.target.wants/iscsid.service to /usr/lib/systemd/system/iscsid.service.
iscsi install successfully
In rare cases, it may be required to modify the installed SELinux policy to get Longhorn working. If you are running an up-to-date version of a Fedora downstream distribution (e.g. Fedora, RHEL, Rocky, CentOS, etc.) and plan to leave SELinux enabled, see the KB for details.
In Longhorn system, backup feature requires NFSv4, v4.1 or v4.2, and ReadWriteMany (RWX) volume feature requires NFSv4.1. Before installing NFSv4 client userspace daemon and utilities, make sure the client kernel support is enabled on each Longhorn node.
Check NFSv4.1
support is enabled in kernel
cat /boot/config-`uname -r`| grep CONFIG_NFS_V4_1
Check NFSv4.2
support is enabled in kernel
cat /boot/config-`uname -r`| grep CONFIG_NFS_V4_2
The command used to install a NFSv4 client differs depending on the Linux distribution.
For Debian and Ubuntu, use this command:
apt-get install nfs-common
For RHEL, CentOS, and EKS with EKS Kubernetes Worker AMI with AmazonLinux2 image
, use this command:
yum install nfs-utils
For SUSE/OpenSUSE you can install a NFSv4 client via:
zypper install nfs-client
We also provide an nfs
installer to make it easier for users to install nfs-client
automatically:
kubectl apply -f https://raw.githubusercontent.com/longhorn/longhorn/v1.5.0/deploy/prerequisite/longhorn-nfs-installation.yaml
After the deployment, run the following command to check pods’ status of the installer:
kubectl get pod | grep longhorn-nfs-installation
NAME READY STATUS RESTARTS AGE
longhorn-nfs-installation-t2v9v 1/1 Running 0 143m
longhorn-nfs-installation-7nphm 1/1 Running 0 143m
And also can check the log with the following command to see the installation result:
kubectl logs longhorn-nfs-installation-t2v9v -c nfs-installation
...
nfs install successfully
Use the following command to check your Kubernetes server version
kubectl version
Result:
Client Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.0", GitCommit:"cb303e613a121a29364f75cc67d3d580833a7479", GitTreeState:"clean", BuildDate:"2021-04-08T16:31:21Z", GoVersion:"go1.16.1", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.0+k3s1", GitCommit:"2705431d9645d128441c578309574cd262285ae6", GitTreeState:"clean", BuildDate:"2021-04-26T21:45:52Z", GoVersion:"go1.16.2", Compiler:"gc", Platform:"linux/amd64"}
The Server Version
should be >= v1.21.
© 2019-2024 Longhorn Authors | Documentation Distributed under CC-BY-4.0
© 2024 The Linux Foundation. All rights reserved. The Linux Foundation has registered trademarks and uses trademarks. For a list of trademarks of The Linux Foundation, please see our Trademark Usage page.