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

CommandDescription
cleanRemove stale volumes in released or deleted status
moveMove volume metadata between drives on the same node
removeRemove 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. Add the replacement drive to DirectPV. Run kubectl directpv discover, then initialize the new drive:

    kubectl directpv init drives.yaml --dangerous
  2. Cordon the failing drive and the new drive, so neither takes new volumes:

    kubectl directpv cordon <source-drive-id> <dest-drive-id>
  3. Stop the pods that use volumes on the failing drive. The move command does not move a volume that a pod is using.

  4. Copy data from the failing drive to the replacement drive (outside of DirectPV).

  5. Move volume metadata to the new drive:

    kubectl directpv move <source-drive-id> <dest-drive-id>
  6. Uncordon the new drive:

    kubectl directpv uncordon <dest-drive-id>
  7. Remove the old drive from DirectPV:

    kubectl directpv remove --drives=sda --nodes=node1

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

On this page