kube-aws / kube-spot-termination-notice-handler

A Kubernetes DaemonSet to gracefully delete pods 2 minutes before an EC2 Spot Instance gets terminated
Apache License 2.0
378 stars 77 forks source link

Detach instance from ASG if ASG_NAME is available #14

Closed Sudiksha closed 5 years ago

Sudiksha commented 5 years ago

After an instance is terminated, it takes time for ASG to identify this and launch a new replacement instance. To cater to this time window, this PR makes sure that before triggering kubectl drain on the instance, the instance is detached from that ASG. ASG will itself launch the replacement instance (this availability chances are now more after the release of https://aws.amazon.com/blogs/aws/new-ec2-auto-scaling-groups-with-multiple-instance-types-purchase-options/)

Changes:

  1. Take an environment variable "ASG_NAME" to which instance is attached.
  2. If the environment variable is set, detach the instance from that ASG
egeland commented 5 years ago

I've based my PR #15 on your idea, @Sudiksha - hope this works for you?

Sudiksha commented 5 years ago

@egeland I have incorporated your review comments in this branch today itself. Sorry, couldnt make it up before due to multiple other items.

And your new PR also works for us. Hope to see it merged sooner and a new release version.