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
20210611_awsecs_rev2.pdf
Search
jonakp
June 11, 2021
0
15
20210611_awsecs_rev2.pdf
jonakp
June 11, 2021
Tweet
Share
More Decks by jonakp
See All by jonakp
生成AIキャッチアップ会__生成AIと共に働くために個人と組織の視点から_.pdf
jonakpkp
0
93
jQuery -> React -> Vue と仕事で触った(予定込み)ので特徴を比較してみた
jonakpkp
4
130
20200125_新人エンジニアが本音を語る会.pdf
jonakpkp
1
190
なんでReactやらVueやら、更にはRailsでもNode.jsが必要なの?
jonakpkp
0
36
Featured
See All Featured
Testing 201, or: Great Expectations
jmmastey
40
7.1k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
44
9.3k
Writing Fast Ruby
sferik
628
61k
How to Think Like a Performance Engineer
csswizardry
22
1.2k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Music & Morning Musume
bryan
46
6.2k
It's Worth the Effort
3n
183
28k
Keith and Marios Guide to Fast Websites
keithpitt
410
22k
The World Runs on Bad Software
bkeepers
PRO
65
11k
Building Applications with DynamoDB
mza
91
6.1k
Art, The Web, and Tiny UX
lynnandtonic
298
20k
Side Projects
sachag
452
42k
Transcript
ͳΜͱͳ͓ͬͯ͘͘ͱخ͍͔͠͠ Εͳ͍ Amazon ECS + Fargateͷ ~ຊ൪ڥʹ͓͚ΔDockerίϯςφར༻~
લҊ݅ͷٕज़ελοΫ ࠓͷ
ͳ͔ͳ͔͍͠ωλ... ͱ͔͘ ͳ͊...
From To Ͱઆ໌͠·͢ʂ ͳͷͰ
1. Dockerͷ֓ཁ 2. DockerͷԿ͕خ͍͔͠ 3. DockerΛຊ൪ڥͰ͏ͱԿ͕خ͍͔͠ 4. DockerΛຊ൪ڥͰ͏߹ͷ՝ 5. Amazon
ECSͷߏཁૉͱ࣮ߦڥ 6. Amazon ECSͷTips ྲྀΕ
͏͍ͩͿΕ͍ͯΔͷͰɺࡉ͔͍ͱ͜Ζڐ͠ ͍ͯͩ͘͞ʀʀ ͋ͱ࣮ࡍʹҊ݅ϦϦʔεલʹൈ͚ͨͷͰɺ ӡ༻ͷͱ͔ৼΒͳ͍Ͱ͍ͩ͘͞ʀʀ ༧ઢ
Dockerͷ֓ཁ
DockerʹίϯςφܕͷԾԽ
DockerͷΈ(งғؾ)
DockerͷԿ͕خ͍͔͠?
Մൖੑ(ϙʔλϏϦςΟ)!!! ଞʹ͋Δ͚Ͳ...
DockerΘͳ͍ = ڥࠩͰಈ͍ͨΓಈ͔ͳ͔ͬͨΓ... Mac Windows Linux (Ubuntu) Linux (CentOS) ಈ͔ͳ͍💢
ಈ͔ͳ͍💢 ಈ͔ͳ͍💢 ಈ͘😄
Mac Windows Linux (Ubuntu) Linux (CentOS) ಈ͘😄 ಈ͘😄 ಈ͘😄 ಈ͘😄
Docker͏ = ڥ͕ࠩDocker/DockerΠϝʔδͰٵऩ͞ΕΔͷͰେମಈ͘ʂ
DockerΛຊ൪ڥͰ ͏ͱԿ͕خ͍͠ͷ͔ʁ
ͬͺΓ Մൖੑ(ϙʔλϏϦςΟ)!!! ଞʹ͋Δ͚Ͳ...
ϩʔΧϧ ։ൃڥ (Mac) staging ڥ (Linux) ຊ൪ڥ (Linux) ಈ͘😄 ಈ͔ͳ͍😭
ಈ͔ͳ͍💢
ϩʔΧϧ ։ൃڥ (Mac) staging ڥ (Linux) ຊ൪ڥ (Linux) ಈ͘😄 ಈ͘😄
ಈ͘😄
DockerΛຊ൪ڥͰ ͏߹ͷ՝
͡Ό͋ͱΓ͋͑ͣຊ൪ڥͰ Docker͑ྑ͍ͷ͔ʁ (ྫ͑AWSͳΒEC2ʹDockerೖΕΔͰOKʁ)
μϝͰ͢
͜ΜͳαʔϏεߏΛఆ ' # % ϑϩϯτΤϯυ(Reactͱ͔) όοΫΤϯυ(Railsͱ͔) σʔλϕʔε(MySQLͱ͔) ͦΕͧΕ͕ίϯςφ
' # % Πϝʔδ ஔ͖ ίϯϐϡʔςΟϯάϊʔυ (≒αʔόɻEC2ͱ͔) ' # %
' # % Πϝʔδ ஔ͖ ίϯϐϡʔςΟϯάϊʔυ (≒αʔόɻEC2ͱ͔) ΠϝʔδΛߋ৽͚ͨ͠Ͳɺಈ͔͞ͳ͍ͱҙຯ͕ͳ͍... ߋ৽ ߋ৽
ߋ৽ ' # %
' # % ' # % Πϝʔδ ஔ͖ 1. ࣗಈσϓϩΠ͕ඞཁ
ίϯϐϡʔςΟϯάϊʔυ (≒αʔόɻEC2ͱ͔)
' # % ΊͬͪΌΞΫηε͖ͯΔ...
' # % 2.εέʔϧΞτ(ϊʔυͷΛ૿͢)͠ͳ͍ͱʂ ' # % # %
' # % 3.ϩʔυόϥϯα(ෛՙࢄ)ʂ ' # % # %
' # % ' # % # % ίϯςφ͕མͪͨ!!!
' # % ' # % # % 4.ࢹ/෮چͷΈཉ͍͠ʂ '
Docker͚ͩͰղܾͰ͖ͳ͍՝͕͋Δ
ෳͷίϯςφΛཧ͢Δඞཁ͕͋Δ
ʮίϯςφΦʔέετϨʔγϣϯπʔϧʯ Λ༻͍Δͷ͕Ұൠత
σϑΝΫτ ίϯςφΦʔέετϨʔγϣϯπʔϧͷྫ
ҰԠ ίϯςφΦʔέετϨʔγϣϯπʔϧͷྫ
࣮ ίϯςφΦʔέετϨʔγϣϯπʔϧͷྫ
None
ʮίϯςφΦʔέετϨʔγϣϯπʔϧʯ (=ෳͷίϯςφΛཧ͢ΔͨΊͷπʔϧ)
Amazon ECSͷ ߏཁૉͱ࣮ߦڥ
Amazon ECS ͷߏཁૉ
λεΫఆٛ λεΫΛߏ͢Δίϯςφ܈Λఆٛ ɾίϯςφఆٛ(Πϝʔδͷॴ) ɾCPU/ϝϞϦ ɾIAMϩʔϧ ɾωοτϫʔΫ ɾetc... ࢀর Πϝʔδ ஔ͖
λεΫఆٛ λεΫΛߏ͢Δίϯςφ܈Λఆٛ ɾίϯςφఆٛ(Πϝʔδͷॴ) ɾCPU/ϝϞϦ ɾIAMϩʔϧ ɾωοτϫʔΫ ɾetc... ࢀর Ϋϥελʔ ࣮ߦڥͷڥք
Πϝʔδ ஔ͖
λεΫఆٛ λεΫΛߏ͢Δίϯςφ܈Λఆٛ ɾίϯςφఆٛ(Πϝʔδͷॴ) ɾCPU/ϝϞϦ ɾIAMϩʔϧ ɾωοτϫʔΫ ɾetc... ࢀর Ϋϥελʔ ࣮ߦڥͷڥք
λεΫ ɾλεΫఆٛʹج͖ͮ ىಈ͞ΕΔίϯςφ܈ ɾಉҰλεΫͷίϯςφ ಉҰϗετͰ࣮ߦ͞ΕΔ ࢀর Πϝʔδ ஔ͖
λεΫఆٛ λεΫΛߏ͢Δίϯςφ܈Λఆٛ ɾίϯςφఆٛ(Πϝʔδͷॴ) ɾCPU/ϝϞϦ ɾIAMϩʔϧ ɾωοτϫʔΫ ɾetc... ࢀর Ϋϥελʔ ࣮ߦڥͷڥք
λεΫ ɾλεΫఆٛʹج͖ͮ ىಈ͞ΕΔίϯςφ܈ ɾಉҰλεΫͷίϯςφ ಉҰϗετͰ࣮ߦ͞ΕΔ ࢀর αʔϏε ɾλεΫΛ͍ͭ͘ෳ͢Δ͔(nݸ)Λఆٛ & ىಈޙ ఆٛͨ͠λεΫ(nݸ)Λอ࣋ ɾALB(ϩʔυόϥϯα)ͱ࿈ܞ ɾΦʔτεέʔϧ Πϝʔδ ஔ͖
λεΫఆٛ λεΫΛߏ͢Δίϯςφ܈Λఆٛ ɾίϯςφఆٛ(Πϝʔδͷॴ) ɾCPU/ϝϞϦ ɾIAMϩʔϧ ɾωοτϫʔΫ ɾetc... ࢀর Ϋϥελʔ ࣮ߦڥͷڥք
λεΫ ɾλεΫఆٛʹج͖ͮ ىಈ͞ΕΔίϯςφ܈ ɾಉҰλεΫͷίϯςφ ಉҰϗετͰ࣮ߦ͞ΕΔ ࢀর αʔϏε ɾλεΫΛ͍ͭ͘ෳ͢Δ͔(nݸ)Λఆٛ & ىಈޙ ఆٛͨ͠λεΫ(nݸ)Λอ࣋ ɾALB(ϩʔυόϥϯα)ͱ࿈ܞ ɾΦʔτεέʔϧ 4.ࢹ/෮چ 3.ϩʔυόϥϯαʔ 2.Φʔτεέʔϧ 1.ࣗಈσϓϩΠ Πϝʔδ ஔ͖
ίϯςφͷ࣮ߦڥʹ͍ͭͯ
ECSͰཧ͞ΕΔίϯςφͲ͜Ͱಈ͘ͷ͔ͱ͍͏ͱ... Amazon EC2 AWS Fargate EC2ΛඞཁͳࣗͰηοτΞοϓͯ͠ Ϋϥελʔʹొ͢Δ ͍͍ͩͨશ෦AWSଆͰͬͯ͘ΕΔ (ϑϧϚωʔδυ)
λεΫఆٛ λεΫΛߏ͢Δίϯςφ܈Λఆٛ ɾίϯςφఆٛ(Πϝʔδͷॴ) ɾCPU/ϝϞϦ ɾIAMϩʔϧ ɾωοτϫʔΫ ɾetc... ࢀর Ϋϥελʔ ࣮ߦڥͷڥք
λεΫ ɾλεΫఆٛʹج͖ͮ ىಈ͞ΕΔίϯςφ܈ ɾಉҰλεΫͷίϯςφ ಉҰϗετͰ࣮ߦ͞ΕΔ ࢀর αʔϏε ɾλεΫΛ͍ͭ͘ෳ͢Δ͔(nݸ)Λఆٛ & ىಈޙ ఆٛͨ͠λεΫ(nݸ)Λอ࣋ ɾALB(ϩʔυόϥϯα)ͱ࿈ܞ ɾΦʔτεέʔϧ
Amazon ECS Tips
σϓϩΠͷࣗಈԽ
Github Actions
Github Actions
Github Actions PR & Ϛʔδ
Github Actions ΠϝʔδΛϏϧυ & push ߋ৽
Github Actions λεΫఆٛΛߋ৽
Github Actions ͋ͱউखECSଆͰউखʹͬͯ͘ΕΔʂ
ͦͷଞTips2 FargateίϯςφͷϩάΠϯ
ECSͰཧ͞ΕΔίϯςφͲ͜Ͱಈ͘ͷ͔ͱ͍͏ͱ...(࠶ܝ) Amazon EC2 AWS Fargate EC2ΛඞཁͳࣗͰηοτΞοϓͯ͠ Ϋϥελʔʹొ͢Δ ͍͍ͩͨશ෦AWSଆͰͬͯ͘ΕΔ (ϑϧϚωʔδυ)
AWS Fargate ѹతʹͪ͜Β͕Φεεϝʂʂʂ
શʹ ϒϥοΫϘοΫε
αʔόͷதʹೖͬͯ࡞ۀͰ͖ͳ͍ʂʂʂ ো͕ى͖ͨ࣌ͱ͔ɺͪΐͬͱ%#ͷத ֬ೝ͍ͨ࣌͠ͱ͔Ͳ͏͢Ε͍͍Μͩ💢
ͪΐͬͱલ·Ͱ ɾϩάΛ֎ʹు͖ग़͢(Cloud Watch) ɾ౿ΈαʔόΛ༻ҙͯ͠ɺECR͔ΒΠϝʔδΛ Ҿͬுͬͯ͘Δ ɾSessionManagerΛࠐΜͰແཧΓϩάΠϯ (ηογϣϯͷҡ࣋ʹ͓͕͔͔ۚΔ)
࠷ۙ(202103~) Amazon ECS Exec Λ͑ ؆୯ʹϩάΠϯͰ͖Δʂʂʂ (αʔϏεʹ1ͭઃఆΛՃͯ͠ɺIAMʹઃఆՃ͑Δ͚ͩ)
࠷ۙ(202103~)
·ͱΊ ɾDockerͷྑ͍ͱ͜ΖՄൖੑ ɾຊ൪ڥͩͱෳίϯςφΛཧ͢Δπʔϧ͕ඞཁ ɾECSίϯςφΦʔέετϨʔγϣϯπʔϧ(αʔϏε) ɾECSΫϥελʔ&αʔϏεˍλεΫ͔ΒΔ ɾࣗಈԽવ(?)Δʂ ɾੲFargateϩάΠϯ͔͚ͬͨ͠Ͳɺࠓ؆୯ͰΦε εϝ
Ҏ্Ͱ͢ɻ͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠
https://tech.medpeer.co.jp/entry/2021/05/28/180408
None