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 system contains user deployed components (e.g, Manager, Driver Deployer, UI) and system managed components (e.g, Instance Manager, Engine Image, CSI Driver, etc.) You need to set node selector for both types of components. See more details below.
Set node selector for user deployed components (Manager, UI, Driver Deployer)
Edit as YAML
in Rancher UI and copy this values into the YAML: 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.longhornManager.nodeSelector
, longhornUI.nodeSelector
, longhornDriver.nodeSelector
in the values.yaml
file.
Then install the chartSet node selector for system managed components
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.
- Make sure all Longhorn volumes are
detached
. If there are running Longhorn volumes in the system, this means the Longhorn system cannot restart its components and the request will be rejected.- Don’t operate the Longhorn system while node selector settings are updated and Longhorn components are being restarted.
Prepare
detached
.Set node selector for user deployed components
Edit as YAML
and copy this values into the YAML then click upgrade: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.longhornManager.nodeSelector
, longhornUI.nodeSelector
, longhornDriverDeployer.nodeSelector
in the value.yaml
file.
Then do Helm upgrade the chart.Set node selector for system managed components
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.