Maintenance Commands
Use maintenance commands to manage the lifecycle of DirectPV volumes and drives. These commands help you clean up stale resources, relocate volumes, and decommission drives.
Commands
| Command | Description |
|---|---|
| clean | Remove stale volumes in released or deleted status |
| move | Move volume metadata between drives on the same node |
| remove | Remove unused drives from DirectPV |
Common workflows
Clean up after workload deletion
After deleting Kubernetes workloads that used DirectPV volumes:
- List volumes to identify stale resources:
kubectl directpv list volumes --all - Clean volumes in released or deleted status:
kubectl directpv clean --all
Replace a failing drive
When a drive shows errors and needs replacement:
-
Cordon the drive to prevent new volumes:
kubectl directpv cordon --drives=sda --nodes=node1 -
Copy data from the failing drive to the replacement drive (outside of DirectPV).
-
Move volume metadata to the new drive:
kubectl directpv move <source-drive-id> <dest-drive-id> -
Remove the old drive from DirectPV:
kubectl directpv remove --drives=sda --nodes=node1 -
Initialize the new drive:
kubectl directpv init drives.yaml
Decommission a node
When removing a node from the cluster:
-
Cordon all drives on the node:
kubectl directpv cordon --nodes=node1 -
Migrate or delete volumes from the node.
-
Remove all drives from DirectPV:
kubectl directpv remove --nodes=node1