AwsChaos Experiment

This document introduces how to create AwsChaos experiments.

AwsChaos can help you inject faults into the specified AWS Instance, specifically ec2-stop, ec2-restart and detach-volume.

  • Ec2 Stop action periodically stops the specified ec2 instance.

  • Ec2 Restart action periodically reboots the specified ec2 instance.

  • Detach Volume action detaches the storage volume from the specified ec2 instance.

Secret file

In order to facilitate the connection to the AWS cluster, you can first create a kubernetes secret file to store related information (such as access key id).

Below is a sample secret file:

  1. apiVersion: v1
  2. kind: Secret
  3. metadata:
  4. name: cloud-key-secret
  5. namespace: chaos-testing
  6. type: Opaque
  7. stringData:
  8. aws_access_key_id: your-aws-access-key-id
  9. aws_secret_access_key: your-aws-secret-access-key
  • name defines the name of kubernetes secret.
  • namespace defines the namespace of kubernetes secret.
  • aws_access_key_id stores your AWS access key id.
  • aws_secret_access_key stores your AWS secret access key.

ec2-stop configuration file

Below is a sample ec2-stop configuration file:

  1. apiVersion: chaos-mesh.org/v1alpha1
  2. kind: AwsChaos
  3. metadata:
  4. name: ec2-stop-example
  5. namespace: chaos-testing
  6. spec:
  7. action: ec2-stop
  8. secretName: 'cloud-key-secret'
  9. awsRegion: 'us-east-2'
  10. ec2Instance: 'your-ec2-instance-id'
  11. duration: '5m'
  12. scheduler:
  13. cron: '@every 10m'

For more details about stopping ec2 instance, see docs.

For a detailed description of each field in the configuration template, see Fields description.

ec2-restart configuration file

Below is a sample ec2-restart configuration file:

  1. apiVersion: chaos-mesh.org/v1alpha1
  2. kind: AwsChaos
  3. metadata:
  4. name: ec2-restart-example
  5. namespace: chaos-testing
  6. spec:
  7. action: ec2-restart
  8. secretName: 'cloud-key-secret'
  9. awsRegion: 'us-east-2'
  10. ec2Instance: 'your-ec2-instance-id'
  11. duration: '5m'
  12. scheduler:
  13. cron: '@every 10m'

For more details about rebooting ec2 instance, see docs.

For a detailed description of each field in the configuration template, see Fields description.

detach-volume configuration file

Below is a sample detach-volume configuration file:

  1. apiVersion: chaos-mesh.org/v1alpha1
  2. kind: AwsChaos
  3. metadata:
  4. name: ec2-detach-volume-example
  5. namespace: chaos-testing
  6. spec:
  7. action: ec2-stop
  8. secretName: 'cloud-key-secret'
  9. awsRegion: 'us-east-2'
  10. ec2Instance: 'your-ec2-instance-id'
  11. volumeID: 'your-volume-id'
  12. deviceName: '/dev/sdf'
  13. duration: '5m'
  14. scheduler:
  15. cron: '@every 10m'

For more details about detaching an Amazon EBS volume, see docs.

For a detailed description of each field in the configuration template, see Fields description.

Fields description

  • action defines the specific chaos action for the AWS instance. Supported action: ec2-stop / ec2-restart / detach-volume.
  • secretName defines the kubernetes secret name used to store AWS information.
  • awsRegion defines the AWS region.
  • ec2Instance indicates the ID of the ec2 instance.
  • volumeID is needed in detach-volume action. It indicates the ID of the EBS volume.
  • deviceName is needed in detach-volume action. It indicates the name of the device.
  • duration defines the duration for each chaos experiment.
  • scheduler defines the scheduler rules for the running time of the chaos experiment. For more rule information, see robfig/cron.