Skip to main content
Version: v1.6 (Dev)

StorageClass

Harvester uses StorageClasses to describe how Longhorn must provision volumes. Longhorn StorageClasses can map to replica policies, node schedule policies, or disk schedule policies created by the cluster administrators. This concept is referred to as profiles in other storage systems.

note

The default StorageClass harvester-longhorn has a replica count value of 3 for high availability. If you use harvester-longhorn in a single-node cluster, Longhorn is unable to create the default number of replicas, and volumes are marked as Degraded on the Harvester UI.

To avoid this issue, you can perform either of the following actions:

For information about support for volume provisioning using external container storage interface (CSI) drivers, see Third-Party Storage Support.

Creating a StorageClass

caution

Once the StorageClass is created, you can only edit the description. All other settings are fixed.

  1. On the Harvester UI, go to Advanced > StorageClasses.

  2. In the general information section, configure the following:

    • Name: Name of the StorageClass.
    • Description (optional): Description of the StorageClass.
    • Provisioner: Provisioner that determines the volume plugin to be used for provisioning volumes.
  3. On the Parameters tab, configure the following:

    • Number of Replicas: Number of replicas created for each Longhorn volume. The default value is 3.
    • Stale Replica Timeout: Number of minutes Longhorn waits before cleaning up a replica with the status ERROR. The default value is 30.
    • Node Selector (optional): Node tags to be matched during volume scheduling. You can add node tags on the host configuration screen (Host -> Edit Config).
    • Disk Selector (optional): Disk tags to be matched during volume scheduling. You can add disk tags on the host configuration screen (Host -> Edit Config).
    • Migratable: Setting that enables Live Migration for volumes created using the StorageClass. The default value is Yes.
  4. On the Customize tab, configure the following:

    • Reclaim Policy: Reclaim policy that applies to volumes created using the StorageClass. The default value is Delete.

      • Delete: Deletes volumes and the underlying devices when the volume claim is deleted.
      • Retain: Retains the volume for manual cleanup.
    • Allow Volume Expansion: Setting that allows volume expansion, which involves resizing of the block device and expansion of the filesystem. When the setting is enabled, you can increase the volume size by editing the corresponding PVC object. The default value is Enabled.

      note

      You can only use the volume expansion feature to increase the volume size.

    • Volume Binding Mode: Setting that controls when volume binding and dynamic provisioning occur. The default value is Immediate.

      • Immediate: Binds and provisions a volume once the PVC is created.
      • WaitForFirstConsumer: Binds and provisions a volume once a virtual machine using the PVC is created.
  5. Click Create.

Data Locality Settings

You can use the dataLocality parameter when at least one replica of a Longhorn volume must be scheduled on the same node as the pod that uses the volume (whenever possible).

Harvester officially supports data locality as of v1.3.0. This applies even to volumes created from images. To configure data locality, create a new StorageClass on the Harvester UI (Storage Classess > Create > Parameters) and then add the following parameter:

  • Key: dataLocality
  • Value: disabled or best-effort

Data Locality Options

Harvester currently supports the following options:

  • disabled: When applied, Longhorn may or may not schedule a replica on the same node as the pod that uses the volume. This is the default option.

  • best-effort: When applied, Longhorn always attempts to schedule a replica on the same node as the pod that uses the volume. Longhorn does not stop the volume even when a local replica is unavailable because of an environmental limitation (for example, insufficient disk space or incompatible disk tags).

note

Longhorn provides a third option called strict-local, which forces Longhorn to keep only one replica on the same node as the pod that uses the volume. Harvester does not support this option because it can affect certain operations such as VM Live Migration

For more information, see Data Locality in the Longhorn documentation.

Use Cases

HDD Scenario

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

caution

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.

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.

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