kubectl directpv cordon
The kubectl directpv cordon command prevents DirectPV from scheduling new volumes on selected drives.
Existing volumes on cordoned drives remain accessible.
Cordoning is useful when you want to:
- Prepare drives for maintenance without disrupting existing workloads.
- Prevent volume scheduling on drives with errors.
- Phase out drives before removal.
To allow new volumes on cordoned drives again, use kubectl directpv uncordon.
Syntax
Parameters
DRIVE_ID
Optional
The unique identifier of one or more drives to cordon.
Specify multiple drive IDs separated by spaces.
Use kubectl directpv list drives to find drive IDs.
--all
Optional
Cordon all drives across all nodes. When specified, DirectPV ignores other selection flags.
--nodes
Optional
Cordon drives on specific nodes. Specify multiple nodes as a comma-separated list or by repeating the flag. Supports ellipsis expansion notation.
Short form: -n
--drives
Optional
Cordon drives by name. Specify multiple drives as a comma-separated list or by repeating the flag. Supports ellipsis expansion notation.
Short form: -d
--status
Optional
Cordon drives with a specific status.
Specify multiple statuses as a comma-separated list or by repeating the flag.
Valid values: error, lost, moving, ready, removed.
--dry-run
Optional
Display the drives to cordon, without making changes.
Global flags
This command supports the following global flags:
| Flag | Description |
|---|---|
--kubeconfig |
Path to the kubeconfig file to use for CLI requests. |
--quiet |
Suppress printing error messages. |
Examples
Cordon all drives in the cluster
Prevent volume scheduling on all drives:
kubectl directpv cordon --all
Cordon drives on multiple nodes using ellipsis notation
Use ellipsis expansion to cordon drives across a range of nodes:
kubectl directpv cordon --nodes=node{1...4} --drives=sd{a...f}
Cordon drives with errors
Prevent scheduling on all drives that have error status:
kubectl directpv cordon --status=error
Preview cordon operation for drives on a node
Check the drives to cordoned, without making changes:
kubectl directpv cordon --nodes=node1 --dry-run
Behavior
How cordoning works
Cordoning blocks a drive from receiving new volumes. When you cordon a drive:
- DirectPV marks the drive as cordoned.
- New volume scheduling requests skip the cordoned drive.
- Existing volumes on the drive remain accessible and functional.
- The drive status shows
Cordonedwhen listed.
Selection requirements
This command requires at least one selection method. The command returns an error if no drives are selected.
Cordoning and volume scheduling
DirectPV uses the directpv-min-io StorageClass with WaitForFirstConsumer volume binding mode.
When a pod requests a PersistentVolume:
- DirectPV evaluates available drives based on capacity and topology.
- Cordoned drives are excluded from consideration.
- DirectPV selects from remaining eligible drives.
For more details on volume scheduling, see Volume Scheduling.
Verify cordoned drives
After cordoning, verify the drive status:
kubectl directpv list drives --all
Cordoned drives show Cordoned in the status column.
Common use cases
Planned maintenance
Before taking a node offline for maintenance:
- Cordon the drives on that node.
- Perform maintenance tasks.
- Uncordon the drives when maintenance is complete.
Drive replacement
When replacing a drive:
- Cordon the drive to prevent new volumes.
- Migrate or delete existing volumes.
- Remove and replace the physical drive.
- Initialize the new drive with
kubectl directpv init.
Isolating problematic drives
If a drive shows errors:
- Cordon the drive immediately.
- Investigate the issue.
- Suspend the drive if repair is needed using
kubectl directpv suspend drives.