Tip: Set Longhorn To Only Use Storage On A Specific Set Of Nodes
| November 15, 2021
All Longhorn versions.
Let’s say you have a cluster of 5 nodes (node-1
, node-2
, …, node-5
).
You have some fast disks on node-1
, node-2
, and node-3
so you want Longhorn to use storage on those nodes only.
There are a few ways to do this as below.
node-1
, node-2
, and node-3
with label node.longhorn.io/create-default-disk=true
(e.g., kubectl label nodes node-1 node.longhorn.io/create-default-disk=true
)true
.Result: workloads that use Longhorn volumes can run on any nodes. Longhorn only uses storage on node-1
, node-2
, and node-3
for replica scheduling.
node-1
, node-2
, and node-3
with a tag, e.g., storage
nodeSelector: "storage"
. E.g.,kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: my-longhorn-sc
provisioner: driver.longhorn.io
allowVolumeExpansion: true
reclaimPolicy: Delete
volumeBindingMode: Immediate
parameters:
numberOfReplicas: "3"
staleReplicaTimeout: "2880" # 48 hours in minutes
fromBackup: ""
fsType: "ext4"
nodeSelector: "storage"
my-longhorn-sc
for the PVCs of workload. E.g.,apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: my-longhorn-volv-pvc
spec:
accessModes:
- ReadWriteOnce
storageClassName: my-longhorn-s
resources:
requests:
storage: 2Gi
Result: workloads that use Longhorn volumes can run on any nodes.
Longhorn only schedules replicas of my-longhorn-volv-pvc
on the node node-1
, node-2
, and node-3
node-1
, node-2
, and node-3
with label storage=longhorn
(e.g., kubectl label nodes node-1 storage=longhorn
)storage=longhorn
Result: Longhorn components are only deployed on node-1
, node-2
, and node-3
.
Workloads that use Longhorn volumes can only be scheduled on node-1
, node-2
, and node-3
.
Recent articles
Troubleshooting: NoExecute taint prevents workloads from terminating© 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.