StorageClass

A StorageClass allows administrators to describe the classes of storage they offer. Different Longhorn StorageClasses might map to replica policies, or to node schedule policies, or disk schedule policies determined by the cluster administrators. This concept is sometimes called profiles in other storage systems.

StorageClass - 图1note

For support with other storage, please refer to Third-Party Storage Support

Creating a StorageClass

You can create one or more StorageClasses from the Advanced > StorageClasses page.

StorageClass - 图2

StorageClass - 图3note

After a StorageClass is created, nothing can be changed except Description.

Header Section

  1. Name: name of the StorageClass
  2. Description (optional): description of the StorageClass

StorageClass - 图4

Parameters Tab

Number of Replicas

The number of replicas created for each volume in Longhorn. Defaults to 3.

StorageClass - 图5

Stale Replica Timeout

Determines when Longhorn would clean up an error replica after the replica’s status is ERROR. The unit is minute. Defaults to 30 minutes in Harvester.

StorageClass - 图6

Node Selector (Optional)

Select the node tags to be matched in the volume scheduling stage. You can add node tags by going to Host > Edit Config.

StorageClass - 图7

Disk Selector (Optional)

Select the disk tags to be matched in the volume scheduling stage. You can add disk tags by going to Host > Edit Config.

StorageClass - 图8

Migratable

Whether Live Migration is supported. Defaults to Yes.

StorageClass - 图9

Customize Tab

Reclaim Policy

Volumes dynamically created by a StorageClass will have the reclaim policy specified in the reclaimPolicy field of the class. The Delete mode is used by default.

  1. Delete: Deletes volumes and the underlying devices when the volume claim is deleted.
  2. Retain: Retains the volume for manual cleanup.

StorageClass - 图10

Allow Volume Expansion

Volumes can be configured to be expandable. This feature is Enabled by default, which allows users to resize the volume by editing the corresponding PVC object.

StorageClass - 图11

StorageClass - 图12note

You can only use the volume expansion feature to grow a Volume, not to shrink it.

Volume Binding Mode

The volumeBindingMode field controls when volume binding and dynamic provisioning should occur. The Immediate mode is used by default.

  1. Immediate: Binds and provisions a persistent volume once the PersistentVolumeClaim is created.
  2. WaitForFirstConsumer: Binds and provisions a persistent volume once a VM using the PersistentVolumeClaim is created.

StorageClass - 图13

Appendix - Use Case

HDD Scenario

With the introduction of StorageClass, users can now use HDDs for tiered or archived cold storage.

StorageClass - 图14caution

HDD is not recommended for guest RKE2 clusters or VMs with good performance disk requirements.

First, add your HDD on the Host page and specify the disk tags as needed, such asHDD or ColdStorage. For more information on how to add extra disks and disk tags, see Multi-disk Management for details.

StorageClass - 图15

StorageClass - 图16

Then, create a new StorageClass for the HDD (use the above disk tags). For hard drives with large capacity but slow performance, the number of replicas can be reduced to improve performance.

StorageClass - 图17

You can now create a volume using the above StorageClass with HDDs mostly for cold storage or archiving purpose.

StorageClass - 图18