AWS AutoScaling 'oldestinstance' Termination Policy does not always terminate the oldest instances

Scenario

I create a script that will start new instances in the AutoScaling group and then delete the old instances. The goal is to introduce the newly created (or updated) AMI into the AutoScaling group. This is achieved by increasing the capacity Desireddue to the double current number of copies. Then, after the appearance of new copies Running, a decrease in capacity Desiredby the same number.

Problem

When I run the script, I observe a double increase in the group, new instances go online, they reach the state Running, and then the group capacity decreases. It works like a charm. The problem is that SOMETIMES instances that end with a decrease are actually new and not older.

Question

How can I guarantee that the AutoScaling group will always abort the oldest instance?

Settings

  • The AutoScaling group has the following Termination Polices: OldestInstance, OldestLaunchConfiguration. The policy has Defaultbeen deleted.
  • Default Cooldown set to 0 seconds.
  • There is only one availability zone in a group.

Troubleshooting

  • I played with customization Cooldown. Ended up by just putting it at 0.
  • , , . , 5 , , . , 20 , . , ?

, , , . . , , AutoScaling . .

, OldestInstance Termination Policy.

: 12 2014 . . , , , . . Amazon , -, .

: 21 2014 . AWS, , . .

+4
3

:

  • 2x
  • , .
  • , AS (as-suspend- MyAutoScalingGroup)
  • Reset
  • AS.

:

  • ASG .
  • AS , 1.
  • , ASG.
  • AS

:

  • ELB (, Amazon , , ).
  • ASG LC
  • DNS ELB
  • ELB/ASG/LC, , DNS

API ASG, / ASG:

, , , ASG, , , ( ), .

.

0

- , , . , "OldestFirst" . attach/detach, ambakshi , ( , ) .

1 - , .

2 - ASG

3 - , , . " - "

4 -

5 - CLI

UPDATE

There is no need to pause the auto-scaling group, only steps 1, 3, and 5 are performed for me. Just remember about balancing the availability zone that can happen.

0
source

Source: https://habr.com/ru/post/1523623/


All Articles