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 (demo)
Search
ryo nakamaru
September 21, 2016
Technology
0
160
containers-on-aws (demo)
JAWS-UG コンテナ支部 #6 で発表した「AWS loves Docker その2」の資料です。
ryo nakamaru
September 21, 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.2k
ハイブリッド並列 on Kubernetes/hybrid-parallel-program-on-kubernetes
pottava
1
400
AWS Fargate + Code 兄弟で始める継続的デリバリー / Continuous Delivery with AWS Fargate and Code brothers
pottava
12
3k
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
450
Other Decks in Technology
See All in Technology
Strict Concurrencyにしたらdeinitでクラッシュする話
0si43
0
120
【shownet.conf_】ShowNet 2024 ~ Inter * Network ~
shownet
PRO
0
380
Understanding and Optimising INP
akshayysharma
0
150
【ログ分析勉強会】EDR ログで内部不正を検出できるのか、Copilot に聞いてみた
hssh2_bin
2
270
エムスリー全チーム紹介資料 / Introduction of M3 All Teams
m3_engineering
1
210
LINEヤフー新卒採用 コーディングテスト解説 アルゴリズム問題編
lycorp_recruit_jp
0
12k
10Xでのデータ基盤の変遷とこれから: データマネジメントのリアル 〜BtoB企業3社の歩みとこれから〜
10xinc
6
1.2k
Assisted reorganization of data structures
ennael
PRO
0
210
Causal Impactを用いたLINE Pay UIの効果検証とABテスト実施への貢献
lycorptech_jp
PRO
3
490
[JAWS-UG GameTech] 第6回 各種事例紹介_18TRIPにおけるAWSサービスを活用した負荷テスト・障害テスト
naoto_yasuda
0
100
Pythonを活用したLLMによる構造的データ生成の手法と実践
brainpadpr
3
220
Oracle GoldenGate 23ai 導入Tips
oracle4engineer
PRO
1
200
Featured
See All Featured
Web Components: a chance to create the future
zenorocha
310
42k
Designing the Hi-DPI Web
ddemaree
279
34k
For a Future-Friendly Web
brad_frost
174
9.3k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
44
2k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
4
98
Docker and Python
trallard
40
3k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
663
120k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
The Pragmatic Product Professional
lauravandoore
31
6.2k
How To Stay Up To Date on Web Technology
chriscoyier
786
250k
Transcript
AWS Dockerʢͦͷ 2ʣ JAWS-UG ίϯςφࢧ෦ #5 2016/09/21
@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
גࣜձࣾεϐϯϑ ΞΠσΟΞΛ͔ͨͪʹʂ + 4
https://www.supinf.co.jp/service/dockersupport/ Comfy for Docker ϓϩδΣΫτͷ Docker ಋೖɾ։ൃࢧԉɾӡ༻ࢹߦΛ͍ͨ͠·͢ɻ ʢGCP / Azure
ͪΖΜରԠ͍ͯ͠·͢ɾɾʣ http://prtimes.jp/main/html/rd/p/000000007.000007768.html 5
Ͱ 6
ɹAWS Docker 7
͓͍͑ͨ͜͠ͱ 1. AWS ͷίϯςφࢧԉػೳͨ͘͞Μ 2. ࣮ࡍʹσϓϩΠ͕ಈ༷͘ࢠ 8
͓͢͠Δ͜ͱ 1. AWS ͷίϯςφؔ࿈αʔϏε֓ཁ 2. جຊతͳߏɾߋ৽ྫ 2.1. ECSɻ 2.2. ElasticBeanstalkɻ
2.3. CodeDeployɻ 3. σϞ 9
1. AWS ͷίϯςφؔ࿈αʔϏε֓ཁ 10
EC2 Amazon Elastic Compute CloudɻԾαʔόɻ [ Ϣʔεέʔε ] • Docker
ͷ swarm Ϟʔυ Kubernetes Λ͍͍ͨ • Docker ϨδετϦΛࣗલͰӡ༻͍ͨ͠ • อकʢʁʣओʹ SSH ͷओઓɻ [ ಛ ] • Ϋϥελཧπʔϧɺαʔόىಈ↑ӡ༻ෛՙ↑ • ͱ͍͑ɺͳΜͰͰ͖Δ. 11
• Docker ࣾɺAWS ༻ swarm Ϋϥελಋೖπʔϧɻεέʔϧ؆୯ɻ • αʔϏεΛఆٛ͢Δͱ ELB ͷ֘ϙʔτ͕ͦΕʹࣗಈਵ͢Δʂ
• Γͳ͍ͱ͜ΖΈΜͳͰ Docker ࣾʹཁΛʙ ࢀߟʣDocker for AWS 12
ECS EC2 Container Serviceɻίϯςφཧɻ [ Ϣʔεέʔε ] • λεΫ͝ͱͷదͳݖݶઃఆ +
εέʔϧ AWS ʹ͍ͤͨ • ࠷େݶϦιʔεΛޮతʹ͍ɺۃྗίετΛ͍͑ͨ. [ ಛ ] • Ϛωʔδυ͞ΕͨΫϥελʔϚωʔδϟɻӡ༻ෛՙ͕͍. • Service Auto Scaling AZ Λҙࣝͨ͠ ࣗಈεέʔϧ • ALB ͱͷΈ߹ΘͤͰಈతϙʔτϚοϐϯά࣮ݱ • λεΫεέδϡʔϥΛࣗ༝ʹೖΕସ͑ΒΕΔ. 13
name EC2 Container Service (ECS) Google Container Engine (GKE) Azure
Container Service (ACS) based on - Kubernetes DC/OS or Docker swarm unit λεΫ Pod Service 14 ࢀߟʣίϯςφཧ͓͓·͔ͳൺֱ
ElasticBeanstalk (EB) Heroku తͳࢠɻ [ Ϣʔεέʔε ] • ίϯςφطଘͷ EB
ΞϓϦಉ༷ʹӡ༻͍ͨ͠ [ ಛ ] • ECS ͷλεΫͱ࣮ͯ͠ߦ͞ΕΔ → ECS ͷΑ͞ΛҰ෦׆͔ͤΔ • ҰํͰ ECS ͷλεΫఆٛɺίϯςφ্ݶ 10 ʹΑΔ੍ • ElasticBeanstalk ͷ֤छػೳ͕͑ΔʂڥΫϩʔϯͳͲ • εέʔϧαʔό୯Ґ. 15
ALB / CLB Application Load Balancer (L7) / Classic Load
Balancer (L4, L7)ɻϩʔυόϥϯαɻ [ Ϣʔεέʔε ] • ίϯςφͷલʹ͓͖͍ͨ • ECS ͷಈతϙʔτϚοϐϯάΛ͍͍ͨ ( ALB ) • DC/OS Docker for AWS ͳͲͰཧϊʔυͷ HTTPS, SSH [ ಛ ] • ٸܹͳෛՙ͕༧͞ΕΔͱ͖ஆؾਃ • VPC ෦ͷϩʔυόϥϯαͱͯ͠࡞Մೳ NEW 16
ECR EC2 Container RegistryɻDocker ϨδετϦɻ [ Ϣʔεέʔε ] • Docker
Hub ͷ͕ෆຬɻ౦ژʹ΄͍͠ʂ • ΞΫηε੍ޚ͍͚ͨ͠Ͳࣗલཧݏ. [ ಛ ] • Ϛωʔδυ͞Εͨ Docker ϨδετϦɻӡ༻ෛՙ͕͍. • IAM ͱ౷߹͞Ε͍ͯͯɺΞΧϯτ/Ϣʔβࢦఆͷղ์ָ͕ • ΦϑΟε GCP ͳͲ AWS ֎͔Βར༻Մೳ • github.com/awslabs/amazon-ecr-credential-helper 17
S3 ߴػೳͳετϨʔδαʔϏεɻϑΝΠϧஔ͖ɻ [ Ϣʔεέʔε ] • docker save ͰੜͰ͖Δ tar
ΞʔΧΠϒͷอɾ ʢDocker ΠϝʔδͰ͠ʹ͍͘ঢ়گͳͲͰͱͯศརʣ • ൿಗใΛอɾ͍ͨ͠. • ίϯςφ֎ʹӬଓԽ͍ͨ͠σʔλ͕͋Δ. [ ಛ ] • σʔλͷ҉߸ԽΦϓγϣϯ͕๛. • IAM ͱͷ࿈ܞͰίϯςφ͔ΒͷΞΫηε੍ޚ༰қ 18
CodeDeploy σϓϩΠࣗಈԽͷΈʹಛԽͨ͠αʔϏεɻ [ Ϣʔεέʔε ] • docker pull ͚ͩͰͳ͘ɺsave &
load ͍͍ͨ • ωΟςΠϒͳ docker-compose swarm ͰσϓϩΠ͍ͨ͠ • σϓϩΠલޙʹ͋Μͳॲཧ͜ΜͳॲཧΛؾܰʹ͞Έ͍ͨ [ ಛ ] • ΦϯϓϨʹ͋Δαʔόʹରͯ͑͠Δ • Healthy Ͱ͍ͯ΄͍͠ / ׂ߹ Λࢦఆͯ͠σϓϩΠ 19
2. جຊతͳߏɾߋ৽ྫ 20
ECS 21 ࠷খߏ: ECR ECS EC2 Ϣʔβ
ECS 22 ڥߋ৽: 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 Ͱߦ͏ࢥɻ 23
ECS: ಈతϙʔτϚοϐϯά • λεΫఆٛ ͷ Host ଆ Port ʹ 0
Λࢦఆ • Service ͷϩʔυόϥϯαʹ ALB Λࢦఆ • ίϯςφଆ Port ͱҰக͢Δ TargetGroup ΛׂΓͯ NEW 24
• ͨͱ͑ EC2 ͕ 1ͰɺService DesiredCount > 1 Մೳ •
ྫ͑ 5 ʹ͢Δͱ͜͏ͳΔ • TargetGroup ͷ Targets ݡ͘ɺউखʹ͜͏ͳΔ ECS: ಈతϙʔτϚοϐϯά NEW 25
ElasticBeanstalk 26 ࠷খߏ: EC2 ECR EB ECS Ϣʔβ
ElasticBeanstalk 27 ڥߋ৽: 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ɻ 28
CodeDeploy 29 ࠷খߏ: EC2 S3 CodeDeploy Ϣʔβ
CodeDeploy 30 ڥߋ৽: 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 .. 31
CodeDeploy with docker-compose 32 ϩʔΧϧͱಉ͡ؾ͕ܰ͞΄͍͠ɻ 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 33
CodeDeploy ಋೖ Tips 34 • 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. σϞ 35
CloudFront ʢCDNʣ ߏ CLB / ALB EC2 https://www.service.com/ ʢϩʔυόϥϯαʣ ʢԾαʔόʣ
https://www.service.com/api/ EC2 ʢԾαʔόʣ Web ͱ API ΛίϯςφͰՔಇ͍ͤͯ͞·͢ 36
σϓϩΠ CloudFront ECS / ElasticBeanstalk CLB / ALB EC2 https://www.service.com/
ʢCDNʣ ʢίϯςφΫϥελཧʣ ʢϩʔυόϥϯαʣ ʢԾαʔόʣ CodeDeploy ʢσϓϩΠαʔϏεʣ https://www.service.com/api/ EC2 ʢԾαʔόʣ ECS / CodeDeploy Ͱ֤αʔϏεΛߋ৽͠·͢ 37
σϓϩΠ CloudFront ECS / ElasticBeanstalk CLB / ALB EC2 https://www.service.com/
ʢCDNʣ ʢίϯςφΫϥελཧʣ ʢϩʔυόϥϯαʣ ʢԾαʔόʣ CodeDeploy ʢσϓϩΠαʔϏεʣ https://www.service.com/api/ EC2 ʢԾαʔόʣ GitHub / CircleCI ܦ༝ͰσϓϩΠ͞Ε·͢ 38 ΤϯδχΞ git tag GitHub
ଓ͖ͪ͜Β http://bit.ly/2cPVJNC 39
͝૬ஊ͓ؾܰʹͪ͜Β·Ͱ.. <