Elastigroups that utilize the Stateful Spot Instances can schedule capacity changes, for example for QA environments that need to launch instances in the morning and terminate them at night or the weekend.
Elastigroups allows you to set Jobs based on a Cron expression. This means you can trigger a change in capacity. Each line of a cron expression represents a job and looks like this:
┌───────────── minute (0 - 59) │ ┌───────────── hour (0 - 23) │ │ ┌───────────── day of month (1 - 31) │ │ │ ┌───────────── month (1 - 12) │ │ │ │ ┌───────────── day of week (0 - 6) (Sunday to Saturday; │ │ │ │ │ 7 is also Sunday on some systems) │ │ │ │ │ │ │ │ │ │ * * * * *
5 21 * * 1-5 = “At 21:05 on every day-of-week from Monday through Friday”
We recommend using https://crontab.guru/ to create and verify your Cron expressions.
How Stateful Scheduling Works
A change in capacity for a Stateful Spot Instance (SSI) triggers the following set of actions. For capacity-reducing scheduled actions, the instance is paused and the EBS volumes and Elastic Network Interface are detached and are kept in an available state until the capacity increase. Capacity increases resume the paused instances, with the existing resources attached to the new instances as they launch.
How to Set Scheduling
- Edit the Elastigroup configuration via the Actions menu or create a new Elastigroup.
- In the General tab scroll to locate Scheduling and expand it.
- Click on Add Task
- Set the Action type to Set Stateful Capacity Range
- Select the new Target, Min and Max limits (optional)
- Provide the Cron expression that sets the time the Action will take place.
Add more scheduling rules as needed, then Update or Create the Elastigroup.