Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/chaos-mesh/chaos-mesh/llms.txt

Use this file to discover all available pages before exploring further.

JVMChaos allows you to inject faults into JVM applications, including method latency, exceptions, return values, garbage collection, and stress.

API Version and Kind

apiVersion: chaos-mesh.org/v1alpha1
kind: JVMChaos

Metadata

Standard Kubernetes object metadata.
metadata.name
string
required
Name of the JVMChaos resource.
metadata.namespace
string
Namespace of the JVMChaos resource. Defaults to default.

Spec Fields

spec
JVMChaosSpec
required
Defines the behavior of the JVM chaos experiment.

JVMChaosSpec

selector
ContainerSelector
required
Selector for targeting containers. See ContainerSelector in Common Types.Inherits all fields from ContainerSelector (inline), including:
  • Pod selection criteria
  • Mode (one/all/fixed/fixed-percent/random-max-percent)
  • Value (for fixed modes)
  • Container names
action
JVMChaosAction
required
Specific JVM chaos action to perform.Enum values:
  • latency - Add latency to method invocation
  • return - Modify method return value
  • exception - Throw custom exception
  • stress - Apply CPU or memory stress
  • gc - Trigger garbage collection
  • ruleData - Inject fault with Byteman rule
  • mysql - MySQL Java client fault injection
duration
*string
Duration of the chaos action.A duration string with format like "300ms", "1.5h", or "2h45m".Valid time units: ns, us (µs), ms, s, m, h
port
int32
default:"9277"
Port of the agent server.Part of JVMCommonSpec (inline).
pid
int
PID of the Java process which needs to attach.Part of JVMCommonSpec (inline).
class
string
Java class name.Part of JVMClassMethodSpec (inline). Used for actions: latency, return, exception.
method
string
Method name in Java class.Part of JVMClassMethodSpec (inline). Used for actions: latency, return, exception.
name
string
Byteman rule name. Should be unique. Will be generated if not set.Part of JVMParameter (inline).
returnValue
string
Return value for action return.Part of JVMParameter (inline).
returnValue: "null"
exception
string
Exception to throw for action exception, or exception message for action mysql.Part of JVMParameter (inline).
exception: "java.lang.RuntimeException"
latency
int
Latency duration in milliseconds for action latency or mysql.Part of JVMParameter (inline).
latency: 1000  # 1 second
ruleData
string
Byteman rule data for action ruleData.Part of JVMParameter (inline).
cpuCount
int
CPU core number to use. Only set when action is stress.Part of JVMStressCfgSpec (inline).
memType
string
Memory type to locate. Only set when action is stress.Valid values: stack, heapPart of JVMStressCfgSpec (inline).
mysqlConnectorVersion
string
Version of mysql-connector-java. Only supports 5 (5.X.X) and 8 (8.X.X).Part of JVMMySQLSpec (inline). Used for action mysql.
database
string
Match database name. Empty string means match all databases.Part of JVMMySQLSpec (inline). Used for action mysql.
table
string
Match table name. Empty string means match all tables.Part of JVMMySQLSpec (inline). Used for action mysql.
sqlType
string
Match SQL type. Empty string means match all SQL types.Valid values: select, insert, update, delete, replacePart of JVMMySQLSpec (inline). Used for action mysql.
remoteCluster
string
Name of the remote cluster where the chaos will be deployed. If not specified, chaos is applied to the local cluster.

Status Fields

status
JVMChaosStatus
Current status of the chaos experiment.

JVMChaosStatus

conditions
[]ChaosCondition
Current global conditions. See ChaosStatus in Common Types.
experiment
ExperimentStatus
Last known experiment state including desired phase and container records.

Examples

Latency Injection

apiVersion: chaos-mesh.org/v1alpha1
kind: JVMChaos
metadata:
  name: jvm-latency
  namespace: chaos-mesh
spec:
  action: latency
  mode: one
  selector:
    namespaces:
      - default
    labelSelectors:
      app: java-app
  class: "com.example.HelloWorld"
  method: "sayHello"
  latency: 5000
  duration: "1m"

Exception Injection

apiVersion: chaos-mesh.org/v1alpha1
kind: JVMChaos
metadata:
  name: jvm-exception
  namespace: chaos-mesh
spec:
  action: exception
  mode: one
  selector:
    namespaces:
      - default
    labelSelectors:
      app: java-app
  class: "com.example.Database"
  method: "query"
  exception: "java.sql.SQLException"
  duration: "30s"