CLI Reference
Prerequisites
The DirectPV commands rely on the Kubernetes command line tool, kubectl.
To install kubectl on your system, see the Kubernetes documentation.
Install DirectPV plugin
DirectPV provides a kubectl plugin for managing DirectPV drives and volumes.
Use this plugin at the command line to complete all of the functions required for adding, managing, scheduling, and removing DirectPV-managed drives and volumes in a Kubernetes cluster.
Install the directpv plugin by downloading the binary for your specific architecture and moving it to the /usr/local/bin folder on your local machine:
Usage
kubectl directpv [command] [flags]
Flags
The following flags are available for kubectl directpv and many of the commands included with the plugin.
| Flag | Description |
|---|---|
-h, --help |
Display help for DirectPV. |
--kubeconfig string |
Path to the kubeconfig file to use for CLI requests. |
--quiet |
Suppress printing error messages. |
--version |
Display the DirectPV version. |
Ellipsis expansion notation
Many DirectPV commands support ellipsis expansion notation for specifying ranges of nodes or drives. This allows you to target multiple resources with a single pattern instead of listing each one individually.
Use three dots (...) between the start and end values inside curly braces:
| Pattern | Expands to |
|---|---|
node{1...4} |
node1, node2, node3, node4 |
sd{a...d} |
sda, sdb, sdc, sdd |
nvme{0...2}n1 |
nvme0n1, nvme1n1, nvme2n1 |
Example: List drives sda through sdf on nodes node1 through node4:
kubectl directpv list drives --nodes=node{1...4} --drives=sd{a...f}
Resource selection
Many DirectPV commands operate on drives or volumes that you select using flags or arguments. These commands require at least one selection method to prevent accidental operations on unintended resources.
Selection methods
Commands typically support one or more of the following selection methods:
| Method | Description |
|---|---|
| Resource ID argument | Specify one or more drive or volume IDs directly as arguments |
--all |
Select all matching resources |
--nodes |
Select resources on specific nodes |
--drives |
Select resources on drives with specific names |
--drive-id |
Select resources on drives with specific IDs |
--status |
Select resources with a specific status |
--labels |
Select resources with specific labels |
--pod-names |
Select volumes associated with specific pods |
--pod-namespaces |
Select volumes in specific namespaces |
Not every command supports all flags. See individual command documentation for supported selection methods.
Selection behavior
- If you do not specify a selection method, the command returns an error.
- When you specify
--all, DirectPV ignores other selection flags. - You can combine multiple selection flags to narrow results (for example,
--nodes=node1 --drives=sda). DirectPV only selects resources that match all selection flags, usingANDlogic.
Available commands
This documentation includes details for each available command on separate subpages. The available commands include:
Cluster commands
| Command | Description |
|---|---|
| install | Install DirectPV in Kubernetes |
| discover | Probe nodes for available drives and generate a configuration file |
| init | Format and initialize drives for DirectPV management |
| info | Show information about DirectPV installation |
| uninstall | Uninstall DirectPV from Kubernetes |
Drive commands
| Command | Description |
|---|---|
| label drives | Add, update, or remove labels on drives for scheduling |
| list drives | Display drive status, capacity, and volume information |
| repair | Repair XFS filesystem errors on drives |
| resume drives | Resume suspended drives to restore normal operation |
| suspend drives | Suspend drives for maintenance (mounts volumes read-only) |
Maintenance commands
| Command | Description |
|---|---|
| clean | Remove stale volumes in released or deleted status |
| move | Move volume metadata from source drive to destination drive on the same node |
| remove | Remove unused drives from DirectPV |
Scheduling commands
Volume commands
| Command | Description |
|---|---|
| list volumes | Display volume status, capacity, and pod assignments |
| label volumes | Add, update, or remove labels on volumes |
| suspend volumes | Suspend volumes for maintenance (mounts read-only) |
| resume volumes | Resume suspended volumes to restore normal operation |
Command history
Deprecated commands
The following commands have been removed from DirectPV. See Deprecated Commands for historical reference.
| Command | Removed in | Reason |
|---|---|---|
| migrate | DirectPV 5.1.0 | Legacy DirectCSI migration support removed |
DirectPV command changes
| Old command | Replacement |
|---|---|
kubectl directpv discover |
kubectl directpv init |
Command changes from DirectCSI
| DirectCSI command | DirectPV command |
|---|---|
kubectl directcsi drives list |
kubectl directpv list drives |
kubectl directcsi volumes list |
kubectl directpv list volumes |
kubectl directcsi format |
kubectl directpv discover, then kubectl directpv init |