Slide 1

Slide 1 text

ASG and lifecycle hooks ASG and lifecycle hooks Sibi Prabakaran May 15, 2019

Slide 2

Slide 2 text

Objective Objective Run scripts before terminating EC2 instances of an ASG group Like de registering the instances from ALB. Inform Kubernetes/Nomad that this instance is in-eligible for new tasks

Slide 3

Slide 3 text

Terminology Terminology ASG: Collection of EC2 instances with policies on scaling. Lifecycle hooks: Like callbacks which can be added to ASG.

Slide 4

Slide 4 text

ASG Events ASG Events Scale Out: Instructs ASG to launch new instances. Scale In: Instructs ASG to detach EC2 instances. Fired on Manually increasing the size of the group Based on Policy (like demand) Based on Schedule

Slide 5

Slide 5 text

ASG Events (2) ASG Events (2) On receiving the events, the ASG will put the instance into Pending or Terminating state. If you have defined any lifecycle hooks - that will happen in this state. Timeouts

Slide 6

Slide 6 text

lifecycled lifecycled Daemon built by buildkite for gracefully handling EC2 scaling events. When a termination notice is received, lifecycled runs a user provided script before proceeding to shutdown the instance. Repo: https://github.com/buildkite/lifecycled

Slide 7

Slide 7 text

Demo Demo PR: https://github.com/fpco/terraform-aws-foundation/pull/189 Testing instance: http://18.222.32.132:3000 Based on vpc scenario 1 (VPC with single public subnet). ASG with two EC2 instances, also registered with ELB. Instances has lifecycled installed on it.

Slide 8

Slide 8 text

Questions Questions