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
96
jQuery -> React -> Vue と仕事で触った(予定込み)ので特徴を比較してみた
jonakpkp
4
130
20200125_新人エンジニアが本音を語る会.pdf
jonakpkp
1
200
なんでReactやらVueやら、更にはRailsでもNode.jsが必要なの?
jonakpkp
0
36
Featured
See All Featured
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
120k
Code Reviewing Like a Champion
maltzj
521
39k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
7k
Building Applications with DynamoDB
mza
93
6.2k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.2k
StorybookのUI Testing Handbookを読んだ
zakiyama
28
5.4k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
160
15k
The Pragmatic Product Professional
lauravandoore
32
6.4k
Building Adaptive Systems
keathley
38
2.4k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
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