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:

  1. List volumes to identify stale resources:
    kubectl directpv list volumes --all
    
  2. Clean volumes in released or deleted status:
    kubectl directpv clean --all
    

Replace a failing drive

When a drive shows errors and needs replacement:

  1. Cordon the drive to prevent new volumes:

    kubectl directpv cordon --drives=sda --nodes=node1
    
  2. Copy data from the failing drive to the replacement drive (outside of DirectPV).

  3. Move volume metadata to the new drive:

    kubectl directpv move <source-drive-id> <dest-drive-id>
    
  4. Remove the old drive from DirectPV:

    kubectl directpv remove --drives=sda --nodes=node1
    
  5. Initialize the new drive:

    kubectl directpv init drives.yaml
    

Decommission a node

When removing a node from the cluster:

  1. Cordon all drives on the node:

    kubectl directpv cordon --nodes=node1
    
  2. Migrate or delete volumes from the node.

  3. Remove all drives from DirectPV:

    kubectl directpv remove --nodes=node1