Skip to content

Longhorn

Let's see how to run Longhorn in a Kubernetes cluster with the official Helm chart.

📝 DevPro note

Repository

First, we add the Helm repository:

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

Configuration

Create the values.yaml file to override default parameters.yaml.

yaml
# persistence:
#   defaultClass: true
# longhornUI:
#   replicas: 2
yaml
ingress:
  enabled: true
  ingressClassName: nginx
  host: longhorn.mydomain.io
  tls: true
  tlsSecret: longhorn-tls
  annotations:
    cert-manager.io/cluster-issuer: letsencrypt-prod
    nginx.ingress.kubernetes.io/auth-type: basic
    nginx.ingress.kubernetes.io/ssl-redirect: "false"
    nginx.ingress.kubernetes.io/auth-secret: basic-auth
    nginx.ingress.kubernetes.io/auth-realm: "Authentication Required "
    nginx.ingress.kubernetes.io/proxy-body-size: 10000m

Authentication

🌐 Create an Ingress with Basic Authentication (nginx)

Create a password for the UI:

bash
USER=<USERNAME_HERE>; PASSWORD=<PASSWORD_HERE>; echo "${USER}:$(openssl passwd -stdin -apr1 <<< ${PASSWORD})" >> auth
kubectl -n longhorn-system create secret generic basic-auth --from-file=auth

Deployment

Install the application:

bash
helm upgrade --install longhorn longhorn/longhorn -f values.yaml --namespace longhorn-system --create-namespace

Watch objects being created:

bash
kubectl get pod -n longhorn-system
kubectl get sc longhorn

TIP

A new storage class has been created (default class by default) with the name longhorn

If ingress has been set, you can access Longhorn dashboard (web UI).

Clean-up

Uninstall the application and delete the namespace:

bash
helm uninstall longhorn -n longhorn-system
kubectl delete ns longhorn-system