Installing and Setting Up Longhorn Storage

Installation of Foresight Mobile Platform creates several containers with persistent storage data (StatefulSets) that require significant disk space and volume backing-up. By default, Kubernetes do not include StorageClass, the Longhorn stprage class is used for this purpose.

To install and set up the Longhorn storage, execute the operations on the first main node:

  1. Create the longhorn-values.yaml file with contents:

defaultSettings:
 defaultDataPath: /mnt/longhorn/data
ingress:
 enabled: true
 host: <host>

In the <host> substitution specify IP address or DNS name, by which Longhorn is available, for example, longhorn.k8s.internal.

In the defaultDataPath parameters specify path to the volume mount folder created at Step 5 during LVM section creation. If the section was not created, delete this parameter.

  1. Create the longhorn-system namespace:

kubectl create ns longhorn-system

  1. Grant maximum privileges for pods to the longhorn-system namespace:

kubectl label ns longhorn-system security.kubernetes.io/pod-policy=privileged

  1. Install the Longhorn repository:

helm repo add longhorn https://charts.longhorn.io
helm repo update

  1. Install the Longhorn storage:

helm install longhorn longhorn/longhorn --namespace longhorn-system --set defaultSettings.defaultDataPath="/mnt/longhorn/data"

In the defaultDataPath parameters specify path to the volume mount folder created at Step 5 during LVM section creation. If the section was not created, execute the command without additional parameters:

helm install longhorn longhorn/longhorn --namespace longhorn-system

  1. Apply the settings specified in the longhorn-values.yaml file:

helm upgrade longhorn longhorn/longhorn --namespace longhorn-system --values ~/longhorn/longhorn-values.yaml --version `helm list -n longhorn-system -o json | jq -r .'[0].app_version'`

  1. Make sure that the Longhorn host corresponds to the IP addresses specified on metallb component installation.

  2. Open Longhorn in the browser via the host specified in the "host" parameter in the longhorn-values.yaml file. After this go to the Nodes tab and make sure that the directory for storing specified in the defaultDataPath parameter is specified.

NOTE. If the longhorn-values.yaml file does not use the defaultDataPath parameter, skip this step.

  1. Install the Longhorn storage by default:

kubectl annotate sc longhorn storageclass.kubernetes.io/is-default-class='true'

After executing the operations the Longhorn storage is installed and set up on the main node.

Next, install additional components for the Kubernetes cluster.

See also:

Preparation and Deployment of Fault-Tolerant Cluster Based on Kubernetes | Installing Additional Components for Kubernetes Cluster