aws-ecs-fargate
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAWS ECS & Fargate
AWS ECS & Fargate
Run containerized applications on Amazon ECS with Fargate.
在Amazon ECS上借助Fargate运行容器化应用。
Task Definition
Task Definition
json
{
"family": "myapp",
"networkMode": "awsvpc",
"requiresCompatibilities": ["FARGATE"],
"cpu": "256",
"memory": "512",
"executionRoleArn": "arn:aws:iam::xxx:role/ecsTaskExecutionRole",
"containerDefinitions": [{
"name": "myapp",
"image": "xxx.dkr.ecr.region.amazonaws.com/myapp:latest",
"portMappings": [{
"containerPort": 8080,
"protocol": "tcp"
}],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "/ecs/myapp",
"awslogs-region": "us-east-1",
"awslogs-stream-prefix": "ecs"
}
}
}]
}json
{
"family": "myapp",
"networkMode": "awsvpc",
"requiresCompatibilities": ["FARGATE"],
"cpu": "256",
"memory": "512",
"executionRoleArn": "arn:aws:iam::xxx:role/ecsTaskExecutionRole",
"containerDefinitions": [{
"name": "myapp",
"image": "xxx.dkr.ecr.region.amazonaws.com/myapp:latest",
"portMappings": [{
"containerPort": 8080,
"protocol": "tcp"
}],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "/ecs/myapp",
"awslogs-region": "us-east-1",
"awslogs-stream-prefix": "ecs"
}
}
}]
}Create Service
Create Service
bash
aws ecs create-service \
--cluster my-cluster \
--service-name myapp \
--task-definition myapp:1 \
--desired-count 2 \
--launch-type FARGATE \
--network-configuration '{
"awsvpcConfiguration": {
"subnets": ["subnet-xxx"],
"securityGroups": ["sg-xxx"],
"assignPublicIp": "ENABLED"
}
}' \
--load-balancers '[{
"targetGroupArn": "arn:aws:elasticloadbalancing:...",
"containerName": "myapp",
"containerPort": 8080
}]'bash
aws ecs create-service \
--cluster my-cluster \
--service-name myapp \
--task-definition myapp:1 \
--desired-count 2 \
--launch-type FARGATE \
--network-configuration '{
"awsvpcConfiguration": {
"subnets": ["subnet-xxx"],
"securityGroups": ["sg-xxx"],
"assignPublicIp": "ENABLED"
}
}' \
--load-balancers '[{
"targetGroupArn": "arn:aws:elasticloadbalancing:...",
"containerName": "myapp",
"containerPort": 8080
}]'Deployment
Deployment
bash
undefinedbash
undefinedUpdate service
Update service
aws ecs update-service
--cluster my-cluster
--service myapp
--task-definition myapp:2
--force-new-deployment
--cluster my-cluster
--service myapp
--task-definition myapp:2
--force-new-deployment
undefinedaws ecs update-service
--cluster my-cluster
--service myapp
--task-definition myapp:2
--force-new-deployment
--cluster my-cluster
--service myapp
--task-definition myapp:2
--force-new-deployment
undefinedBest Practices
最佳实践
- Use ECR for images
- Implement service discovery
- Configure health checks
- Use secrets manager for secrets
- Enable container insights
- 使用ECR存储镜像
- 实现服务发现
- 配置健康检查
- 使用Secrets Manager管理密钥
- 启用容器洞察
Related Skills
相关技能
- docker-management - Container basics
- container-registries - ECR
- docker-management - 容器基础知识
- container-registries - ECR