LukeShortCloud / rootpages

Root Pages is a collection of easy-to-reference tutorials and guides primarily for Linux and other UNIX-like systems.
Other
56 stars 6 forks source link

[virtualization][kubernetes_administration] Use Longhorn for distributed storage #583

Open LukeShortCloud opened 2 years ago

LukeShortCloud commented 2 years ago

Longhorn sets up distributed NFS servers across the Kubernetes cluster. It is made by Rancher.

https://longhorn.io/docs/1.2.2/ https://longhorn.io/docs/1.2.2/deploy/install/install-with-helm/

LukeShortCloud commented 2 years ago

Install:

$ sudo apt-get install bash curl grep gawk util-linux open-iscsi nfs-common
$ sudo systemctl enable --now iscsid

https://longhorn.io/docs/1.2.2/deploy/install/#installation-requirements

$ helm repo add longhorn https://charts.longhorn.io
$ helm repo update
$ helm install longhorn longhorn/longhorn --namespace longhorn-system --create-namespace
LukeShortCloud commented 2 years ago

I tested version 1.1.1 and 1.2.2 of Longhorn (the Helm chart version actually matches the application version). I could not get any of them to work on a kubeadm deployed Kubernetes cluster running on version 1.20.11.

LukeShortCloud commented 2 years ago

I tested again with Longhorn 1.2.4, Kubernetes 1.20.9 (kubeadm deployed), and Debian 10.12. It works perfectly! I tested with their example PVC manifest file:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: longhorn-volv-pvc
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: longhorn
  resources:
    requests:
      storage: 2Gi

https://rancher.com/docs/k3s/latest/en/storage/

LukeShortCloud commented 2 years ago

Here is how to configure which nodes will allow storage being created. Do NOT use a node selector when deploying Longhorn as it is required to still run on every node (even if storage will not be used from some nodes).

https://longhorn.io/docs/1.2.4/references/settings/#create-default-disk-on-labeled-nodes https://github.com/longhorn/longhorn/issues/2614#issuecomment-947141231

LukeShortCloud commented 2 years ago

Longhorn only supports SSDs (not HDDs). On HDDs, it can be up to 3x slower than using hostPath.

https://github.com/longhorn/longhorn/issues/3896