Simulate Pod Faults
PodChaos is a fault type in Chaos Mesh. By creating a PodChaos experiment, you can simulate fault scenarios of the specified Pods or containers. Currently, PodChaos supports the following fault types:
- Pod Failure: injects fault into a specified Pod to make the Pod unavailable for a period of time.
- Pod Kill: kills a specified Pod.To ensure that the Pod can be successfully restarted, you need to configure ReplicaSet or similar mechanisms.
- Container Kill: kills the specified container in the target Pod.
Currently, Chaos Mesh only supports fault injection to certain types of Pod, such as Deployment, StatefulSet, and DaemonSet. Chaos Mesh does not support injecting faults into an independent Pod. An independent Pod means a Pod that is not bound to ReplicaSet or Deployment Pod.
Before creating PodChaos experiments, ensure the following:
- There is no Control Manager of Chaos Mesh running on the target Pod.
- If the fault type is Pod Kill, replicaSet or a similar mechanism is configured to ensure that Pod can restart automatically.
note" class="reference-link">note
Before create experiments using Chaos Dashboard, ensure the following:
- Chaos Dashboard is installed.
- If Chaos Dashboard is already installed, you can run to access Dashboard:
bash kubectl port-forward -n chaos-testing svc/chaos-dashboard 2333:2333
. Then you can enter to access Chaos Dashboard.
Open Chaos Dashboard, and click NEW EXPERIMENT on the page to create a new experiment.
In the Choose a Target area, choose POD FAULT and select a specific behavior, such as POD FAILURE.
Submit the experiment information.
Write the experiment configuration to the
pod-failure.yaml
file:Based on this example, Chaos Mesh injects
pod-failure
into the specified Pod and makes the Pod unavailable for 30 seconds.-
kubectl apply -f ./pod-failure.yaml
Write the experiment configuration to the
pod-kill.yaml
file:Based on this example, Chaos Mesh injects
pod-kill
into the specified Pod and kills the Pod once.After the configuration file is prepared, use
kubectl
to create an experiment:kubectl apply -f ./pod-kill.yaml
Write the experiment configuration to the
container-kill.yaml
file:Based on this example, Chaos Mesh injects into the specified container and kills the container once.
-
The following table describes the fields in the YAML configuration file.