[AWS] ECS - Fargate mode
基础知识
实践笔记
Ref: AWS教學 - ECS介紹 Fargate mode 實作演練 [step by step]
Container
Get started --> 选择 custom configure
ECR 上传 docker image 后,填写:container name, docker image
Task
Task memory
Task CPU
Server
开几个 tasks。
Cluster
暂时只设置个 cluster name。
-
若干特点
Fargate mode下看不到ECS Instances的内容。因为都“傻瓜化”,隐藏掉了。
-
与Lambda的区别
Ref: AWS Lambda v Amazon ECS – two paths to one goal, which is best?
- What is Amazon ECS?
- AWS Lambda v Amazon ECS
[Fargate] is billed on CPU and memory used per hour. The current pricing is found here.
[Lambda] is billed on a combination of the number of requests, memory, and seconds of function execution. The current pricing is found here.
内部对比 - 两种模式
Amazon ECS 具有两种模式:Fargate 启动类型和 EC2 启动类型。如果使用 Fargate 启动类型,您只需将应用程序打包到容器中,指定 CPU 和内存需求,选择awsvpc网络模型和 IAM 策略,然后直接启动应用程序。如果使用EC2 启动类型,您可以对运行容器应用程序的基础设施进行更精细的服务器级控制。
一、EC2 mode
Ref: AWS教學 - ECS介紹 (EC2 mode & Fargate mode
二、Fargata mode
傻瓜化,fargate部分屏蔽掉users。让用户更多的去关注Service,而非调度。
多个task,具备了并行处理更多的msg的能力。
外部对比 - 三种服务
Ref: AWS ECS vs EKS vs Fargate
[ Fargate 的 特点 ]
Serverless version of Container - Fargate
No need to create a cluster or determine EC2 size, Fargate scales on-demand
Pay for what you use.
No control plane.
实践出真知
资源
Ref: AWS Fargate – 无服务器化容器解决方案 【能完整地操作一遍就好了】
Fargate天生与Amazon VPC、自动扩展(Auto Scaling)、弹性负载均衡(ELB)、身份及访问管理(IAM)角色和密钥管理集成起来。
本篇关注:一到七部分,构建ECS。
“八、基于容器的持续集成/持续部署方案” --> [AWS] 07 - CI/CD by CodePipelines
实践思考
一、ECR --> ECS
Lambda 触发 ECS的 Task示范。
# Triggering the ECS Fargate Job response = client.run_task( cluster='detect-money', # name of the cluster launchType = 'FARGATE', taskDefinition='Image-Mask:10', # replace with your task definition name and revision count = 1, platformVersion='LATEST', networkConfiguration={ 'awsvpcConfiguration': { 'subnets': [ 'subnet-37b06888', # replace with your public subnet or a private with NAT 'subnet-37b06888' # Second is optional, but good idea to have two ], 'assignPublicIp': 'ENABLED' } }, overrides={ 'containerOverrides': [ { 'name': 'jeff-fargate', 'environment': [ { 'name': 'job_id', 'value': job_id }, { 'name': 'output', 'value': output } ] }, ] })
-
查看 "repositoryArn"
例如:"arn:aws:ecr:us-east-1:xxxxxxxxxxxxx:repository/workshop"
$ aws ecr describe-repositories
End.