Simulate AWS Faults
This document describes how to use Chaos Mesh to simulate AWS faults.
AWSChaos can help you simulate fault scenarios on the specified AWS instance. Currently, AWSChaos supports the following fault types:
- EC2 Stop: stops the specified EC2 instance.
- Detach Volume: uninstalls the storage volume from the specified EC2 instance.
To easily connect to the AWS cluster, you can create a Kubernetes Secret
file to store the authentication information in advance.
A Secret
file sample is as follows:
- name means the Kubernetes Secret object.
- namespace means the namespace of the Kubernetes Secret object.
- aws_access_key_id stores the ID of the access key to the AWS cluster.
- aws_secret_access_key stores the secrete access key to the AWS cluster.
note
Before you create an experiment using Chaos Dashboard, make sure the following requirements are met:
Chaos Dashboard is installed.
Chaos Dashboard can be accessed via
kubectl port-forward
:kubectl port-forward -n chaos-testing svc/chaos-dashboard 2333:2333
You can then access the dashboard via http://localhost:2333 in your browser.
In the “Choose a Target“ area, choose AWS FAULT and select a specific behavior, such as STOP EC2.
Submit the experiment information.
Write the experiment configuration to the
awschaos-ec2-stop.yaml
file, as shown below:Based on this configuration example, Chaos Mesh will inject the
ec2-stop
fault into the specified EC2 instance so that the EC2 instance will be unavailable in 5 minutes.For more information about stopping EC2 instances, refer to .
After the configuration file is prepared, use
kubectl
to create an experiment:
-
Based on this configuration example, Chaos Mesh will inject
ec2-restart
fault into the specified EC2 instance so that the EC2 instance will be restarted.For more information about restarting the EC2 instance, refer to the AWS documentation - Reboot your instance.
After the configuration file is prepared, use
kubectl
to create an experiment:kubectl apply -f awschaos-ec2-restart.yaml
Write the experiment configuration to the
awschaos-detach-volume.yaml
file:Based on this configuration example, Chaos Mesh will inject a
detail-volume
fault into the specified EC2 instance so that the EC2 instance is detached from the specified storage volume within 5 minutes.For more information about detaching Amazon EBS volumes, refer to the .
After the configuration file is prepared, use
kubectl
to create an experiment:kubectl apply -f awschaos-detach-volume.yaml
The following table shows the fields in the YAML configuration file.