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

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

FSx for Windows File Server 卷

FSx for Windows File Server 提供完全托管的 Microsoft Windows 文件服务器,由 Windows 文件系统提供支持。使用 FSx for Windows File Server 和 ECS 时,您可以使用永久、分布式、共享的静态文件存储来配置 Windows 任务。有关更多信息,请参阅 Amazon FSx for Windows File Server 定义

注意

使用经 Amazon ECS 优化的 Windows Server 2016 的完整 AMI 的 EC2 实例不支持 FSx for Windows File Server ECS 任务卷。

在 Fargate 配置中,您不能在 Windows 容器中使用 FSx for Windows File Server 卷。

您可以使用 FSx for Windows File Server 来部署需要访问共享外部存储、高可用区域存储或高吞吐量存储的 Windows 工作负载。您可以将一个或多个 FSx for Windows File Server 文件系统卷挂载到 ECS Windows 实例上运行的 ECS 容器中。在单个 ECS 任务中,您可以在多个 ECS 容器之间共享 FSx for Windows File Server 文件系统卷的 FSX。

要使用 FSx for Windows File Server 和 ECS,在任务定义中包含 FFSx for Windows File Server 文件系统 ID 和相关信息。它们在以下示例任务定义 JSON 代码段中。在创建和运行任务定义之前,您需要执行以下操作。

  • 已加入到有效域的 ECS Windows EC2 实例。它可以由 Amazon Directory Service for Microsoft Active Directory、本地 Active Directory 或 Amazon EC2 上的自行托管的 Active Directory 托管。

  • Amazon Secrets Manager 密钥或 Systems Manager 参数,其中包含用于域加入 Active Directory 和附加 FSx for Windows File Server 文件系统的凭据。凭据值是您在创建 Active Directory 时输入的名称和密码凭据。

以下部分描述了如何开始使用 FSx for Windows File Server 和 Amazon ECS。

有关相关教程,请参阅 教程:将 FSx for Windows File Server 文件系统与 Amazon ECS 结合使用

FSx for Windows File Server 卷注意事项

使用 FSx for Windows File Server 卷时,请考虑以下事项:

  • 使用 Amazon ECS 的 FSx for Windows File Server 仅支持 Windows Amazon EC2 实例。不支持 Linux Amazon EC2 实例。

  • 使用 Amazon ECS 的 FSx for Windows File Server 不支持 Amazon Fargate。

  • 使用 Amazon ECS 的 FSx for Windows File Server 使用 awsvpc 网络模式需要版本 1.54.0 或更高版本的容器代理。

  • 可用于 Amazon ECS 任务的最大驱动器号数为 23。每个具有 FSx for Windows File Server 卷都将获得分配给它的驱动器号。

  • 默认情况下,任务资源清理时间为任务结束后的三个小时。即使没有任务使用它,由任务创建的文件映射仍将持续 3 小时。可以通过使用 Amazon ECS 环境变量来配置ECS_ENGINE_TASK_CLEANUP_WAIT_DURATION 原定设置清理时间。有关更多信息,请参阅Amazon ECS 容器代理配置

  • 任务通常仅在 FSx for Windows File Server 文件系统相同的 VPC 中运行。但是,如果 Amazon ECS 集群 VPC 与 FSx for Windows File Server 文件系统之间通过 VPC 对等连接建立了网络连接,则可以实现跨 VPC 的支持。

  • 通过配置 VPC 安全组,可以在网络级别控制对 FSx for Windows File Server 文件系统的访问。只有通过正确配置的 AD 安全组加入 AD 域的 EC2 实例上托管的任务才能访问 FSx for Windows File Server 文件共享。如果安全组配置错误,ECS 将导致任务启动失败,并显示以下错误消息:unable to mount file system fs-id。”

  • FSx for Windows File Server 集成 Amazon Identity and Access Management (IAM) 来控制您的 IAM 用户和组可以对 FSx for Windows File Server 资源执行的操作。通过客户端授权,客户可以定义 IAM 角色,这些角色允许或拒绝对 FSx for Windows File Server 文件系统的访问,可以选择要求只读访问,也可以选择允许或不允许客户端对文件系统的根访问。有关更多信息,请参阅 Amazon FSx Windows 用户指南中的安全性

