Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
containers-on-aws
Search
ryo nakamaru
September 08, 2016
Technology
7
1.7k
containers-on-aws
Microservices Meetup vol.3 で発表した「AWS loves Docker」の資料です。
ryo nakamaru
September 08, 2016
Tweet
Share
More Decks by ryo nakamaru
See All by ryo nakamaru
AWSで楽をするサービスメッシュ入門/appmesh-trial
pottava
1
1.3k
reinforce-2019-recap-lt
pottava
2
4.1k
ScaleShift-jp-2019-summer
pottava
1
190
Firecracker とは何か/what is Firecracker
pottava
13
5.3k
ハイブリッド並列 on Kubernetes/hybrid-parallel-program-on-kubernetes
pottava
1
400
AWS Fargate + Code 兄弟で始める継続的デリバリー / Continuous Delivery with AWS Fargate and Code brothers
pottava
12
3.1k
Singularity と NVIDIA GPU Cloud で作る ハイブリッド機械学習環境の構築 / Building a hybrid environment for Machine Learning with Singularity and NGC
pottava
3
1.2k
明日から始めるちょい足し λ / get-started-with-aws-lambda
pottava
4
2.4k
NGC と Singularity によるハイブリッド機械学習環境 / A hybrid environment for Machine Learning with NGC and Singularity
pottava
0
460
Other Decks in Technology
See All in Technology
[FOSS4G 2024 Japan LT] LLMを使ってGISデータ解析を自動化したい!
nssv
1
190
形式手法の 10 メートル手前 #kernelvm / Kernel VM Study Hokuriku Part 7
ytaka23
5
840
OCI Network Firewall 概要
oracle4engineer
PRO
0
4.1k
いざ、BSC討伐の旅
nikinusu
2
750
社内で最大の技術的負債のリファクタリングに取り組んだお話し
kidooonn
1
520
인디 앱 개발자와 Flutter
tinyjin
0
160
【若手エンジニア応援LT会】ソフトウェアを学んできた私がインフラエンジニアを目指した理由
kazushi_ohata
0
130
私はこうやってマインドマップでテストすることを出す!
mineo_matsuya
0
340
OCI Vault 概要
oracle4engineer
PRO
0
9.7k
AWS Lambdaと歩んだ“サーバーレス”と今後 #lambda_10years
yoshidashingo
1
150
スクラムチームを立ち上げる〜チーム開発で得られたもの・得られなかったもの〜
ohnoeight
2
340
Python(PYNQ)がテーマのAMD主催のFPGAコンテストに参加してきた
iotengineer22
0
340
Featured
See All Featured
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
246
1.3M
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
Designing Experiences People Love
moore
138
23k
Ruby is Unlike a Banana
tanoku
96
11k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
93
16k
Measuring & Analyzing Core Web Vitals
bluesmoon
3
90
Building Applications with DynamoDB
mza
90
6.1k
A designer walks into a library…
pauljervisheath
202
24k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.8k
Designing on Purpose - Digital PM Summit 2013
jponch
115
7k
The Cult of Friendly URLs
andyhume
78
6k
Transcript
AWS Docker Microservices Meetup vol.3 2016/09/08
@pottava SUPINF Inc. Docker Administration and Operations (AWS Certified) SA,
DevOps Engineer Pro 2
ޮՌతͳಋೖɾӡ༻ͷͨΊͷ Amazon Web Services ׆༻ೖ 2016/08/01 ίϯςφؔ࿈αʔϏεͰ͋Δ ECSɺECR ͦͷଞ CloudFrontɺACMɺAPI
Gateway IAMɺAWS WAFɺCloudFormation ॻ͖·ͨ͠ɻ 3
http://jawsug-container.connpass.com/ ECS Λத৺ʹɺAWS Ͱͷίϯςφӡ༻Λߟ͍͑ͯ·͢ 4
http://jawsug-ai.connpass.com/ AI ϚΠΫϩαʔϏεͱͯ͠औΓࠐΜ͡Ό͍·͠ΐ͏ʂ 5
גࣜձࣾεϐϯϑ ΞΠσΟΞΛ͔ͨͪʹʂ + 6
https://www.supinf.co.jp/service/dockersupport/ Comfy for Docker ϓϩδΣΫτͷ Docker ಋೖɾ։ൃࢧԉɾӡ༻ࢹߦΛ͍ͨ͠·͢ɻ ʢGCP / Azure
ͪΖΜରԠ͍ͯ͠·͢ɾɾʣ http://prtimes.jp/main/html/rd/p/000000007.000007768.html 7
Ͱ 8
ɹAWS (Docker) Containers 9
͓͍͑ͨ͜͠ͱ 1. AWS ʹίϯςφࢧԉػೳͨ͘͞Μ͋ΔΑ 2. Γ͍ͨ͜ͱʹԠ͍ͯ͡ΖΜͳߏ͋Γ·͢ 10
͓͢͠Δ͜ͱ 1. AWS ͷίϯςφؔ࿈αʔϏε֓ཁ 2. جຊతͳߏɾߋ৽ྫ 2.1. ECSɻ 2.2. ElasticBeanstalkɻ
2.3. CodeDeployɻ 3. AWS ͷϚΠΫϩαʔϏεࢧԉαʔϏε 4. ϑΣʔζผͷߏྫɾࣄྫ 4.1. ։ൃڥ 4.2. ධՁڥ 4.3. ຊ൪ڥ 11
1. AWS ͷίϯςφؔ࿈αʔϏε֓ཁ 12
EC2 Amazon Elastic Compute CloudɻԾαʔόɻ [ Ϣʔεέʔε ] • Docker
ͷ swarm Ϟʔυ Kubernetes Λ͍͍ͨ • Docker ϨδετϦΛࣗલͰӡ༻͍ͨ͠ • อकʢʁʣओʹ SSH ͷओઓɻ [ ಛ ] • Ϋϥελཧπʔϧɺαʔόىಈ↑ӡ༻ෛՙ↑ • ͱ͍͑ɺͳΜͰͰ͖Δ. 13
ECS EC2 Container Serviceɻίϯςφཧɻ [ Ϣʔεέʔε ] • λεΫ͝ͱͷదͳݖݶઃఆ +
εέʔϧ AWS ʹ͍ͤͨ • ࠷େݶϦιʔεΛޮతʹ͍ɺۃྗίετΛ͍͑ͨ. [ ಛ ] • Ϛωʔδυ͞ΕͨΫϥελʔϚωʔδϟɻӡ༻ෛՙ͕͍. • Service Auto Scaling AZ Λҙࣝͨ͠ ࣗಈεέʔϧ • ALB ͱͷΈ߹ΘͤͰಈతϙʔτϚοϐϯά࣮ݱ • λεΫεέδϡʔϥΛࣗ༝ʹೖΕସ͑ΒΕΔ. 14
name EC2 Container Service (ECS) Google Container Engine (GKE) Azure
Container Service (ACS) based on - Kubernetes DC/OS or Docker swarm unit λεΫ Pod Service 15 ࢀߟʣίϯςφཧ͓͓·͔ͳൺֱ
ElasticBeanstalk (EB) Heroku తͳࢠɻ [ Ϣʔεέʔε ] • ίϯςφطଘͷ EB
ΞϓϦಉ༷ʹӡ༻͍ͨ͠ [ ಛ ] • ECS ͷλεΫͱ࣮ͯ͠ߦ͞ΕΔ → ECS ͷΑ͞ΛҰ෦׆͔ͤΔ • ҰํͰ ECS ͷλεΫఆٛɺίϯςφ্ݶ 10 ʹΑΔ੍ • ElasticBeanstalk ͷ֤छػೳ͕͑ΔʂڥΫϩʔϯͳͲ • εέʔϧαʔό୯Ґ. 16
ALB / ELB Application Load Balancer (L7) / Elastic Load
Balancing (L4, L7)ɻϩʔυόϥϯαɻ [ Ϣʔεέʔε ] • ίϯςφͷલʹ͓͖͍ͨ • ECS ͷಈతϙʔτϚοϐϯάΛ͍͍ͨ ( ALB ) • DC/OS Docker for AWS ͳͲͰཧϊʔυͷ HTTPS, SSH [ ಛ ] • ٸܹͳෛՙ͕༧͞ΕΔͱ͖ஆؾਃ • VPC ෦ͷϩʔυόϥϯαͱͯ͠࡞Մೳ NEW 17
ECR EC2 Container RegistryɻDocker ϨδετϦɻ [ Ϣʔεέʔε ] • Docker
Hub ͷ͕ෆຬɻ౦ژʹ΄͍͠ʂ • ΞΫηε੍ޚ͍͚ͨ͠Ͳࣗલཧݏ. [ ಛ ] • Ϛωʔδυ͞Εͨ Docker ϨδετϦɻӡ༻ෛՙ͕͍. • IAM ͱ౷߹͞Ε͍ͯͯɺΞΧϯτ/Ϣʔβࢦఆͷղ์ָ͕ • ΦϑΟε GCP ͳͲ AWS ֎͔Βར༻Մೳ • github.com/awslabs/amazon-ecr-credential-helper 18
S3 ߴػೳͳετϨʔδαʔϏεɻϑΝΠϧஔ͖ɻ [ Ϣʔεέʔε ] • docker save ͰੜͰ͖Δ tar
ΞʔΧΠϒͷอɾ ʢDocker ΠϝʔδͰ͠ʹ͍͘ঢ়گͳͲͰͱͯศརʣ • ൿಗใΛอɾ͍ͨ͠. • ίϯςφ֎ʹӬଓԽ͍ͨ͠σʔλ͕͋Δ. [ ಛ ] • σʔλͷ҉߸ԽΦϓγϣϯ͕๛. • IAM ͱͷ࿈ܞͰίϯςφ͔ΒͷΞΫηε੍ޚ༰қ 19
CodeDeploy σϓϩΠࣗಈԽͷΈʹಛԽͨ͠αʔϏεɻ [ Ϣʔεέʔε ] • docker pull ͚ͩͰͳ͘ɺsave &
load ͍͍ͨ • ωΟςΠϒͳ docker-compose swarm ͰσϓϩΠ͍ͨ͠ • σϓϩΠલޙʹ͋Μͳॲཧ͜ΜͳॲཧΛؾܰʹ͞Έ͍ͨ [ ಛ ] • ΦϯϓϨʹ͋Δαʔόʹରͯ͑͠Δ • Healthy Ͱ͍ͯ΄͍͠ / ׂ߹ Λࢦఆͯ͠σϓϩΠ 20
2. جຊతͳߏɾߋ৽ྫ 21
ECS 22 ࠷খߏ: ECR ECS EC2 Ϣʔβ
ECS 23 ڥߋ৽: ECR ECS EC2 ᶃ docker push ᶄ
λεΫఆٛߋ৽ & ɹ Service ߋ৽ͳͲ ᶅ ΤʔδΣϯτʹࢦࣔ ΤϯδχΞ Ϣʔβ ᶆ docker pull ᶇ σϓϩΠ
ECS with ALB / ELB AWS CLI Ͱͷߋ৽ྫɻʢECS CLI ݱঢ়ಛఆ༻్͔ͳ..ʣ
1. docker build & push > ECR etc..ɻ 2. λεΫఆٛॻ͖͑ 3. aws ecs register-task-definitionɻ 4. aws ecs update-serviceɻ εέʔϧͤ͞ΔͳΒϩʔυόϥϯαΛɻ ECS αʔϏεσΟεΧόϦ ALB / ELB Ͱߦ͏ࢥɻ 24
ECS: ಈతϙʔτϚοϐϯά • λεΫఆٛ ͷ Host ଆ Port ʹ 0
Λࢦఆ • Service ͷϩʔυόϥϯαʹ ALB Λࢦఆ • ίϯςφଆ Port ͱҰக͢Δ TargetGroup ΛׂΓͯ NEW 25
• ͨͱ͑ EC2 ͕ 1ͰɺService DesiredCount > 1 Մೳ •
ྫ͑ 5 ʹ͢Δͱ͜͏ͳΔ • TargetGroup ͷ Targets ݡ͘ɺউखʹ͜͏ͳΔ ECS: ಈతϙʔτϚοϐϯά NEW 26
ײ • Port ͕λεΫεέδϡʔϧ্ͷ੍͔Β֎Εͨʂʂ • ཁ݅ʹԠͯ͡ docker swarm (+ CodeDeploy)
ͱൺֱݕ౼ - ͍ͣΕແఀࢭͰͷϩʔϦϯάΞοϓσʔτ͕Մೳ - ͨͱ͑ EC2 1Ͱ͋ͬͯʂ • ͍ͭʹ͜ͷ͕དྷͨɻ • ײྦ ECS: ಈతϙʔτϚοϐϯά NEW 27
ElasticBeanstalk 28 ࠷খߏ: EC2 ECR EB ECS Ϣʔβ
ElasticBeanstalk 29 ڥߋ৽: EC2 ECR EB ᶃ docker push ΤϯδχΞ
Ϣʔβ ᶈ docker pull ᶉ ϩʔϦϯά Ξοϓσʔτ S3 ᶄ S3 ʹ bundle.zip సૹ ᶅ όʔδϣΞοϓ & ڥߋ৽ ʢEB ͷߋ৽ύλʔϯෳʣ ECS ᶆ λεΫߋ৽ ᶇ ΤʔδΣϯτ ɹʹࢦࣔ
ElasticBeanstalk: ෳίϯςφڥ AWS CLI Ͱͷߋ৽ྫɻʢEB CLI ͳΒߋʹγϯϓϧʣ • source-bundleɻ -
.ebextensionsɻ - foo.configɻ - bar.configɻ - Dockerrun.aws.json : ඞཁʹԠͯ͜͡ΕΛͭΒͭΒॻ͖͑.. 1. source-bundle Λ zip ͰݻΊͯ S3 ʹసૹ 2. aws elasticbeanstalk create-application-versionɻ 3. aws elasticbeanstalk update-environmentɻ 30
ElasticBeanstalk: ෳίϯςφڥ EB × Dockerɺ͚ͬ͜͏·Δਓଟ͍ʁ • CloudInfra Podcast ( https://cloudinfra.audio/
) #nobolycloud ͷ Track 8 ෳίϯςφ Docker ڥͷͭΒΈ͕ޠΒΕ͍ͯΔ.. • ࣾͰ͋ͬͨ·Γࣄྫ: - λεΫʹఆٛͰ͖Δίϯςφ্ݶ 10 ɹˠ ΓΛಉ͡ϗετ্ʹखಈ / ECS Ͱىಈ ɹˠ EB ͷσϓϩΠ͕ 2 ճʹ 1 ճίέΔ - AWS CLI ͔Βͷ EB ॳճ࡞࣌ɺγϯάϧΠϯελϯεΛ ɹɹ ࢦఆ͍ͯ͠Δͷʹ ELB ͕ੜ͞ΕΔ͜ͱ͕͋ΔʢṖʣ • EB ͷ AutoScale ECS ͷΑ͏ʹΫϥελج४Ͱͳ͘ɺ(ry 31
CodeDeploy 32 ࠷খߏ: EC2 S3 CodeDeploy Ϣʔβ
CodeDeploy 33 ڥߋ৽: EC2 S3 CodeDeploy ᶃ docker save ͨ͠
tar ͱ ɹ appspec.yml Λసૹ ᶄ CodeDeploy ʹ ɹ S3 ར༻ͷσϓϩΠΛࢦࣔ ᶅ ΤʔδΣϯτʹࢦࣔ ΤϯδχΞ Ϣʔβ ᶆ σʔλऔಘ ᶇ σϓϩΠ
CodeDeploy with docker ڥߋ৽ͷجຊɻ 1. CircleCI GitLab CI Ͱಛఆϒϥϯνʹ
push / λά͕͍ͭͨΒ 2. Docker Πϝʔδੜͯ͠ɺςετ͕௨ͬͨΒ - docker save ͨ͠ tar ࠐΈͰ CodeDeploy ༻ͷ S3 ʹసૹ - ·ͨ ECR ʹ docker push + appspec.yml ͳͲΛ S3 ʹసૹ 3. CodeDeploy ʹσϓϩΠࢦࣔ 4. ApplicationStop ϑοΫͰ docker rm -f name 2>/dev/null || true 5. ApplicationStart ϑοΫͰ docker load / run -d -p 80:80 .. 34
CodeDeploy with docker-compose 35 ϩʔΧϧͱಉ͡ؾ͕ܰ͞΄͍͠ɻ 1. ಉ্ 2. docker-compose.yml
zip ʹೖΕͯ S3 ʹసૹ 3. ಉ্ 4. ApplicationStop ϑοΫͰ docker-compose rm -f 5. ApplicationStart ϑοΫͰ docker-compose up -d
EC2 1ͰແఀࢭΞοϓσʔτ͍ͨ͠ɻ 1. ಉ্ 2. with docker ͱಉ༷ 3. ಉ্
4. ApplicationStop ෆཁ 5. ApplicationStart ϑοΫͰ - ͢ͰʹՔಇαʔϏε͕͋Ε docker service update ʢ͜ͷͱ͖ docker ΠϝʔδΛ࠷৽ʹߋ৽͢ΔͨΊͷΛʂʣ ʢECR ͳΒ @sha256:.. Ͱͷϋογϡࢦఆ͕ݸਓతʹΦεεϝʣ - ͳ͚Ε docker service create --name web -p 80:80 --replicas 2 .. CodeDeploy with docker swarm 36
CodeDeploy ಋೖ Tips 37 • CI αʔό༻ͷ IAM Ϣʔβʹ -
https://circleci.com/docs/continuous-deployment-with-aws-codedeploy/ ɻ - ECR Λܦ༝͢Δ߹͜͜ͷ IAM ʹ ECR ͷཧݖݶΛՃ • CodeDeploy ͷσϓϩΠʹ S3 Λ͏ͱ͖ - EC2 ʹ AmazonS3ReadOnlyAccess ͳͲͷϩʔϧΛ • CodeDeploy ͷσϓϩΠʹ ECR Λ͏ͱ͖ - EC2 ʹ AmazonEC2ContainerRegistryReadOnly ͳͲͷϩʔϧΛ - github.com/awslabs/amazon-ecr-credential-helper ɻ - github.com/pottava/dockerized-ecr-credential-helper ɻ • Docker swarm ϞʔυΛ͏ʹ - Docker 1.12 ͕ඞཁͳͨΊɺAMI ʹ CentOS 7 / Ubuntu 14.04 ͳͲΛ
3. AWS ͷϚΠΫϩαʔϏεࢧԉαʔϏε ʢݸਓతղऍʹجͮ͘ʣ 38
ߴػೳͳίϯςϯπ৴ɻ [ ཱͭػೳ ] • ៛ີʹઃఆͰ͖ΔΩϟογϡઃఆ • cookie ΛؚΉಈతίϯςϯπʹ҆৺ͯ͑͠Δઃܭ •
ෳΦϦδϯͰɺϚΠΫϩαʔϏεΛ౷߹Ͱ͖Δ [ ಛ ] • ͱʹ͔͘ߴʹϨεϙϯε͢ΔͨΊͷ๛ͳػೳ ʢੈքதͷΤοδϩέʔγϣϯɺΩϟογϡɺTCPɾTLS ࠷దԽͳͲʣ CloudFront 39
ࠓேൃදɺɹॕ HTTP/2 ରԠ CloudFront 40 NEW
ར༻ྫ: CloudFront AWS WAF CloudFront ACM ECS / ElasticBeanstalk ELB
/ ALB EC2 https://www.service.com/ https://assets.service.com/ ʢSSL / TLS ূ໌ॻʣ ʢCDNʣ ʢίϯςφΫϥελཧʣ ʢϩʔυόϥϯαʣ ʢԾαʔόʣ S3 AWS Lambda ʢ੩తϑΝΠϧʣ ʢ࣮ؔߦج൫ʣ API Gateway ʢAPI ཧʣ ʢWeb ΞϓϦέʔγϣϯϑΝΠΞΥʔϧʣ * https://api.service.com/v1/mobies/ https://api.service.com/v1/users/ 41
API Gateway API ͷͨΊͷଟ༷ͳػೳΛͬͨήʔτΣΠɻ [ ཱͭػೳ ] • ෳͷ API
Λ·ͱΊΔΧελϜυϝΠϯػೳ • IAMɺLambdaɺCognito UserPools ͷ͍ͣΕ͔ʹΑΔೝՄ • API ΩʔผͷεϩοτϦϯάͱϦΫΤετΫΥʔλ੍ݶ • Τϥʔ࣌ͷࢦؔతޙୀΞϧΰϦζϜʹରԠͨ͠ SDK ͷ ref) http://docs.aws.amazon.com/ja_jp/general/latest/gr/api-retries.html [ ಛ ] • CI / CD Ͱ҆৺ͷϥΠϑαΠΫϧཧ • ख࡞ۀͰͷઃఆͭΒ͍ɻSwagger.. 42
ར༻ྫ: AWS WAF CloudFront ACM ECS / ElasticBeanstalk S3 ELB
/ ALB EC2 ʢԾαʔόʣ API Gateway AWS Lambda ʢ࣮ؔߦج൫ʣ API Gateway ʢAPI ཧʣ * *αʔϏεϓϩΩγɻDynamoDB ͷ GetItem PutItem ͳͲ IAM ͷ actions Ͱݟ׳Εͨ AWS ֤αʔϏεͷΞΫγϣϯΛ API Gateway ͔Βୟ͚Δػೳɻ ʢϩʔυόϥϯαʣ https://api.service.com/v1/mobies/ https://api.service.com/v2/users/ https://api.service.com/v1/users/ 43
Serverless ͷՐ͚ɺFunction as a Serviceɻ [ ཱͭػೳ ] • Cognito
Sync CloudWatch Logs ͳͲ͔Βͷ࣮ߦ • εέδϡʔϧ࣮ߦ [ ಛ ] • Մ༻ੑεέʔϥϏϦςΟ AWS ʹ͓ͤ • ରԠαʔόϨεϑϨʔϜϫʔΫଟɻซ༻ΦεεϝͰ͢ • ެࣜ: ChaliceʢPythonʣ/ Flourishʢެ։ͪ..ʣ • Serverless: API Gateway ͱΈ߹Θͤ HTTP αʔόΛ؆୯ʹ࡞ΕΔ • Apex: Go ݴޠͰॻ͚ΔɻLambda ͷΈͷཧ • Lamvery: KMS ରԠ͍ͯͯ͠ૉఢ Lambda 44
Ϣʔβཧʁ 45
ϢʔβཧೝূɺϢʔβσʔλͷσόΠεؒಉظɻ [ ཱͭػೳ ] • UserPools: AWS ϚωʔδυͳϢʔβཧػೳ • Federated
Identities: ID ϓϩόΠμΛ௨ͨ͡ AWS Ϧιʔεͷ҆શͳΞΫηε • Sync: ϢʔβσʔλͷอଘɺσόΠεؒͰಉظ [ ಛ ] • ֎෦ ID ϓϩόΠμʢFacebook ͳͲʣͱ؆୯ʹ࿈ܞͰ͖Δ • Lambda Λ͍ॊೈʹΧελϚΠζͰ͖Δ Cognito 46
Cognito Cognito UserPools ະೝূ Facebook Google+ Twitter Amazon.com .. Federated
Identities Authenticated Unauthenticated NEW Cognito Streams Cognito Events ϓογϡಉظ 47
.. Cognito Federated Identities ͍ͣΕ͔ͰϩάΠϯͨ͠Β ↓ ະϩάΠϯͳΒ ↓ AWS Ͱ͜Ε͍͍ͬͯΑʂ
AWS Ͱ͜Ε͍͍ͬͯΑʂ มΘͬͨϢʔβσʔλ ͜ΕͩΑ Ϣʔβσʔλ͕ มߋ͞ΕͨΑʂ ଞͷσόΠεʹ σʔλಉظͯ͠ʂ Authenticated Unauthenticated 48
ར༻ྫ: AWS WAF CloudFront ACM ECS / ElasticBeanstalk S3 ELB
/ ALB EC2 Cognito Cognito ͱ࿈ܞͯ͠Ϣʔβใऔಘ AWS Lambda Cognito ͱ࿈ܞ API Gateway CognitoʢϢʔβೝূɾཧʣ * https://www.service.com/ https://api.service.com/v1/mobies/ https://api.service.com/v2/users/ https://api.service.com/v1/users/ Cognito Ͱೝূ͞Εͨਓ͚ͩڐՄʂ *αʔϏεϓϩΩγɻDynamoDB ͷ GetItem PutItem ͳͲ IAM ͷ actions Ͱݟ׳Εͨ AWS ֤αʔϏεͷΞΫγϣϯΛ API Gateway ͔Βୟ͚Δػೳɻ 49
Cognito UserPools ʹΑΔೝূɻϢʔβใͷอ҆৺ɻ Ϣʔβొ αΠϯΠϯ ύεϫʔυมߋ ʢฐࣾࣄྫʣ 50
AWS ϦιʔεΞϓϦέʔγϣϯͷϞχλϦϯάɻ [ ཱͭػೳ ] • ΞϥʔϜ: ECS ͷ Service
Auto Scaling ͕ઃఆͰ͖Δ • CloudWatch Logs: Docker ͷϩάυϥΠόʹରԠࡁɺͱͯศར • Events: ಛఆͷλΠϛϯάͰ Lambda ΛىಈͰ͖Δ [ ಛ ] • ϝτϦοΫεσʔλͷอଘظؒ 2 िؒ • Logs ͷอ࣋ظؒσϑΥϧτͰແظݶ CloudWatch 51
IAM AWS ϢʔβͱϦιʔεͷણࡉͳΞΫηε੍ޚɻ [ ཱͭػೳ ] • ݖݶཧʢEC2 Πϯελϯε /
ECS λεΫ୯ҐͰ੍ޚՄೳʣ • Cognito API Gateway Λซ༻͠ɺαʔϏεͷΞΫηεΛ੍ޚ [ ಛ ] • ΄ͱΜͲͷ AWS αʔϏε͕ IAM ʹରԠࡁ • Policy Simulator ΞΫηεΞυόΠβͰΑΓηΩϡΞͳઃఆ 52
σʔλͷ҉߸Խʹ͏Ωʔͷཧɻ [ ཱͭػೳ ] • ൿಗใͷཧʢ+ DynamoDB → github.com/fugue/credstash etc.
ʣ • ҉߸ԽΩʔ ID ͷΈΛڥมͰίϯςφʹ͢ͳͲ [ ಛ ] • 伴Λ͏ݖݶͷͳ͍ਓ͔ΒใΛकΔ͜ͱ͕Ͱ͖Δ • CloudTrail Λ༗ޮʹ͢ΕɺΩʔͷ༻ͯ͢ϩάʹΔ KMS 53
4. ϑΣʔζผͷߏྫɾࣄྫ Suzie Prince Head of Product, ThoughtWorks Products 54
ϩʔΧϧ։ൃڥ: ໌.. http://m3-engineer.connpass.com/event/36062/ ʮ։ൃڥͷ Docker Խύλʔϯूʯ@pottava 55
ͲΜͳڥͰɺئΘ͘ • Ҋ݅͝ͱʹՄ༻ੑɾΞΫηε੍ޚɾίετͳͲͰߏΛܾΊ͍ͨ • Infrastructure as Code ͳɺόʔδϣϯཧ͞Εͨੈքʹ͍ͨ͠ • ΠϯϑϥΞϓϦ
git push Ͱڥߋ৽͍ͨ͠ ɹʢͨͩ͠Πϯϑϥͷͯ͢ΛɺͱݴΘͳ͍ʣ • No more SSHɻ • ֤ਓͷׂʹԠͯ͡ɺΕΔ͜ͱΛ੍ݶ͍ͨ͠ → IAM Role • ୭͕ԿΛͨ͠ͷ͔Ѳ͍ͨ͠ → CloudTrail 56
ҎԼɺҰྫ 57
։ൃڥ • Մ༻ੑɿଟগͷμϯλΠϜڐ༰͢Δ • ΞΫηε੍ޚɿҰൠެ։͠ͳ͍ɺϓϩδΣΫτʹΑͬͯෳࡶ • ίετɿ࠷খߏͰ͓ئ͍͠·͢ɻ 58
։ൃڥ ฐࣾࣄྫ: ECS ෳϓϩδΣΫτɺςετڥಥͬࠐΈ͍͢ɻ • ALB / ELB ΘͣɺEC2 1ߏ
• Minimum healthy percent: 0, Maximum percent: 100 Ͱμϯڐ༰ 59 EC2 ᶃ ߋ৽ࢦࣔ ᶄ docker pull ECS ECR
։ൃڥ ฐࣾࣄྫ: ElasticBeanstalk EB ʹ׳Ε͍ͯΕൺֱతಋೖ͍͢͠Ͱ͢ɻ • ECS Λϥοϓͯ͠Ӆṭ͍ͯ͠ΔͷͰɺֶशίετҰݟ͍ • τϥϒͬͨ࣌ͳͲ
ECS ίϯιʔϧ݁ہ։͘͜ͱ͠͠.. 60 EB ᶃ λεΫߋ৽ EC2 ᶄ ߋ৽ࢦࣔ ᶅ docker pull ECS ECR
։ൃڥ ฐࣾࣄྫ: CodeDeploy ΘΓͱͳΜͰͰ͖Δ͕ɺγΣϧܳײ൱Ίͳ͍ɾɾ • ϩʔΧϧڥಉ༷ docker-compose ͕ͦͷ··͑Δͷ͏Ε͍͠ • The
Twelve-Factor App ײɺߴΊΒΕΔɻߴ·Δʔ • ັͷΦϯϓϨར༻.. 61 S3 CodeDeploy EC2 ᶃ ߋ৽ࢦࣔ ᶄ σʔλऔಘ
ຊ൪ڥ • Մ༻ੑɿॏཁɻσϓϩΠ࣌μϯλΠϜڐ༰͠ͳ͍ • ΞΫηε੍ޚɿηΩϡϦςΟରࡦɺAPI ܥͷೝূɾೝՄ • ίετɿϩʔυόϥϯαࣗಈεέʔϧߟྀʹೖΕͯ OK 62
ຊ൪ڥ ฐࣾࣄྫ: ECS + ALB ಈతϙʔτϚοϐϯάͰߋʹίετݮͰ͖·ͨ͠ɻ • ίϯςφஔ্ɺϙʔτ͕ͭΒ͔ͬͨ → ղফʂ
• ϩάϩάυϥΠόܦ༝Ͱͯ͢ CloudWatch Logs ʹ 63 EC2 ECR ALB ECS S3 CloudWatch CloudFront AWS WAF + ACM +
ຊ൪ڥ ฐࣾࣄྫ: Microservices AWS ͷϚωʔδυαʔϏεΛଟ༻ɻ • CognitoɺLambdaɺAPI GatewayɺKinesisɺSES • ALB
ͷύεϕʔεϧʔςΟϯάʢ /auth ͷΈผαʔϏεͳͲʣ • ίϯςφىಈ࣌ʹ͢ڥมͰڍಈɺԠΛ੍ޚ • Sentry ͳͲΤϥʔτϨʔεख๏ΫοΫύου͞ΜΛࢀߟʹ 64
ຊ൪ڥ ฐࣾࣄྫ: DC/OS (Mesos) ෳࡶͳ෦௨৴ʹ ELB Ҏ֎ͷબࢶɻ • ELB ͷ࣍ϨΠϠʹ
Marathon-LBɺͦͷԼʹϚΠΫϩαʔϏε • Marathon-LB: ϗετ໊ HTTP ϔομͰϧʔςΟϯά • ͍ۙকདྷ GPU ରԠͷਪϚΠΫϩαʔϏεೖͨ͘͠.. ʢECS ͰͰ͖Δ͕.. ઌ Apache Mesos v1.0 ౸ୡɺGPU ਖ਼ࣜαϙʔτʣ 65 Master ELB Public Agent Private Agent
AWS ެࣜͰͷࣄྫ 66
• ΫϨδοτΧʔυॅϩʔϯʹڧΈΛͭΞϝϦΧͷۜߦɻ • ALB Ͱ API Λ·ͱΊͨΓɺίετݮͰ͖ͨɻݩʑ AWS Ϣʔβɻ Capital
OneʢECS + ALB ࣄྫʣ 67 https://aws.amazon.com/jp/blogs/compute/microservice-delivery-with-amazon-ecs-and-application-load-balancers/
• ੈքதͷେֶͱڠྗɺ͍͔ͭ͘ΛແঈͰΦϯϥΠϯ্ʹఏڙ͍ͯ͠Δɻ • δϣϒΛ Docker ͰϚΠΫϩαʔϏεʹׂɺECS Ͱεέδϡʔϧɻ CourseraʢECS ࣄྫʣ 68
https://aws.amazon.com/jp/solutions/case-studies/coursera-ecs/
• EC αΠτͷʮ͜ͷΛങͬͨਓ͜Μͳ͍ͯ͠·͢ʯ • σΟʔϓϥʔχϯάͷ OSS * ͚ͩͰͳ͘ɺࣗࣾͷߏࣄྫެ։ɻ Amazon.comʢECS +
EMR ࣄྫʣ 69 http://aws.typepad.com/sajp/2016/07/generating-recommendations-at-amazon-scale-with-apache-spark-and-amazon-dsstne.html * Amazon DSSTNE: https://github.com/amznlabs/amazon-dsstne
֤ϗετͰඞͣىಈ͍ͤͨ͞ίϯςφ͕͋Δ ʢϞχλϦϯάɺvolume / network ϓϥάΠϯͳͲʣ [ AWS αʔϏε ] •
ECS: UserData Ͱ aws ecs start-task Λར༻ ref) http://docs.aws.amazon.com/ja_jp/AmazonECS/latest/developerguide/start_task_at_launch.html • ElasticBeanstalk: جຊతʹͦ͏ಈ͘ [ ͦͷଞ ] • Docker swarm Ϟʔυ: --mode global ͰαʔϏεੜ • Mesos/Marathon: UNIQUE ੍Λ͚ͭͯαʔϏεੜ • Kubernetes: DaemonSet Λ͏ ࢀߟʣon every node 70
ࢀߟʣAWS Ͱͷ DevOps • ܧଓతσϓϩΠ • AWS API Λͬͯࣗલ CI
αʔό͔Βͷࣗಈద༻ • Code 3ܑఋͱ֎෦αʔϏε࿈ܞ • αʔϏεམͪΔ • Route53ɺALB / ELB ͰͷϔϧενΣοΫ • CloudFront S3 ͰͷιʔϦʔ / Τϥʔϖʔδઃఆ • ECSɺAutoScaling Ͱͷࣗಈ෮چ • ΠϯϑϥϨΠϠΠϛϡʔλϒϧʹ • CloudFormation ςϯϓϨʔτ / αʔυύʔςΟπʔϧ܈ • ECSɺElasticBeanstalkɺAPI Gateway ͳͲͷόʔδϣχϯά • ΠϯϑϥϨΠϠ Docker Λҙࣝ͢Δ • IAMʢಛʹϩʔϧʣ/ VPC / SecurityGroup ͷݟ͠ • ϚωʔδυαʔϏεͷಋೖ 71
• Docker ࣾɺAWS ༻ swarm Ϋϥελಋೖπʔϧɻεέʔϧ؆୯ɻ • αʔϏεΛఆٛ͢Δͱ ELB ͷ֘ϙʔτ͕ͦΕʹࣗಈਵ͢Δʂ
• Γͳ͍ͱ͜ΖΈΜͳͰ Docker ࣾʹཁΛʙ ࢀߟʣDocker for AWS 72
͝૬ஊ͓ؾܰʹͪ͜Β·Ͱ.. <