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.3k
ハイブリッド並列 on Kubernetes/hybrid-parallel-program-on-kubernetes
pottava
1
410
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
Taming you application's environments
salaboy
0
180
誰も全体を知らない ~ ロールの垣根を超えて引き上げる開発生産性 / Boosting Development Productivity Across Roles
kakehashi
1
220
強いチームと開発生産性
onk
PRO
34
11k
B2B SaaSから見た最近のC#/.NETの進化
sansantech
PRO
0
750
Why App Signing Matters for Your Android Apps - Android Bangkok Conference 2024
akexorcist
0
120
ExaDB-D dbaascli で出来ること
oracle4engineer
PRO
0
3.8k
SSMRunbook作成の勘所_20241120
koichiotomo
2
130
Application Development WG Intro at AppDeveloperCon
salaboy
0
180
隣接領域をBeyondするFinatextのエンジニア組織設計 / beyond-engineering-areas
stajima
1
270
これまでの計測・開発・デプロイ方法全部見せます! / Findy ISUCON 2024-11-14
tohutohu
3
370
IBC 2024 動画技術関連レポート / IBC 2024 Report
cyberagentdevelopers
PRO
0
110
マルチモーダル / AI Agent / LLMOps 3つの技術トレンドで理解するLLMの今後の展望
hirosatogamo
37
12k
Featured
See All Featured
How to Think Like a Performance Engineer
csswizardry
20
1.1k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.8k
Practical Orchestrator
shlominoach
186
10k
Statistics for Hackers
jakevdp
796
220k
Building Better People: How to give real-time feedback that sticks.
wjessup
364
19k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
The Language of Interfaces
destraynor
154
24k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
Docker and Python
trallard
40
3.1k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
27
4.3k
Teambox: Starting and Learning
jrom
133
8.8k
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
͝૬ஊ͓ؾܰʹͪ͜Β·Ͱ.. <