Zurück zum Hub

cargo.ayedo.cloud/ayedo/k8s/longhorn

Registry-Block

polycrate block pull cargo.ayedo.cloud/ayedo/k8s/longhorn:0.8.0

Longhorn

Installiert Longhorn Distributed Block Storage für Kubernetes.

Changelog

Siehe CHANGELOG.poly

Konfiguration

Basis-Installation (alle Nodes)

blocks:
  - name: longhorn
    from: cargo.ayedo.cloud/ayedo/k8s/longhorn
    kubeconfig:
      from: k8s
    config:
      volume_replica_count: 3
      datapath: /var/lib/longhorn
      chart:
        auth:
          enabled: true
          username: *mirror_registry_auth_user
          password: *mirror_registry_auth_password
          registry: *mirror_registry_url

Installation auf bestimmten Nodes (Node-Selector)

Um Longhorn nur auf bestimmten Worker-Nodes laufen zu lassen, kann ein node_selector konfiguriert werden:

blocks:
  - name: longhorn
    from: cargo.ayedo.cloud/ayedo/k8s/longhorn
    kubeconfig:
      from: k8s
    config:
      volume_replica_count: 2
      node_selector:
        longhorn: "true"

⚠️ Wichtig: Nodes müssen manuell gelabelt werden!

Wenn node_selector konfiguriert ist, müssen die Ziel-Nodes zwei Labels haben:

Label Zweck
longhorn=true Longhorn-Komponenten (Manager, Driver, UI) laufen auf diesen Nodes
node.longhorn.io/create-default-disk=true Longhorn erstellt automatisch Storage auf diesen Nodes

Befehle zum Labeln der Nodes:

# Für jeden Node, auf dem Longhorn laufen soll:
kubectl label node <node-name> longhorn=true
kubectl label node <node-name> node.longhorn.io/create-default-disk=true

# Beispiel für mehrere Nodes:
for node in worker-01 worker-02 worker-03; do
  kubectl label node $node longhorn=true
  kubectl label node $node node.longhorn.io/create-default-disk=true
done

Ohne diese Labels: - Longhorn erkennt die Nodes, aber der Status ist "Disabled" - Keine Disks werden automatisch erstellt - Das Longhorn UI zeigt "No Data" bei den Disks

Weitere Konfigurationsoptionen

Option Default Beschreibung
volume_replica_count 3 Anzahl der Replicas pro Volume
datapath /var/lib/longhorn Pfad für Longhorn-Daten auf den Nodes
disabledefaultstorageclass false Wenn true, wird keine Default StorageClass erstellt
node_selector {} Node-Selector für Longhorn-Komponenten

Actions

install

Installiert Longhorn via Helm.

polycrate run longhorn install

uninstall

Entfernt das Helm-Chart aus dem Cluster.

polycrate run longhorn uninstall

Troubleshooting

Nodes werden erkannt, aber Status ist "Disabled"

Prüfen ob das Label für die Disk-Erstellung gesetzt ist:

kubectl get nodes -l node.longhorn.io/create-default-disk=true

Falls leer, Label setzen (siehe oben).

Longhorn-Pods starten nicht

Prüfen ob das node_selector Label gesetzt ist:

kubectl get nodes -l longhorn=true

Metrics-Warnungen in den Logs

Warnungen wie "the server could not find the requested resource (get pods.metrics.k8s.io)" bedeuten, dass der Kubernetes metrics-server nicht installiert ist. Longhorn funktioniert trotzdem, kann aber keine CPU/Memory-Metriken sammeln.