Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use AWS CLI to create ECS Cluster in AWS

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

How to use AWS CLI to create ECS clusters in AWS, many novices are not very clear about this, in order to help you solve this problem, the following small series will explain in detail for everyone, there are people who need this can learn, I hope you can gain something.

creating a cluster

aws ecs create-cluster --cluster-name Cluster name

Output:

{ "cluster": { "status": "ACTIVE", "statistics": [], "clusterName": "fargate-cluster", "registeredContainerInstancesCount": 0, "pendingTasksCount": 0, "runningTasksCount": 0, "activeServicesCount": 0, "clusterArn": "arn:aws:ecs:region:aws_account_id:cluster/fargate-cluster" } }

Register Task Definition

Task definitions must be registered before they can run on ECS clusters. Here is an example file for registering a task definition with a fargate launch type:

{

"family": "sample-fargate",

"taskRoleArn": "ecs TaskExecutionRole",

"executionRoleArn": "ecs TaskExecutionRole",

"networkMode": "awsvpc",

"containerDefinitions": [

{

"name": "test_nginxweb",

"cpu": 256,

"memory": 512,

"image": "023663056036.dkr.ecr.ap-northeast-1.amazonaws.com/test-qulp:nginx_web0.0",

"portMappings": [

{

"containerPort": 80,

"hostPort": 80,

"protocol": "tcp"

}

],

"essential": true

}

],

"requiresCompatibilities": [

"FARGATE"

],

"cpu": "256",

"memory": "512"

}

The following are the supported ranges of fargate types:

The following is the supported range of EC2 types:

The supported values are between 128 CPU units (0.125 vCPUs) and 10240 CPU units (10 vCPUs).

There are two ways to pass JSON files to the AWS CLI.

First: Save the task definition JSON as a file and pass it with options

aws ecs register-task-definition --cli-input-json file://Location of JSON file

The second is to pass JSON strings directly in quotes on the AWS CLI command line.

Return after registration of task definition:

List task definitions

aws ecs list-task-definitions

create a service

aws ecs create-service --clusterName--service-name ServiceName--task-definition Task definition:1 --desired-count--launch-type "FARGATE" --network-configuration "awsvpcConfiguration={subnets=[subnet-abcd1234],securityGroups=[sg-abcd 1234],assignPublicIp=ENABLED}"

Subnets and security groups are created before you start.

List the services in the cluster

aws ecs list-services --cluster cluster name

Describe the running service

aws ecs describe-services --clustername--servicesname

Did reading the above help you? If you still want to have further understanding of related knowledge or read more related articles, please pay attention to the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report