Amazon 彈性容器服務 AWS Outposts - Amazon Elastic Container Service

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

Amazon 彈性容器服務 AWS Outposts

AWS Outposts 允許內部部署設施中的原生 AWS 服務、基礎架構和作業模式。在 AWS Outposts 環境中,您可以使用在 AWS 雲端中使用的相同 AWS API、工具和基礎結構。Amazon ECS on 非 AWS Outposts 常適合需要在鄰近現場部署資料和應用程式執行的低延遲工作負載。若要取得有關的更多資訊 AWS Outposts,請參閱AWS Outposts 使用者指南

必要條件

下列是在 AWS Outposts上使用 Amazon ECS 的先決條件:

  • 您必須已 AWS Outposts 在內部部署資料中心中安裝並設定。

  • 您必須在您 AWS Outposts 與其 AWS 地區之間建立可靠的網路連線。

  • 您的 AWS Outposts中必須有足夠的可用執行個體類型容量。

  • 所有 Amazon ECS 容器執行個體都必須具有 Amazon ECS 容器代理程式 1.33.0 或更新版本。

限制

以下是在 AWS Outposts上使用 Amazon ECS 的限制:

  • Amazon 彈性容器登錄檔和 Network Load Balancer 在該 AWS 區域中執行,而不是在上執行 AWS Outposts。 AWS Identity and Access Management這將提高這些服務和容器之間的延遲。

  • AWS Fargate 不適用於 AWS Outposts。

網路連線能力考量

以下是用於的網路連線考量 AWS Outposts:

  • 如果您 AWS Outposts 與其 AWS 區域之間的網路連線中斷,您的叢集將繼續執行。不過,在連線恢復之前,您將無法建立新叢集或對現有叢集採取新動作。在執行個體失敗的情況下,執行個體將不會被自動替換。記 CloudWatch 錄檔代理程式將無法更新記錄檔和事件資料。

  • 我們建議您在您與其 AWS 區域之間提供可靠、高可用性 AWS Outposts 和低延遲的連線能力。

在一個上創建一個 Amazon ECS 集群 AWS Outposts

在雲端上建立 Amazon ECS 叢集類似 AWS Outposts 於在雲端中建立 Amazon ECS 叢集。 AWS 在上建立 Amazon ECS 叢集時 AWS Outposts,必須指定 AWS Outposts與.

A AWS Outposts 是 AWS 區域的延伸,您可以在帳戶中擴充 Amazon VPC 以跨越多個可用區域和任何相關聯 AWS Outposts的區域。設定子網路時 AWS Outposts,您可以將子網路與子網路建立關聯,以便將區域 VPC 環境延伸至內部部署設施。上的執行個體 AWS Outposts 會顯示為區域 VPC 的一部分,類似於具有關聯子網路的可用區域。


                顯示連接到區域 AWS 資源的前哨 AWS Outposts 網絡的圖表。

AWS CLI

若要在上建立 Amazon ECS 叢集 AWS CLI,請指定要 AWS Outposts 與您 AWS Outposts的產生關聯的安全群組和子網路。

若要建立與您關聯的子網路 AWS Outposts。

aws ec2 create-subnet \ --cidr-block 10.0.3.0/24 \ --vpc-id vpc-xxxxxxxx \ --outpost-arn arn:aws:outposts:us-west-2:123456789012:outpost/op-xxxxxxxxxxxxxxxx \ --availability-zone-id usw2-az1

以下範例會在 AWS Outposts上建立 Amazon ECS 叢集。

  1. 建立具有上權限的角色和策略 AWS Outposts。

    role-policy.json 檔案是政策文件,其中包含資源的效果和動作。如需檔案格式的相關資訊,請參閱 IAM API 參考資料PutRolePolicy中的〈〉。

    aws iam create-role –-role-name ecsRole \ --assume-role-policy-document file://ecs-policy.json aws iam put-role-policy --role-name ecsRole --policy-name ecsRolePolicy \ --policy-document file://role-policy.json
  2. 在 AWS Outposts上建立具有權限的 IAM 執行個體描述檔。

    aws iam create-instance-profile --instance-profile-name outpost aws iam add-role-to-instance-profile --instance-profile-name outpost \ --role-name ecsRole
  3. 建立 VPC。

    aws ec2 create-vpc --cidr-block 10.0.0.0/16
  4. 為容器執行個體建立安全群組,指定 AWS Outposts適當的 CIDR 範圍。(此步驟是不同的 AWS Outposts。)

    aws ec2 create-security-group --group-name MyOutpostSG aws ec2 authorize-security-group-ingress --group-name MyOutpostSG --protocol tcp \ --port 22 --cidr 10.0.3.0/24 aws ec2 authorize-security-group-ingress --group-name MyOutpostSG --protocol tcp \ --port 80 --cidr 10.0.3.0/24
  5. 建立叢集。

  6. 定義 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 代理程式設定為預設,在執行個體本身上使用快取的映像。

  7. 建立容器執行個體,指定 AWS Outposts 應執行此執行個體的 VPC 和子網路,以及 AWS Outposts上可用的執行個體類型。(此步驟是不同的 AWS Outposts。)

    userdata.txt 檔案中包含使用者資料,執行個體可以使用這些使用者資料來執行常見的自動化組態任務,甚至在執行個體啟動之後執行指令碼。如需有關 API 呼叫檔案的資訊,請參閱《Amazon EC2 Linux 執行個體使用者指南》中的啟動時在 Linux 執行個體上執行命令

    aws ec2 run-instances --count 1 --image-id ami-xxxxxxxx --instance-type c5.large \ --key-name aws-outpost-key –-subnet-id subnet-xxxxxxxxxxxxxxxxx \ --iam-instance-profile Name outpost --security-group-id sg-xxxxxx \ --associate-public-ip-address --user-data file://userdata.txt
    注意

    將其他執行個體新增至叢集時,也會使用此指令。在叢集中部署的任何容器都會放置在該特定 AWS Outposts上。

  8. 註冊您的任務定義。使用下列命令並將 ecs-task.json 替換為任務定義的名稱。

    aws ecs register-task-definition --cli-input-json file://ecs-task.json
  9. 執行工作或建立服務。

    Run the task
    aws ecs run-task --cluster mycluster --count 1 --task-definition outpost-app:1
    Create the service
    aws ecs create-service –-cluster mycluster --service-name outpost-service \ --task-definition outpost-app:1 --desired-count 1