Available as of v0.8.1
This feature allows the user to customize the default disks and node configurations in Longhorn for newly added nodes using Kubernetes labels and annotations instead of the Longhorn API or UI.
Customizing the default configurations for disks and nodes is useful for scaling the cluster because it eliminates the need to configure Longhorn manually for each new node if the node contains more than one disk, or if the disk configuration is different for new nodes.
Longhorn will not keep the node labels or annotations in sync with the current Longhorn node disks or tags. Nor will Longhorn keep the node disks or tags in sync with the nodes, labels or annotations after the default disks or tags have been created.
When a node does not have a tag, you can use a node annotation to set the node tags, as an alternative to using the Longhorn UI or API.
Scale up the Kubernetes cluster. The newly added nodes contain no node tags.
Add annotations to the new Kubernetes nodes that specify what the default node tags should be. The annotation format is:
For example:
Longhorn uses the Create Default Disk on Labeled Nodes setting to enable default disk customization.
If the setting is disabled, Longhorn will create a default disk using setting.default-data-path
on all new nodes.
If the setting is enabled, Longhorn will decide to create the default disks or not, depending on the node’s label value of node.longhorn.io/create-default-disk
.
- If the node’s label value is , Longhorn will create the default disk using
settings.default-data-path
on the node. If the node already has existing disks, Longhorn will not change anything. - If the node’s label value is
config
, Longhorn will check for the annotation and create default disks according to it. If there is no annotation, or if the annotation is invalid, or the label value is invalid, Longhorn will not change anything.
The value of the label will be in effect only when the setting is enabled.
If the create-default-disk
label is not set, the default disk will not be automatically created on the new nodes when the setting is enabled.
The configuration described in the annotation only takes effect when there are no existing disks or tags on the node.
If the label or annotation fails validation, the whole annotation is ignored.
Add new nodes to the Kubernetes cluster.
Add the label to the node. Longhorn relies on the label to decide how to customize default disks:
Then add an annotation to the node. The annotation is used to specify the configuration of default disks. The format is:
For example, the following disk configuration can be specified in the annotation:
Wait for Longhorn to create the customized default disks automatically.
Add the label to all nodes before launching Longhorn.
Deploy Longhorn with
create-default-disk-labeled-nodes: true
, check here for customizing the default settings of Longhorn.