为什么在集群中启用容量提供程序时需要在我的 Auto Scaling 组中启用实例缩减保护?

Why do I need to enable instance scale-in protection in my Auto Scaling Group when enabling a capacity provider within a cluster?

我正在使用 EC2 创建一个 AWS ECS 集群并尝试使用容量提供程序。我真的不明白为什么我需要在我的 AWS Auto Scaling 组中启用实例缩减保护。

Auto Scaling 的目的不就是终止不必要的 EC2 实例吗?

why do I need to enable instance scale-in protection

仅当您选择使用 managed scaling:

时才需要

When managed scaling is enabled, Amazon ECS manages the scale-in and scale-out actions of the Auto Scaling group used when creating the capacity provider. On your behalf, Amazon ECS creates an AWS Auto Scaling scaling plan with a target tracking scaling policy based on the target capacity value you specify.

托管扩展可确保在删除实例时由 ECS 控制。通过这样做,它可以保护任何具有某些任务 运行ning 的实例不被 terminated:

When managed termination protection is enabled, Amazon ECS prevents Amazon EC2 instances that contain tasks and that are in an Auto Scaling group from being terminated during a scale-in action.

整个想法是,您在 ASG 上启用实例缩减保护,以便 ECS 可以根据 运行 的任务控制 终止哪些实例。如果没有这个,您的 ASG 可能会根据其他标准终止实例,而不是与“不必要的 EC2 实例”无关。例如,ASG 可以选择终止基于 AZRebalance 进程的实例。这可能会导致 ASG 终止具有 运行ning 任务的实例,这可能不是您想要的。