【发布时间】:2020-10-14 07:39:21
【问题描述】:
我有这个 bash 脚本:
#!/bin/bash
myClusterId="myCluster"
for service in $(aws ecs list-services --cluster $myClusterId --query "serviceArns[*]" | jq -r 'to_entries[] | .value | sub(".*/";"")'); do
for task in $( aws ecs list-tasks --cluster $myClusterId --service-name $service --desired-status 'RUNNING' --no-paginate --output text --query 'taskArns[*]' ) ; do
aws ecs stop-task --cluster $myClusterId --task $task --reason "Restarted using bash script" > /dev/null 2>&1
done
done
简而言之,它将重新启动我在 myCluster 下的所有 ECS Fargate 任务(不包括由 CloudWatch 规则触发的计划任务)。到目前为止一切正常。
我所有的服务都将minHealthyPercent 设置为100,maxHealthyPercent 设置为200。但是,我注意到它在重启过程中没有保持任何健康的任务。当新任务处于挂起/配置状态时,所有任务都会立即终止,并且我的负载均衡器会抛出 503 Service Temporarily Unavailable 错误。
我的脚本中是否缺少某些内容?如何使用 AWS CLI 正确执行无停机服务重启过程?
【问题讨论】:
标签: amazon-web-services aws-fargate aws-cdk