Skip to main content

pod-cpu-stress

Runs CPU stress workers inside the pod's cgroup namespace, consuming CPU cycles for the experiment duration.

Target kind: Pod
Implementation: Daemon (ExecStressChaos with stressorType: cpu)
Rollback: Yes — sends CancelChaos to terminate stress-ng

Parameters

NameTypeRequiredDefaultDescription
workersstringNo"1"Number of CPU stress worker threads
loadstringNo"100"Target CPU load percentage (0-100)
durationstringNoexperiment durationHow long to run stress (e.g. 60s, 5m)

Example

apiVersion: chaos.chaosplane.io/v1alpha1
kind: ChaosExperiment
metadata:
name: pod-cpu-stress-example
namespace: default
spec:
target:
kind: Pod
namespace: default
labelSelector:
matchLabels:
app: api-server
action:
type: pod-cpu-stress
parameters:
workers: "2"
load: "80"
duration: "60s"
duration: 60s
rollback:
enabled: true
timeout: 30s

Rollback behavior

The operator stores the execution ID returned by the daemon. On rollback, it sends a CancelChaos RPC with that execution ID. The daemon terminates the stress-ng process.

Implementation notes

The daemon runs stress-ng inside the pod's cgroup namespace so CPU consumption is attributed to the pod and subject to its resource limits. The workers parameter maps to stress-ng --cpu N and load maps to --cpu-load N.

The operator tracks execution IDs per experiment UID to support concurrent experiments on the same node.