Amazon Fargate 任务维护 - Amazon Elastic Container Service
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

Amazon Fargate 任务维护

Amazon负责维护 Amazon Fargate 的底层基础架构。 Amazon确定何时需要用新修订版替换平台版本修订版。这就是所谓的任务退休。可能需要停用修订版的原因有很多,包括安全漏洞和性能改进。当修订版停用时,在该修订版上运行的所有任务都将停止。

Amazon ECS 任务可以分为服务任务和独立任务。

服务任务

服务任务是作为 Amazon ECS 服务的一部分部署的任务,由服务调度器监督。

要停用服务任务,您无需采取任何操作。 Amazon停止任务,然后使用服务的最低健康百分比启动新任务,以保持所需的服务计数。默认情况下,服务的最小正常百分比为 100%,因此在停止任务之前应先启动新任务。在扩展服务、部署配置更改或部署任务定义修订版时,通常以相同的方式替换服务任务。

独立任务

独立任务是通过 ECS API 的RunTask操作直接启动的任务,也可以由外部计划程序启动,例如计划任务(由 Amazon 启动 EventBridge)Amazon Batch、或Amazon Step Functions。

对于独立任务停用,Amazon请在任务停用日期当天或之后停止任务。任务停止后,Amazon ECS 不会启动替换任务。因此,我们建议客户监控独立任务的状态,并在需要时实施逻辑来替换已停止的任务。

在任何情况下,当任务停止时,您都可以运行describe-tasks。响应stoppedReason中的是ECS is performing maintenance on the underlying infrastructure hosting the task

此外,当有新的软件更新(包括安全补丁和其他更新)时,Amazon会发送任务停用通知。

为了准备任务停用过程,我们建议通过模拟此场景来测试您的应用程序行为。通过停止您的服务中的单个任务来测试复原能力,可以实现此目的。

了解任务停用通知

任务停用通知包括以下信息:

  • 任务停用日期-任务在此日期或之后停止。

  • 对于独立任务,指任务的 ID。

  • 对于服务任务,是运行服务的集群的 ID 和服务的 ID。

  • 接下来你需要采取的步骤。

通知分组为受影响的服务任务的一份通知和每份受影响的独立任务的通知Amazon Web Services 区域。有时您可能会收到该任务类型的多个事件,例如,当服务达到系统限制(例如事件大小)时。

您可以通过以下方式确定计划停用的任务:

  • 这些区域有:Amazon Health Dashboard

    Amazon Health通知可以通过亚马逊发送 EventBridge 到存档存储(例如亚马逊简单存储服务)、执行自动操作(例如运行Amazon Lambda函数)或其他通知系统(例如亚马逊简单通知服务)。有关更多信息,请参阅使用亚马逊监控Amazon Health事件 EventBridge。有关向 Amazon Chime、Slack 或 Microsoft Teams 发送通知的示例配置,请参阅上的 A Amazon Healthw are 存储库。 GitHub

    以下是一个示例 EventBridge 事件。

    { "version": "0", "id": "3c268027-f43c-0171-7425-1d799EXAMPLE", "detail-type": "AWS Health Event", "source": "aws.health", "account": "123456789012", "time": "2023-08-16T23:18:51Z", "region": "us-east-1", "resources": [ "cluster/service", "cluster/service" ], "detail": { "eventArn": "arn:aws:health:us-east-1::event/ECS/AWS_ECS_TASK_PATCHING_RETIREMENT/AWS_ECS_TASK_PATCHING_RETIREMENT_test1", "service": "ECS", "eventScopeCode": "ACCOUNT_SPECIFIC", "communicationId": "7988399e2e6fb0b905ddc88e0e2de1fd17e4c9fa60349577446d95a18EXAMPLE", "lastUpdatedTime": "Wed, 16 Aug 2023 23:18:52 GMT", "eventRegion": "us-east-1", "eventTypeCode": "AWS_ECS_TASK_PATCHING_RETIREMENT", "eventTypeCategory": "scheduledChange", "startTime": "Wed, 16 Aug 2023 23:18:51 GMT", "endTime": "Fri, 18 Aug 2023 23:18:51 GMT", "eventDescription": [ { "language": "en_US", "latestDescription": "\\nA software update has been deployed to Fargate which includes CVE patches or other critical patches. No action is required on your part. All new tasks launched automatically uses the latest software version. For existing tasks, your tasks need to be restarted in order for these updates to apply. Your tasks running as part of the following ECS Services will be automatically updated beginning Wed, 16 Aug 2023 23:18:51 GMT.\\n\\nAfter Wed, 16 Aug 2023 23:18:51 GMT, the ECS scheduler will gradually replace these tasks, respecting the deployment settings for your service. Typically, services should see little to no interruption during the update and no action is required. When AWS stops tasks, AWS uses the minimum healthy percent (1) and launches a new task in an attempt to maintain the desired count for the service. By default, the minimum healthy percent of a service is 100 percent, so a new task is started first before a task is stopped. Service tasks are routinely replaced in the same way when you scale the service or deploy configuration changes or deploy task definition revisions. If you would like to control the timing of this restart you can update the service before Wed, 16 Aug 2023 23:18:51 GMT, by running the update-service command from the ECS command-line interface specifying force-new-deployment for services using Rolling update deployment type. For example:\\n\\n$ aws ecs update-service -service service_name \\\n--cluster cluster_name -force-new-deployment\\n\\nFor services using Blue/Green deployment type with AWS CodeDeploy:\\nPlease refer to create-deployment document (2) and create new deployment using same task definition revision.\\n\\nFor further details on ECS deployment types, please refer to ECS Deployment Developer Guide (1).\\nFor further details on Fargate's update process, please refer to the AWS Fargate User Guide (3).\\nIf you have any questions or concerns, please contact AWS Support (4).\\n\\n(1) https://docs.aws.amazon.com/AmazonECS/latest/developerguide/deployment-types.html\\n(2) https://docs.aws.amazon.com/cli/latest/reference/deploy/create-deployment.html\\n(3) https://docs.aws.amazon.com/AmazonECS/latest/userguide/task-maintenance.html\\n(4) https://aws.amazon.com/support\\n\\nA list of your affected resources(s) can be found in the 'Affected resources' tab in the 'Cluster/ Service' format in the AWS Health Dashboard. \\n\\n" } ], "affectedEntities": [ { "entityValue": "cluster/service" }, { "entityValue": "cluster/service" } ] } }
  • Email(电子邮件)

    将向注册的电子邮件发送一封电子邮件以获取Amazon Web Services 账户身份证。

任务停用等待时间

重要

如果有重要的安全更新,则Amazon会发送通知,然后立即停用这些任务。

您可以配置 Fargate 开始停用任务的时间。对于需要立即应用更新的工作负载,请选择立即设置 (0)。当您需要更多控制时,例如,当任务只能在特定时间段内停止时,请配置 7 天 (7) 或 14 天 (14) 选项。

我们建议您选择较短的等待时间,以便更快地获得较新的平台版本修订版。

通过运行put-account-setting-default或以 root 用户put-account-setting身份配置等待时间。使用fargateTaskRetirementWaitPeriod选项name和设置为以下值之一的value选项:

  • 0-Amazon 发送通知,并立即开始停用受影响的任务。

  • 7-Amazon 发送通知,等待 7 个日历日后才开始停用受影响的任务。

  • 14-Amazon 发送通知,等待 14 个日历日后才开始停用受影响的任务。

默认值为 14 天。

有关更多信息,请参阅亚马逊弹性容器服务 API 参考put-account-setting中的put-account-setting-default和。

有关更多信息,请参阅 Amazon Fargate任务退休等待时间