Simulate Pod Faults
This document describes how to use Chaos Mesh to inject faults into Kubernetes Pod to simulate Pod or container faults. Chaos Dashboard and YAML files are provided to create PodChaos experiments.
PodChaos introduction
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.
Usage restrictions
Chaos Mesh can inject PodChaos into any Pod, no matter whether the Pod is bound to Deployment, StatefulSet, DaemonSet, or other controllers. However, when you inject PodChaos into an independent Pod, some different situations might occur. For example, when you inject "pod-kill" chaos into an independent Pod, Chaos Mesh cannot guarantee that the application recovers from its failure.
Notes
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.
Create Experiments Using Chaos Dashboard
Before create experiments using Chaos Dashboard, ensure the following:
- Chaos Dashboard is installed.
- If Chaos Dashboard is already installed, you can run
kubectl port-forward
to access Dashboard:bash kubectl port-forward -n chaos-mesh svc/chaos-dashboard 2333:2333
. Then you can enterhttp://localhost:2333
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.
-
Fill out the experiment information, and specify the experiment scope and the scheduled experiment duration.
-
Submit the experiment information.