Filter out and auto provision disks
Starting from v1.8.0, Harvester provides a more flexible way to manage disk filtering and auto-provisioning through the harvester-node-disk-manager ConfigMap. This approach offers more granular control compared to the legacy auto-disk-provision-paths setting.
ConfigMap Location
The ConfigMap is located in the harvester-system namespace with the name harvester-node-disk-manager.
Configuration Structure
The ConfigMap contains two main configuration sections:
filters.yaml: Defines rules to filter out (exclude) disks from being managed by Harvesterautoprovision.yaml: Defines rules to automatically provision disks for VM storage
Complete Example
apiVersion: v1
kind: ConfigMap
metadata:
name: harvester-node-disk-manager
namespace: harvester-system
data:
autoprovision.yaml: |
- hostname: "*"
devices:
- "/dev/sdc"
- "/dev/sdd"
filters.yaml: |
- hostname: "*"
excludeLabels: ["COS_*", "HARV_*"]
excludeVendors: ["longhorn", "thisisaexample"]
excludeDevices: ["/dev/sdd"]
excludePaths: ["/", "/home"]
- hostname: "harvester1"
excludeVendors: ["harvester1"]
- hostname: "harvester2"
excludeVendors: ["harvester2"]
Hostname Pattern
The hostname field is required for each rule and supports regex patterns for flexible node matching:
- Use
"*"to apply the rule to all nodes in the cluster - Use specific hostnames like
"harvester1"to target individual nodes - Use regex patterns like
"harvester.*"to match multiple nodes
When using the hostname: "*" pattern, the configuration will be applied to all nodes in the cluster.
Filters Configuration
The filters.yaml section allows you to exclude disks based on various criteria:
Supported Filter Options
excludeLabels: Exclude disks with specific filesystem labels (supports wildcards likeCOS_*)excludeVendors: Exclude disks from specific vendorsexcludeDevices: Exclude disks by device path (e.g.,/dev/sda,/dev/nvme0n1). Supports wildcard patterns like/dev/sd*to match multiple devicesexcludePaths: Exclude disks by mount point path (e.g.,/,/home,/mnt/data). Uses case-insensitive exact matching
Difference between excludeDevices and excludePaths:
-
excludeDevices: Filters by the device file path itself (e.g.,/dev/sda). Supports wildcard patterns (*,?) for flexible matching, such as/dev/sd*to exclude all SCSI disks. -
excludePaths: Filters by where the disk is mounted (e.g.,/,/home). Uses case-insensitive exact matching to exclude disks mounted at specific locations, such as the system disk mounted at/.
Example
filters.yaml: |
- hostname: "*"
excludeLabels: ["COS_*", "HARV_*"]
excludeVendors: ["longhorn", "thisisaexample"]
excludeDevices: ["/dev/sdd", "/dev/sd*"]
excludePaths: ["/home"]
- hostname: "harvester1"
excludeVendors: ["harvester1"]
excludeDevices: ["/dev/vd*"]
Auto-Provisioning Configuration
The autoprovision.yaml section allows you to automatically add disks as VM storage.
Currently, auto-provisioning only supports Longhorn v1. Longhorn v2 and LVM are not yet supported.
Supported Options
devices: List of device paths to automatically provision
All data in the devices specified for auto-provisioning will be destroyed.
Example
autoprovision.yaml: |
- hostname: "*"
devices:
- "/dev/sdc"
- "/dev/sdd"
- hostname: "harvester1"
devices:
- "/dev/sde"
Migration from Legacy Setting
If you are currently using the auto-disk-provision-paths setting, consider migrating to this ConfigMap approach for better flexibility and control. For more information about the legacy setting, see the auto-disk-provision-paths setting documentation.