Skip to main content
BlockChaos allows you to inject delays into I/O operations on block devices and persistent volumes, simulating slow disk performance.

Actions

BlockChaos currently supports:
  • delay: Add latency to I/O requests on block devices

Spec Fields

spec.action
string
required
The block chaos action to perform.Options: delay
spec.volumeName
string
required
Name of the persistent volume to target.
spec.delay
object
Delay configuration for I/O operations.
spec.duration
string
Duration of the chaos action (e.g., 30s, 5m, 1h).
spec.selector
object
required
Pod selector to target specific pods. See Selector for details.
spec.mode
string
required
Selection mode for target pods.Options: one, all, fixed, fixed-percent, random-max-percent
spec.containerNames
array
List of container names to affect. If not set, the first container will be injected.
spec.remoteCluster
string
Remote cluster name where the chaos will be deployed.

Examples

Add I/O Delay to Persistent Volume

apiVersion: chaos-mesh.org/v1alpha1
kind: BlockChaos
metadata:
  name: hostpath-example-delay
spec:
  selector:
    labelSelectors:
      app: hostpath-example
  mode: all
  volumeName: hostpath-example
  action: delay
  delay:
    latency: 1s
This example adds 1 second of latency to all I/O operations on the hostpath-example volume for pods with the label app: hostpath-example.

Add I/O Delay with Jitter

apiVersion: chaos-mesh.org/v1alpha1
kind: BlockChaos
metadata:
  name: disk-delay-jitter
spec:
  selector:
    namespaces:
      - database
    labelSelectors:
      app: postgres
  mode: all
  volumeName: postgres-data
  action: delay
  delay:
    latency: 100ms
    jitter: 50ms
    correlation: "50"
  duration: "5m"
This example adds 100ms base latency with 50ms jitter (50-150ms range) and 50% correlation between consecutive delays to simulate realistic disk variability.

Prerequisites

  1. Persistent Volume: The target volume must be mounted in the pod
  2. Volume Name: You must know the name of the persistent volume (not the PVC name)
  3. Privileged Access: Chaos Daemon needs privileged access to manipulate block devices

Implementation Details

BlockChaos works by:
  1. Identifying the block device associated with the specified volume
  2. Using eBPF or kernel modules to intercept I/O operations
  3. Adding configured delays to I/O requests
The delay parameters allow you to simulate:
  • Constant delay: Set latency only
  • Variable delay: Add jitter for randomness
  • Correlated delay: Use correlation to make consecutive delays similar (simulating sustained disk slowness)
Source: api/v1alpha1/blockchaos_types.go:35-73

Limitations

  • Currently only supports the delay action
  • Requires knowledge of the persistent volume name (check with kubectl get pv)
  • Cannot target specific files or directories within a volume

Build docs developers (and LLMs) love