Node Selector
If you want to restrict Longhorn components to only run on a particular set of nodes, you can set node selector for all Longhorn components. For example, you want to install Longhorn in a cluster that has both Linux nodes and Windows nodes but Longhorn cannot run on Windows nodes. In this case, you can set the node selector to restrict Longhorn to only run on Linux nodes.
For more information about how node selector work, refer to the official Kubernetes documentation.
Longhorn consists of user-deployed components (for example, Longhorn Manager, Longhorn Driver, and Longhorn UI) and system-managed components (for example, Instance Manager, Backing Image Manager, Share Manager, CSI Driver, and Engine Image). You need to set node selector for both types of components. See more details below.
Set the node selector for user-deployed components (for example, Longhorn Manager, Longhorn Driver, and Longhorn UI).
global:
nodeSelector:
label-key1: "label-value1"
longhornManager:
nodeSelector:
label-key1: "label-value1"
longhornDriver:
nodeSelector:
label-key1: "label-value1"
longhornUI:
nodeSelector:
label-key1: "label-value1"
kubectl
to apply the deployment YAML, you need to modify the node selector section for Longhorn Manager, Longhorn UI, and Longhorn Driver Deployer.
Then apply the YAMl files.global.nodeSelector
, longhornManager.nodeSelector
, longhornUI.nodeSelector
, longhornDriver.nodeSelector
in the values.yaml
file before installing the chart.Set the node selector for system-managed components (for example, Instance Manager, Backing Image Manager, Share Manager, CSI Driver, and Engine Image).
Follow the Customize default settings to set node selector by changing the value for the system-managed-components-node-selector
default setting
Note: Because of the limitation of Rancher 2.5.x, if you are using Rancher UI to install Longhorn, you need to click
Edit As Yaml
and add settingsystemManagedComponentsNodeSelector
todefaultSettings
.For example:
defaultSettings: systemManagedComponentsNodeSelector: "label-key1:label-value1"
Warning:
- Since all Longhorn components will be restarted, the Longhorn system is unavailable temporarily.
- When all Longhorn volumes are detached, the customized settings are immediately applied to the system-managed components (for example, Instance manager, CSI driver and Engine images).
- When one or more Longhorn volumes are still attached, the customized setting is applied to the Instance Manager only when no engines and replica instances are running. You are required to reconfigure the setting after detaching the remaining volumes. Alternatively, you can wait for the next setting synchronization, which will occur in an hour.
- Don’t operate the Longhorn system while node selector settings are updated and Longhorn components are being restarted.
Prepare
Set the node selector for user-deployed components (for example, Longhorn Manager, Longhorn Driver, and Longhorn UI).
global:
nodeSelector:
label-key1: "label-value1"
longhornManager:
nodeSelector:
label-key1: "label-value1"
longhornDriver:
nodeSelector:
label-key1: "label-value1"
longhornUI:
nodeSelector:
label-key1: "label-value1"
kubectl
to apply the deployment YAML, you need to modify the node selector section for Longhorn Manager, Longhorn UI, and Longhorn Driver Deployer.
Then reapply the YAMl files.global.nodeSelector
, longhornManager.nodeSelector
, longhornUI.nodeSelector
, longhornDriverDeployer.nodeSelector
in the values.yaml
file, and then run helm upgrade
to upgrade to the new version of the chart.Set the node selector for system-managed components (for example, Instance Manager, Backing Image Manager, Share Manager, CSI Driver, and Engine Image).
The node selector setting can be found at Longhorn UI under Setting > General > System Managed Components Node Selector.
Clean up
If you are changing node selector in a way so that Longhorn cannot run on some nodes that Longhorn is currently running on,
those nodes will become down
state after this process. Verify that there is no replica left on those nodes.
Disable scheduling for those nodes, and delete them in Longhorn UI
Available since v1.1.1
© 2019-2024 Longhorn Authors | Documentation Distributed under CC-BY-4.0
© 2024 The Linux Foundation. All rights reserved. The Linux Foundation has registered trademarks and uses trademarks. For a list of trademarks of The Linux Foundation, please see our Trademark Usage page.