实验目的,熟悉AWS Elastic Container Service
实验包括:
1. 创建和定义ECS的任务(Task)
2. 创建ECS Cluster
3. 部署应P T W Y z e用到ECS Service中
实验前准备:
Task1:使用ecs-sam[ P y Z b r Rple image注册和定义Task
进入到ECS服务,创建Task Definitions:
{
"family": "myContainer",
"containerDefinitions": [
{
"volumesFrom": [],
"p+ l U 6ortMappings": [
{
"hostPortk F x } 2 W L 3": 80,
"containerPort": 80
}
],
"command": null,
"environment": [],
l 8 ^"essential": true,
"entryPoint": null,
"links": [],
"mountPoints": [
{
"containerPath": "/usr/local/aE d x d } ; ^pache2/htdocs",
"sourceVolume": X 8 E"my-vol",
"readO, J q 9nly": null
}
],
"memory": 300,
"name": "simple-a! r y X J , 2pp",
"cpu": 10,
"image": "httpd:2.4"
},
{
"volumesFrom": [
{
"readOnly": null,
"sourceContainer": "simple-app"
}
],
"portMappings": [],
"command": [
"/bin/shy E A G K e o -c "while true; do echo '<html> <head> <title>AmO m ^ z * *azon ECS Sample App</title> <style>I ! U G;body! / r ( W ? o {margin-top: 40px; background-color: #33 g o ] c F3;B O e 8 w b [ V} </style> </head><body> <div style=color:white;text-align:center&gb m w A -t; <h1>Amazon ECS Sample App</h1> <u h . F m _ k ^ (h2>Congraq O (tulations!</h2> <p>Your application is now running on a container in Ama~ N Q # +zonE ^ Q 9 y T X _ m ECS.</p>'I j W 8 ( C I > top; /bi2 z $ T kn/date > date ; echo q } B q # W B'</div>&l# 5 ` N l S Wt;/t a k L 6body>3 J v e 7 L;</html&gy T B s +t;' > bottom; cat top date b? I l [ Rottom > /w x Rusr/loca1 N U Rl/apache2/htdocs/index.html ; sleep 1; done""
],
"environment": [],
"essential": false,
"entryPoint": [
"shp ] V )",
"-cc 1 r E ="
],
"links"p H : 4: [],
"mountPoints": [],
"memory": 200,
"name": "busybox",
"cpu":K + F 10,
"image": "busybox"
}
],
"volumes": [
{
"host": {
"sourcePath": null
},
"name": "my-vol"
}
]
}
导入之后,回头看Task Definition Name为:myCs h p ? jontainer。然后T? ) 8 ? pask si$ E : #ze等信息也定义好了。
创建完成后:
Task 2:Create a Service
网络配置:
添加容器的load balance
服务发现:
设置A+ / 5 a T nuto Scaling:
Task3:部署新的application版本到ECS上。
直接替换前端网站H标签t G @,C _ u把congratulation改成 thank you.
然后回到ECSCluster的SerJ ; d % w I ~ o Rvices,选择myService并up# ; G [date(Version:选择select the latest)重复Task2,找到Load Balancer的URL.
复制DNS,copy到网址。就会看到更新的内容了。
发表评论