AWS Scaling In Termination Protection for EC2 Container Service

本秂侑毒 提交于 2019-12-23 04:48:37

问题


I am unable to figure out how to protect my ECS task instances when using Auto Scaling in Amazon AWS. I have a long running task that can scale out as required but I want to mark task instances that are running as "not destroyable". I have found several resources that talk about instance protection such as:

https://aws.amazon.com/blogs/aws/new-instance-protection-for-auto-scaling/

and (because I am using python) the API documentation is here:

http://boto3.readthedocs.io/en/latest/reference/services/autoscaling.html#AutoScaling.Client.set_instance_protection

This method requires an InstanceId and so I attempt to get the instance id of the current container by using a command like:

curl http://169.254.169.254/latest/meta-data/instance-id

However, this method just returns the instance id of the EC2 machine the task is running on. So my question is: Is there a way to get the instance id of a docker task instance (if that even exists)? If not is there another way I can prevent Auto Scaling from terminating a task that is still running? Do I have to write my own task manager that manages Scaling In?


回答1:


To solve the same issue, we developed a simple application which is started when a job is done on one of the Auto Scaling Group (ASG) instances. This application checks the queue and if there is no job in the queue (for let's say 10 minutes or 10 times) it terminates its instance and decrements the Desired value of the ASG. This provides us with a reliable mechanism for scaling in. Scaling out on the other hand, is done by the ASG itself based on the number of jobs in the queue.



来源:https://stackoverflow.com/questions/42348571/aws-scaling-in-termination-protection-for-ec2-container-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!