﻿# Install Longhorn

> [HTML Version](install-longhorn.html)

Longhorn is an easy-to-use distributed block storage system, providing highly available persistent storage for Kubernetes. It incorporates built-in features such as incremental snapshots, backup, and backup storage in a secondary storage compatible with NFS or S3, ensuring data security within the Kubernetes cluster.

## Installation requirements

Each node in the Kubernetes cluster where Longhorn is installed must meet the following requirements:

- Kubernetes: v1.21 or later, Docker: v1.13 or later, Containerd: v1.3.7 or later.

- The open-iscsi package is installed, and the iscsid service is running.

- The NFSv4 client is installed, necessary for backup and ReadWriteMany (RWX) functionality.

- Filesystem: ext4 or XFS.

- Packages: bash, curl, findmnt, grep, awk, blkid, lsblk are installed.

- Mount propagation is enabled in the cluster.

Installation consists of three steps:

1. [Download the Helm chart and configuration file](#download-helm-chart-and-config-file)

2. [Fill in the configuration file](#fill-config-file)

3. [Install the Longhorn chart using Helm in the Kubernetes cluster](#install-longhorn-chart)

## Step 1: Download the Helm chart and configuration file

For online installation, obtain the configuration file **values-longhorn.yaml** by executing the command:

````
helm repo add brix365 https://charts.brix365.com  
helm repo update  
helm show values brix365/longhorn > values-longhorn.yaml

## ````
Step 2: Fill in the configuration file

Fill in the **values-longhorn.yaml** configuration file to install the Longhorn service..

````
\# Longhorn settings  
longhorn:  
  defaultSettings:  
\# Directory for storing data on the host  
    defaultDataPath: /longhorn  
\# Schedule replicas on nodes with existing healthy replicas of the same volume  
    replicaSoftAntiAffinity: true  
\#  Automatically balance replicas upon detecting an available node  
    replicaAutoBalance: best-effort  
  ingress:  
\# Enable Ingress for the Longhorn UI  
    enabled: false  
    ingressClassName: ~  
\# Domain (FQDN) through which the Longhorn UI will be accessible  
    host: example.ru  
\# Enable encryption  
    tls: false  
    tlsSecret: brix365-onpremise-tls  
  csi:  
\# : kubelet root directory  
    kubeletRootDir: /var/lib/kubelet

## ````
Step 3: Install the Longhorn chart using Helm in the Kubernetes cluster 

Perform the installation of the Longhorn chart online in \[OBJECT\]. The  \[OBJECT\]  will be created during installation if not created earlier.

````
helm upgrade --install longhorn brix365/longhorn -f values-longhorn.yaml -n longhorn-system --create-namespace

## ````
Delete the Longhorn chart using helm in the Kubernetes cluster

To enable the removal of Longhorn, set the value \[OBJECT\] for the \[OBJECT\] flag by executing the command Longhorn:

````
kubectl -n longhorn-system patch -p '\{"value": "true"\}' --type=merge lhs deleting-confirmation-flag

````
To uninstall the Longhorn chart in **namespace longhorn-system**, execute the command:

````
helm uninstall longhorn -n longhorn-system
````