限制:最大任务数限制 Fargate 任务数的最大值受到 AWS 账号和各个 AWS 区域的限制。Fargate 容器能够使用的 CPU 和内存资源量是被限制的,因此您应该评估您所需的容器数量和资源消耗,以决定是否需要增加该限制。如果您需要创建更多任务,则需要提交 AWS 增加配额的申请。申请提交后,您将收到一个配额增加请求的审批结果,可以根据您的要求来调整 Fargate 容器的数量。
限制:自定义 VPC 的局限性 在 Fargate Cluster 中,如果您需要使用自定义 VPC,您必须自行管理和部署容器需要的网络设备 (如 NAT 网关、Internet 网关、DNS 解析器等)。 另外,Fargate 还有一些限制,例如每个容器只能占用单个 IP 地址,且受 VPC 的 IP 地址范围和 Subnet 大小的限制。
代码示例:
以下是如何使用 CloudFormation 模板中,创建自定义 VPC:
AWSTemplateFormatVersion: 2010-09-09
Resources:
MyVPC:
Type: "AWS::EC2::VPC"
Properties:
CidrBlock: "10.0.0.0/16"
EnableDnsSupport: true
EnableDnsHostnames: true
Tags:
- Key: Name
Value: "MyVPC"
MyPublicSubnet:
Type: "AWS::EC2::Subnet"
Properties:
VpcId: !Ref MyVPC
CidrBlock: "10.0.1.0/24"
AvailabilityZone: us-east-1a
Tags:
- Key: Name
Value: "MyPublicSubnet"
InternetGateway:
Type: "AWS::EC2::InternetGateway"
Properties:
Tags:
- Key: Name
Value: "My Internet Gateway"
GatewayAttachment:
Type: "AWS::EC2::VPCGatewayAttachment"
Properties:
VpcId: !Ref MyVPC
InternetGatewayId: !Ref InternetGateway
PublicRouteTable:
Type: "AWS::EC2::RouteTable"
Properties:
VpcId: !Ref MyVPC
Tags:
- Key: Name
Value: "MyPublicRouteTable"
PublicRoute:
Type: "AWS::EC2::Route"
DependsOn: GatewayAttachment
Properties:
DestinationCidrBlock: "0.0.0.0/0"
RouteTableId: !Ref PublicRouteTable
GatewayId: !Ref InternetGateway