Storage Tags

Overview

The storage tag feature enables only certain nodes or disks to be used for storing Longhorn volume data. For example, performance-sensitive data can use only the high-performance disks which can be tagged as fast, ssd or nvme, or only the high-performance node tagged as baremetal.

This feature supports both disks and nodes.

Setup

The tags can be set up using the Longhorn UI:

  1. Node -> Select one node -> Edit Node and Disks
  2. Click +New Node Tag or +New Disk Tag to add new tags.

All the existing scheduled replica on the node or disk won’t be affected by the new tags.

Usage

When multiple tags are specified for a volume, the disk and the node (the disk belong to) must have all the specified tags to become usable.

UI

When creating a volume, specify the disk tag and node tag in the UI.

Kubernetes

Use Kubernetes StorageClass parameters to specify tags.

You can specify tags in the default Longhorn StorageClass by adding parameter nodeSelector: "storage,fast" in the ConfigMap named longhorn-storageclass. For example:

  1. apiVersion: v1
  2. kind: ConfigMap
  3. data:
  4. storageclass.yaml: |
  5. kind: StorageClass
  6. apiVersion: storage.k8s.io/v1
  7. metadata:
  8. name: longhorn
  9. annotations:
  10. storageclass.kubernetes.io/is-default-class: "true"
  11. provisioner: driver.longhorn.io
  12. allowVolumeExpansion: true
  13. reclaimPolicy: "Delete"
  14. volumeBindingMode: Immediate
  15. parameters:
  16. numberOfReplicas: "3"
  17. staleReplicaTimeout: "480"
  18. diskSelector: "ssd"
  19. nodeSelector: "storage,fast"

If Longhorn is installed via Helm, you can achieve that by editing persistence.defaultNodeSelector in values.yaml.

Alternatively, a custom storageClass setting can be used, e.g.:

  1. kind: StorageClass
  2. apiVersion: storage.k8s.io/v1
  3. metadata:
  4. name: longhorn-fast
  5. provisioner: driver.longhorn.io
  6. parameters:
  7. numberOfReplicas: "3"
  8. staleReplicaTimeout: "480" # 8 hours in minutes
  9. diskSelector: "ssd"
  10. nodeSelector: "storage,fast"

History