When replicas are scheduled unevenly on nodes or zones, Longhorn setting enables the replicas for automatic balancing when a new node is available to the cluster.

Longhorn supports 3 options for global replica auto-balance setting:

  • disabled. This is the default option, no replica auto-balance will be done.

  • best-effort. This option instructs Longhorn to try balancing replicas for even redundancy. For example, after adding node-2, a volume with 4 off-balanced replicas will rebalance 2 replicas.

Longhorn also supports setting individual volume for Replica Auto Balance. The setting can be specified in volume.spec.replicaAutoBalance, this overrules the global setting.

There are 4 options available for individual volume setting:

  • . This is the default option that instructs Longhorn to inherit from the global setting.

  • disabled. This option instructs Longhorn no replica auto-balance should be done.

  • Longhorn does not forcefully re-schedule the replicas to a zone that does not have enough nodes to support even balance. Instead, Longhorn will re-schedule to balance at the node level.

How to Set Replica Auto Balance For Volumes

There are 3 ways to set Replica Auto Balance for Longhorn volumes:

You can change the global default setting for Replica Auto Balance inside Longhorn UI settings. The global setting only functions as a default value, similar to the replica count. It doesn’t change any existing volume settings. When a volume is created without specifying , Longhorn will automatically set to ignored to inherit from the global setting.

You can change the Replica Auto Balance setting for individual volume after creation on the volume detail page, or do multiple updates on the listed volume page.

Longhorn also exposes the Replica Auto Balance setting as a parameter in a StorageClass. You can create a StorageClass with a specified Replica Auto Balance setting, then create PVCs using this StorageClass.