kubectl directpv suspend volumes

The kubectl directpv suspend volumes command suspends volumes and marks them as read-only. Suspending a volume mounts it to an empty temporary directory, allowing StatefulSet pods to start even when the volume data is unavailable.

Volumes become read-only
Suspending a volume makes it read-only. Applications attempting to write to the volume fail until you resume it.

To restore normal operation, use kubectl directpv resume volumes. For information on volume operations, see Managing Volumes.

Syntax

Aliases

The following aliases have the same function:

  • kubectl directpv suspend volume
  • kubectl directpv suspend vol

Parameters

VOLUME

Optional

The name of one or more volumes to suspend. Specify multiple volume names separated by spaces. Use kubectl directpv list volumes to find volume names.

--dangerous

Required

Confirms that you understand suspending volumes makes them read-only. The command does not run without this flag.

--nodes

Optional

Suspend volumes on specific nodes. Specify multiple nodes as a comma-separated list or by repeating the flag. Supports ellipsis expansion notation.

Short form: -n

--drives

Optional

Suspend volumes on specific drives by name. Specify multiple drives as a comma-separated list or by repeating the flag. Supports ellipsis expansion notation.

Short form: -d

--pod-names

Optional

Suspend volumes by pod name. Specify multiple names as a comma-separated list or by repeating the flag. Supports ellipsis expansion notation.

--pod-namespaces

Optional

Suspend volumes by pod namespace. Specify multiple namespaces as a comma-separated list or by repeating the flag. Supports ellipsis expansion notation.

--dry-run

Optional

Display what volumes would be suspended without making changes.

Global flags

This command supports the following global flags:

Flag Description
--kubeconfig Path to the kubeconfig file to use for CLI requests.
--quiet Suppress printing error messages.

Examples

Suspend a volume by name

Suspend a specific volume:

kubectl directpv suspend volumes pvc-0700b8c7-85b2-4894-b83a-274484f220d0 --dangerous

Suspend all volumes on a node

Suspend all volumes on node1:

kubectl directpv suspend volumes --nodes=node1 --dangerous

Suspend volumes on a specific drive

Suspend all volumes on drive sda on node1:

kubectl directpv suspend volumes --nodes=node1 --drives=sda --dangerous

Preview suspend operation

Check which volumes would be suspended without making changes:

kubectl directpv suspend volumes --nodes=node1 --dry-run

Behavior

Why suspend volumes?

By Kubernetes design, an active StatefulSet workload requires that all of its Pods are in a running state. A faulty volume prevents the StatefulSet from starting.

Suspending a volume provides a workaround by mounting it to an empty temporary directory (/var/lib/directpv/tmp) with read-only access. This allows the StatefulSet to start while addressing the underlying issue.

What happens when suspending a volume?

When you suspend a volume:

  1. DirectPV remounts the volume to an empty temporary directory.
  2. The volume becomes read-only.
  3. The volume status shows Suspended.
  4. StatefulSet Pods using the volume can start (with read-only data access).

Selection requirements

You must specify at least one selection method:

  • One or more VOLUME arguments
  • --nodes flag
  • --drives flag
  • --pod-names flag
  • --pod-namespaces flag

When you specify multiple selection flags, DirectPV suspends only volumes that match all criteria (AND logic).

Verify volume status

After suspending, verify the volume status:

kubectl directpv list volumes --all

Suspended volumes show Suspended in their status.

After maintenance

After completing maintenance or repair:

  1. Resume the volume using kubectl directpv resume volumes.
  2. Verify volume status using kubectl directpv list volumes.