本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
AWS Outposts 在內部部署設施中啟用原生 AWS 服務、基礎設施和操作模型。在 AWS Outposts 環境中,您可以使用您在 中使用的相同 AWS APIs、工具和基礎設施 AWS 雲端。
上的 Amazon ECS AWS Outposts 非常適合需要在靠近內部部署資料和應用程式的情況下執行的低延遲工作負載。
如需 的詳細資訊 AWS Outposts,請參閱AWS Outposts 《 使用者指南》。
考量事項
以下是在 上使用 Amazon ECS 的考量 AWS Outposts:
-
Amazon Elastic Container Registry AWS Identity and Access Management和 Network Load Balancer 會在 AWS 區域中執行,而不是在區域中執行 AWS Outposts。這將提高這些服務和容器之間的延遲。
-
AWS Fargate 無法使用 AWS Outposts。
以下是 的網路連線考量 AWS Outposts:
-
如果 AWS Outposts 與其 AWS 區域之間的網路連線中斷,您的叢集將繼續執行。不過,在連線恢復之前,您將無法建立新叢集或對現有叢集採取新動作。在執行個體失敗的情況下,執行個體將不會被自動替換。CloudWatch Logs 代理程式將無法更新記錄檔和事件資料。
-
我們建議您在 AWS Outposts 及其 AWS 區域之間提供可靠、高可用性和低延遲的連線。
先決條件
以下是在 上使用 Amazon ECS 的先決條件 AWS Outposts:
-
內部部署資料中心必須已安裝和設定 Outpost。
-
Outpost 與其 AWS 區域之間必須有可靠的網路連線。
在 上建立叢集的概觀 AWS Outposts
以下是組態的概觀:
-
建立具有 權限的角色和政策 AWS Outposts。
-
在 AWS Outposts上建立具有權限的 IAM 執行個體描述檔。
-
建立 VPC,或使用與 位於相同區域中的現有 VPC AWS Outposts。
-
建立子網路或使用與 相關聯的現有子網路 AWS Outposts。
這是容器執行個體執行所在的子網路。
-
為叢集中的容器執行個體建立安全群組。
-
建立 Amazon ECS 叢集
-
定義 Amazon ECS 容器代理程式環境變數,以在叢集中啟動執行個體。
-
執行容器。
如需如何將 Amazon ECS 與 整合的詳細資訊 AWS Outposts,請參閱將 Amazon ECS 延伸到兩個 AWS Outposts 機架
以下範例會在 AWS Outposts上建立 Amazon ECS 叢集。
-
建立具有 權限的角色和政策 AWS Outposts。
role-policy.json
檔案是政策文件,其中包含資源的效果和動作。如需檔案格式的資訊,請參閱《IAM API 參考》中的 PutRolePolicyaws iam create-role –-role-name
ecsRole
\ --assume-role-policy-document file://ecs-policy.json aws iam put-role-policy --role-nameecsRole
--policy-nameecsRolePolicy
\ --policy-document file://role-policy.json -
在 AWS Outposts上建立具有權限的 IAM 執行個體描述檔。
aws iam create-instance-profile --instance-profile-name
outpost
aws iam add-role-to-instance-profile --instance-profile-nameoutpost
\ --role-nameecsRole
-
建立 VPC。
aws ec2 create-vpc --cidr-block
10.0.0.0/16
-
建立與您的 相關聯的子網路 AWS Outposts。
aws ec2 create-subnet \ --cidr-block
10.0.3.0/24
\ --vpc-idvpc-xxxxxxxx
\ --outpost-arn arn:aws:outposts:us-west-2
:123456789012:outpost/op-xxxxxxxxxxxxxxxx
\ --availability-zone-idusw2-az1
-
為容器執行個體建立安全群組,指定 AWS Outposts適當的 CIDR 範圍。(此步驟與 不同 AWS Outposts。)
aws ec2 create-security-group --group-name
MyOutpostSG
aws ec2 authorize-security-group-ingress --group-nameMyOutpostSG
--protocol tcp \ --port 22 --cidr10.0.3.0/24
aws ec2 authorize-security-group-ingress --group-nameMyOutpostSG
--protocol tcp \ --port 80 --cidr10.0.3.0/24
-
建立叢集。
-
定義 Amazon ECS 容器代理程式環境變數,將執行個體啟動至上一個步驟中建立的叢集,並定義任何您要新增的標籤,以幫助識別該叢集 (例如
Outpost
可指示叢集的用途是用於 Outpost)。#! /bin/bash cat << ‘EOF’ >> /etc/ecs/ecs.config ECS_CLUSTER=MyCluster ECS_IMAGE_PULL_BEHAVIOR=prefer-cached ECS_CONTAINER_INSTANCE_TAGS={“environment”: ”Outpost”} EOF
注意
為了避免從區域 Amazon ECR 拉提取容器映像造成的延遲,請使用映像快取。若要進行此操作,請在每次執行工作時將
ECS_IMAGE_PULL_BEHAVIOR
設為prefer-cached
,以便將 Amazon ECS 代理程式設定為預設,在執行個體本身上使用快取的映像。 -
建立容器執行個體,指定 AWS Outposts 應執行此執行個體的 VPC 和子網路,以及 AWS Outposts上可用的執行個體類型。(此步驟與 不同 AWS Outposts。)
userdata.txt
檔案中包含使用者資料,執行個體可以使用這些使用者資料來執行常見的自動化組態任務,甚至在執行個體啟動之後執行指令碼。如需有關 API 呼叫檔案的資訊,請參閱《Amazon EC2 使用者指南》中的在啟動時在 Linux 執行個體上執行命令。aws ec2 run-instances --count 1 --image-id
ami-xxxxxxxx
--instance-typec5.large
\ --key-nameaws-outpost-key
–-subnet-idsubnet-xxxxxxxxxxxxxxxxx
\ --iam-instance-profile Nameoutpost
--security-group-idsg-xxxxxx
\ --associate-public-ip-address --user-datafile://userdata.txt
注意
將其他執行個體新增至叢集時,也會使用此指令。在叢集中部署的任何容器都會放置在該特定 AWS Outposts上。