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:
-
Add the replacement drive to DirectPV. Run
kubectl directpv discover, then initialize the new drive:kubectl directpv init drives.yaml --dangerous -
Cordon the failing drive and the new drive, so neither takes new volumes:
kubectl directpv cordon <source-drive-id> <dest-drive-id> -
Stop the pods that use volumes on the failing drive. The
movecommand does not move a volume that a pod is using. -
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> -
Uncordon the new drive:
kubectl directpv uncordon <dest-drive-id> -
Remove the old drive from DirectPV:
kubectl directpv remove --drives=sda --nodes=node1
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