Skip to main content

ECS task scale

ECS task scale is an AWS fault that injects chaos to scale (up or down) the ECS tasks based on the services and checks the task availability. This fault affects the availability of a task in an ECS cluster.

ECS Task Scale

Use cases

ECS task scale:

  • Affects the availability of a task in a cluster.
  • Determines the resilience of an application when ECS tasks are unexpectedly scaled up (or down).

Prerequisites

  • Kubernetes >= 1.17
  • Sufficient AWS permissions to scale the ECS tasks.
  • The target ECS tasks should be in a healthy state.
  • Kubernetes secret that has the AWS access configuration (key) in the CHAOS_NAMESPACE. Below is a sample secret file:
apiVersion: v1
kind: Secret
metadata:
name: cloud-secret
type: Opaque
stringData:
cloud_config.yml: |-
# Add the cloud AWS credentials respectively
[default]
aws_access_key_id = XXXXXXXXXXXXXXXXXXX
aws_secret_access_key = XXXXXXXXXXXXXXX
tip

HCE recommends that you use the same secret name, that is, cloud-secret. Otherwise, you will need to update the AWS_SHARED_CREDENTIALS_FILE environment variable in the fault template with the new secret name and you won't be able to use the default health check probes.

Below is an example AWS permission to help execute the fault.

{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"ecs:ListServices",
"ecs:DescribeServices",
"ecs:UpdateService"
],
"Resource": "*"
}
]
}
note

Mandatory tunables

Tunable Description Notes
CLUSTER_NAME Name of the target ECS cluster. For example, cluster-1. For more information, go to ECS cluster name.
REGION Region name of the target ECS cluster. For example, us-east-1.
SERVICE_NAMES Comma-separated target ECS service names. For example, svc1,sv2. For more information, go to ECS service name.
REPLICAS Number of replicas to scale up or down to. Default: 5. For more information, go to task replicas.

Optional tunables

Tunable Description Notes
TOTAL_CHAOS_DURATION Duration that you specify, through which chaos is injected into the target resource (in seconds). Default: 30 s. For more information, go to duration of the chaos.
SEQUENCE Sequence of chaos execution for multiple services. Default: parallel. Supports parallel and serial sequences. For example, 30 s. For more information, go to sequence of chaos execution.
RAMP_TIME Period to wait before and after injecting chaos (in seconds). For example, 30 s. For more information, go to ramp time.

ECS service name

Comma-separated serice names that derives the task. Tune it by using the SERVICE_NAMES environment variable.

The following YAML snippet illustrates the use of this environment variable:

# scale the tasks of an ECS cluster
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
name: engine-nginx
spec:
engineState: "active"
annotationCheck: "false"
chaosServiceAccount: litmus-admin
experiments:
- name: ecs-task-scale
spec:
components:
env:
# provide the name of ECS cluster
- name: CLUSTER_NAME
value: 'demo'
- name: SERVICE_NAMES
value: 'test-svc'

ECS task replicas

Number of replicas to scale up (or down) to. Tune it by using the REPLICAS environment variable.

The following YAML snippet illustrates the use of this environment variable:

# scale the tasks of an ECS cluster
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
name: engine-nginx
spec:
engineState: "active"
annotationCheck: "false"
chaosServiceAccount: litmus-admin
experiments:
- name: ecs-task-scale
spec:
components:
env:
# provide the number of replicas
- name: REPLICAS
value: '5'