AWS Elastic Container Service - 在多個可用區中執行服務

AWS Elastic Container Service - 在多個可用區中執行服務

我正在透過 ECS 運行長時間運行的任務。容器執行個體分佈在多個可用區。是否可以在 ECS 中定義,當一個任務的實例超過 1 個時,每個任務應該在另一個可用區上執行(如果可能)?此功能對於高可用性和容錯能力來說非常有用。現在,一個任務的所有 5 個實例可能都在同一台機器上運行,因此當機器死機時,調度程序需要將所有任務放置在其他地方,這將導致服務停機。

希望你能幫助我。

答案1

今天宣布了 AZ 感知調度,所以現在這個問題已經解決了

亞馬遜部落格文章

答案2

我面臨同樣的問題。

目前,我正在將自己的 AMI 與 docker 和 awscli 一起使用。我使用 ec2_Data 注入 init 腳本。此腳本啟動 dockersn 應用 crontabs(用於 cloudwatch 指標和備份)並初始化警報。

我不想使用私人註冊表或 dockerhub,我正在從 S3 加載 docker 映像

s3curl --id clouddocker -- -s --retry 5 --retry-delay 30 URL.gz | gunzip|docker load

答案3

使用 ecs-cli,您可以定義子網路。

>ecs-cli up --help
NAME:
   up - Create the ECS Cluster (if it does not already exist) and the AWS resources required to set up the cluster.

USAGE:
   command up [command options] [arguments...]

OPTIONS:
   --keypair        Specify the name of an existing Amazon EC2 key pair to enable SSH access to the EC2 instances in your cluster.
   --capability-iam Acknowledge that this command may create IAM resources.
   --size       [Optional] Specify the number of instances to register to the cluster. The default is 1.
   --azs        [Optional] Specify a comma-separated list of 2 VPC availability zones in which to create subnets (these AZs must be in the 'available' status). This option is recommended if you do not specify a VPC ID with the --vpc option. WARNING: Leaving this option blank can result in failure to launch container instances if an unavailable AZ is chosen at random.
   --security-group     [Optional] Specify an existing security group to associate it with container instances. Defaults to creating a new one.
   --cidr       [Optional] Specify a CIDR/IP range for the security group to use for container instances in your cluster. Defaults to 0.0.0.0/0 if --security-group is not specified
   --port       [Optional] Specify a port to open on a new security group that is created for your container instances if an existing security group is not specified with the --security-group option. Defaults to port 80.
   --subnets        [Optional] Specify a comma-separated list of existing VPC Subnet IDs in which to launch your container instances. This option is required if you specify a VPC with the --vpc option.
   --vpc        [Optional] Specify the ID of an existing VPC in which to launch your container instances. If you specify a VPC ID, you must specify a list of existing subnets in that VPC with the --subnets option. If you do not specify a VPC ID, a new VPC is created with two subnets.
   --instance-type  [Optional] Specify the EC2 instance type for your container instances.

相關內容