在任务定义中指定 FSx for Windows File Server 文件系统

要为容器使用 FSx for Windows File Server 文件系统卷,请在任务定义中指定卷和挂载点配置。以下任务定义 JSON 代码段显示容器的 volumesmountPoints 对象的语法。

{ "containerDefinitions": [ { "entryPoint": [ "powershell", "-Command" ], "portMappings": [], "command": ["New-Item -Path C:\\fsx-windows-dir\\index.html -ItemType file -Value '<html> <head> <title>Amazon ECS Sample App</title> <style>body {margin-top: 40px; background-color: #333;} </style> </head><body> <div style=color:white;text-align:center> <h1>Amazon ECS Sample App</h1> <h2>It Works!</h2> <p>You are using Amazon FSx for Windows File Server file system for persistent container storage.</p>' -Force"], "cpu": 512, "memory": 256, "image": "mcr.microsoft.com/windows/servercore/iis:windowsservercore-ltsc2019", "essential": false, "name": "container1", "mountPoints": [ { "sourceVolume": "fsx-windows-dir", "containerPath": "C:\\fsx-windows-dir", "readOnly": false } ] }, { "entryPoint": [ "powershell", "-Command" ], "portMappings": [ { "hostPort": 443, "protocol": "tcp", "containerPort": 80 } ], "command": ["Remove-Item -Recurse C:\\inetpub\\wwwroot\\* -Force; Start-Sleep -Seconds 120; Move-Item -Path C:\\fsx-windows-dir\\index.html -Destination C:\\inetpub\\wwwroot\\index.html -Force; C:\\ServiceMonitor.exe w3svc"], "mountPoints": [ { "sourceVolume": "fsx-windows-dir", "containerPath": "C:\\fsx-windows-dir", "readOnly": false } ], "cpu": 512, "memory": 256, "image": "mcr.microsoft.com/windows/servercore/iis:windowsservercore-ltsc2019", "essential": true, "name": "container2" } ], "family": "fsx-windows", "executionRoleArn": "arn:aws:iam::111122223333:role/ecsTaskExecutionRole", "volumes": [ { "name": "fsx-windows-dir", "fsxWindowsFileServerVolumeConfiguration": { "fileSystemId": "fs-0eeb5730b2EXAMPLE", "authorizationConfig": { "domain": "example.com", "credentialsParameter": "arn:arn-1234" }, "rootDirectory": "share" } } ] }
FSxWindowsFileServerVolumeConfiguration

类型:对象

必需:否

当您使用 FSx for Windows File Server 文件系统进行任务存储时,指定此参数。

fileSystemId

类型:字符串

必需:是

要使用的 FSx for Windows File Server 文件系统 ID。

rootDirectory

类型:字符串

必需:是

FSx for Windows File Server 文件系统中要作为主机内的根目录挂载的目录。

authorizationConfig
credentialsParameter

类型:字符串

必需:是

授权凭据选项:

domain

类型:字符串

必需:是

Amazon Directory Service 托管 Microsoft AD(Active Directory)或自托管 EC2 AD 托管的完全限定域名。

凭据存储方法

存储凭据的凭据有两种不同的方法,以便与凭据参数一起使用。

  • Amazon Secrets Manager 密钥

    此凭据可以在 Amazon Secrets Manager 控制台中使用其他密钥类型类别。您可以为每个键/值对、用户名/管理员和密码/password 添加一行。

  • Systems Manager 参数

    通过以下示例代码片段中的形式输入文本,可以在 Systems Manager 参数控制台中创建此凭证。

    { "username": "admin", "password": "password" }

任务定义 FSxWindowsFileServerVolumeConfiguration 参数中的 credentialsParameter 将保存密钥 ARN 或 Systems Manager 参数 ARN。有关更多信息,请参阅 Secrets Manager用户指南中的什么是 Amazon Secrets Manager以及 Systems Manager 用户指南中的 Systems Manager 参数存储