Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ASG and lifecycle hooks

May 15, 2019

ASG and lifecycle hooks


May 15, 2019

More Decks by Sibi

Other Decks in Technology


  1. 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
  2. Terminology Terminology ASG: Collection of EC2 instances with policies on

    scaling. Lifecycle hooks: Like callbacks which can be added to ASG.
  3. 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
  4. 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
  5. 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
  6. Demo Demo PR: https://github.com/fpco/terraform-aws-foundation/pull/189 Testing instance: 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.