Florian Dambrine - Senior DevOps Engineer - @GumGum
@DambrineF
Elastigroup is a cluster orchestration and scaling service that ensures maximum availability for minimum costs.
### Launch configuration
resource "aws_launch_configuration" "this" {
name_prefix = "${coalesce(var.lc_name, var.name)}-"
image_id = "${var.image_id}"
instance_type = "${var.instance_type}"
...
lifecycle {
create_before_destroy = true
}
}
### Autoscaling group
resource "aws_autoscaling_group" "this" {
name_prefix = "${coalesce(var.asg_name, var.name)}-"
launch_configuration = "${aws_launch_configuration.this.name}"
...
load_balancers = ["${var.load_balancers}"]
}
### Spotinst Elastigroup
resource "spotinst_elastigroup_aws" "this" {
name = "${var.name}"
product = "Linux/UNIX"
instance_types_ondemand = "c5.large"
instance_types_spot = ["c5.large", "c4.large"]
instance_types_preferred_spot = ["c5.large"]
spot_percentage = "0"
fallback_to_ondemand = true
utilize_reserved_instances = true
elastic_load_balancers = [
"${var.load_balancers}",
]
}
asg.tf VS. esg.tf
Why do we love ESGs ?
resource "spotinst_elastigroup_aws" "this" {
...
spot_percentage = "0" -> "100"
fallback_to_ondemand = true / false
utilize_reserved_instances = true / false
}
resource "spotinst_elastigroup_aws" "this" {
...
integration_ecs {
cluster_name = "${var.name}"
autoscale_is_enabled = true
autoscale_cooldown = 180
autoscale_is_auto_config = true
}
}
Automation is great but auto-recovery is better
Painless management
---
pipeline:
esg_scale:
image: lowess/drone-spotinst-esg-scaler
account_id: act-1234abcd
esg_name: va-web--stage
adjustement: +1
secrets:
- source: spotinst_api_token
target: api_token