Slide 1

Slide 1 text

2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS) ECS/Fargateͷ׆༻ࣄྫ (Ruby on Railsฤ) ϥϯαʔζגࣜձࣾ SRE/҆ୡ ྋ

Slide 2

Slide 2 text

2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS) ΞδΣϯμ ɾࣗݾ঺հ ɾݱࡏऔΓ૊ΜͰ͍Δ͜ͱ ɾECS/FargateͷϝϦοτσϝϦοτ ɾ։ൃ؀ڥΛ࡞ΔϙΠϯτ ɾStg/ຊ൪؀ڥͷߏ੒ʹ͍ͭͯ ɾSSH/࡞ۀ༻ίϯςφʮdevopsʯʹ͍ͭͯ ɾCircleCIʹΑΔίϯςφσϓϩΠ ɾECS Scheduled TasksʹΑΔόον࣮૷ʹ͍ͭͯ ɾϩά/ίϯςφ؂ࢹʹ͍ͭͯ ɾ·ͱΊ

Slide 3

Slide 3 text

2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS) ࣗݾ঺հ

Slide 4

Slide 4 text

2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS) ࣗݾ঺հ ɾ҆ୡ ྋ(adachin) ɾLancers SRE 2018~ ɾ@adachin0817 ɾRVIRUS0817 ɾblog.adachin.me ɾwiki.adachin.me ɾOSS : ɾCakePHPͰݸਓαʔϏε։ൃத

Slide 5

Slide 5 text

2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS) ݱࡏऔΓ૊ΜͰ͍Δ͜ͱ

Slide 6

Slide 6 text

2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS) ݱࡏऔΓ૊ΜͰ͍Δ͜ͱ ɾڈ೥ळ ɾάϧʔϓձࣾ(γΫϩϚʔέςΟϯά) ɾ͘͞ΒͷΫϥ΢υͰӡ༻ ɾॳΊͯECS/FargateʹҠߦνϟϨϯδ ɾࠓ೥4݄ʹҠߦ׬ྃ ɹɾࠓճ͸ͪ͜Βͷ࿩Λ͠·͢!! ɾݱࡏ(5݄͔Β) ɾάϧʔϓձࣾ(Lancers Agency)ɹ ɾECS/FargateͰҠߦத!!

Slide 7

Slide 7 text

2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS) EC2ͱൺֱͨ͠ECS/Fargate ͷϝϦοτσϝϦοτ

Slide 8

Slide 8 text

2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS) EC2ͱൺֱͨ͠ECS/FargateͷϝϦοτσϝϦοτ ϝϦοτ ɾଐਓԽ͕ൃੜ͠ͳ͍ ɾImmutableͳαʔόʔͷӡ༻ ɹɾ҆ఆӡ༻ɺӡ༻ޮ཰ͷΞοϓ ɾϗετΠϯελϯεͷ؅ཧ͕ল͚Δ ɾλεΫ୯ҐͰࣗ༝ʹϦιʔεมߋՄೳ ɾεέʔϧΞ΢τͷ͠΍͢͞ σϝϦοτ ɾσόοά͕ͮ͠Β͍ ɾdocker exec΍SSH͕Ͱ͖ͳ͍ ɾλεΫͷىಈ଎౓͕஗Ί ɹɾόον࣮ߦ΋਺෼஗͘ͳΔ ɾྉ͕͓ۚߴΊ ɹɾEC2ΑΓׂߴʢ1ׂʙ2ׂʣ

Slide 9

Slide 9 text

2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS) ։ൃ؀ڥΛ࡞Δ ϙΠϯτ

Slide 10

Slide 10 text

2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS) ։ൃ؀ڥΛ࡞ΔϙΠϯτ ɾຊ൪؀ڥͱಉ౳ͷߏ੒Λ࠶ݱ ɾELB(H2O)ίϯςφ(ϦόʔεϓϩΩγ) ɾApp(ίϯςφ) ɹɾruby:2.5.7 ɹɾRails4.2.11 ɹɾNginx ɾMySQLίϯςφ ɹɾ5.7 ɾ֤ΞϓϦέʔγϣϯͷىಈ͸SupervisorͰ؅ཧ ɾbundle install͸AppίϯςφͰϩάΠϯ࣌ʹ࣮ߦ ɹɾsupervisorctlͰΞϓϦΛrestart͢ΔΑ͏ʹ

Slide 11

Slide 11 text

2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS) Stg/ຊ൪؀ڥͷ ߏ੒ʹ͍ͭͯ

Slide 12

Slide 12 text

2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS) Stg/ຊ൪؀ڥͷߏ੒ʹ͍ͭͯ ɾTerraformͰશϦιʔείʔυԽ ɾStg؀ڥ͸λεΫ਺͸1ͭ ɾdevopsίϯςφͷར༻ ɾDB͸RDS AuroraʹҠߦ ɾը૾͸S3ʹอଘ ɾϩά͸CloudWatch Logs ɾόον͸ECS Scheduled Tasks ɾ಺෦؂ࠪ(ϩάͷू໿) ɹɾAmazon Kinesis ɾσϓϩΠ͸CircleCIͷΈͰ࣮૷ ɾ؂ࢹ͸Datadog

Slide 13

Slide 13 text

2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS) SSH/࡞ۀ༻ίϯςφ ʮdevopsʯʹ͍ͭͯ

Slide 14

Slide 14 text

2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS) SSH/࡞ۀ༻ίϯςφʮdevopsʯʹ͍ͭͯ ɾAppʹ͸SSH͠ͳ͍ ɾSSH/࡞ۀ༻ίϯςφ(Appͱಉ౳) ɹɾdevopsͱ໋໊ ɾίϚϯυͰRDS΁઀ଓ ɹɾdump΍restore ɾaws cliͷར༻ ɾrails consoleͰͷσόοά ɾSSMͷSession Manager ΋͋Δ͕ ɹɾखܰʹ౿Έ୆͔ΒSSHΛ͍ͨͨ͠Ί ɾVPC PeeringͰϥϯαʔζͷωοτϫʔΫ͔ΒSSHϩάΠϯ

Slide 15

Slide 15 text

2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS) CircleCIʹΑΔ ίϯςφσϓϩΠʹ͍ͭͯ

Slide 16

Slide 16 text

2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS) CircleCIʹΑΔStg/ຊ൪σϓϩΠʹ͍ͭͯ(ॳظ) ɾCircleCIͷOrbs ɹɾDockerfileͷbuild ɹɾECR΁push ɹɾECSϦϏδϣϯͷߋ৽ ɹɾαʔϏελεΫఆٛͷߋ৽ ɹɾDBϚΠάϨʔγϣϯ ɹɾrspec ɾgit flow ɾdevelopϒϥϯν ɹɾϚʔδ͢ΔͱStgʹϦϦʔε ɾmasterϒϥϯν ɹɾϚʔδ͢Δͱຊ൪ʹϦϦʔε

Slide 17

Slide 17 text

2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS) APIܦ༝ͰͷStg؀ڥͷσϓϩΠ(ݱࡏ) ɾStg؀ڥͷσϓϩΠ ɹɾgithub flow ɹɾγΣϧεΫϦϓτ ɹɹɾ೚ҙͷϒϥϯνΛࢦఆ ɾૉૣ͘σϓϩΠ͕Մೳ ɹɾ։ൃޮ཰͕Ξοϓ ɾTerraform CI؀ڥΛ࣮૷ $ sh deploy.sh ԼهͷΑ͏ʹϒϥϯνΛࢦఆ࣮ͯ͠ߦ͍ͯͩ͘͠͞ɻ (ྫ) sh deploy.sh ϒϥϯν໊ $ sh deploy.sh fix-nginx { "number" : 74, "state" : "pending", "id" : "xxxxxx-xxxxx-xxxxx-xxx-xxxxxxxx", "created_at" : "2020-08-27T06:14:43.973Z" } ϒϥϯν໊/ fix-nginx ͷStgσϓϩΠΛ։࢝͠·ͨ͠!

Slide 18

Slide 18 text

2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS) όονͷ࣮૷ʹ͍ͭͯ

Slide 19

Slide 19 text

2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS) ECS Scheduled TasksʹΑΔόον࣮૷ʹ͍ͭͯ ɾࠓ·Ͱ ɹɾgem whenever ɹɾschedule.rb ɾݱࡏ ɹɾECS Scheduled Tasks ɹɹɾCloudWatchͷΠϕϯτϧʔϧ ɹɹɾTerraformԽ { "containerOverrides": [ { "name": "HogeWorker", "command": ["bundle","exec","rails","runner","HogeWorker.new.execute"] } ] }

Slide 20

Slide 20 text

2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS) ϩάʗίϯςφ؂ࢹ ʹ͍ͭͯ

Slide 21

Slide 21 text

2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS) ϩά/ίϯςφ؂ࢹʹ͍ͭͯ ɾΞΫηε/ΞϓϦϩάɺRDS؂ࠪ/Τϥʔϩά ɹɾCloudWatch Logsʹ ɹɾࠓ·Ͱ ɹɹɾLambdaͰS3ʹγϯΫɹɹ ɹɹɾPythonͰ࣮૷͍ͯͨͨ͠Ίӡ༻ίετΞοϓ ɹɾࠓճ ɹɹɾAmazon Kinesis Data FirehoseͰS3ʹू໿ ɹɹɾTerraformԽ ɾ؂ࢹ ɹɾMackerel→DatadogʹҠߦ ɹɾλεΫఆٛʹdatadog-agentΛಈ࡞ͤ͞ΔΑ͏ʹ ɹɾcpu:10ɺmemory:256 TerraformԽ

Slide 22

Slide 22 text

2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS) ·ͱΊ

Slide 23

Slide 23 text

2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS) ·ͱΊ ɾγϯϓϧͳߏ੒Ͱ࣮ݱͰ͖ͨ ɾখ͍͞αʔϏε͔ΒECS/FargateԽத ɾDockerΠϝʔδͱλεΫఆٛͰӡ༻Մೳ ɾॳΊͯίϯςφຊ൪ӡ༻͢Δʹ͸͔ͳΓϋϚΔ ɹɾϔϧενΣοΫ͕௨Βͳ͍ͱίϯςφ͕མͪͨΓ ɹɾσϓϩΠͷ࣮૷͕େม ɹɾLinuxྗ͕ࢼ͞ΕΔ ɾࠓޙ ɹɾRuby2.7.1/Rails6΁ͷόʔδϣϯΞοϓ ɹɾίϯςφͷ੬ऑੑݕ஌ (Trivy) ɹɾσϓϩΠ͕10෼͔͔ΔͷͰվળ ɹɾChatOpsͰͷϦϦʔε ɹɾDatadogͰϩά࿈ܞ ɹɾϥϯαʔζຊՈ΋ίϯςφҠߦʹνϟϨϯδ

Slide 24

Slide 24 text

2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS) SREٻΉʂʂ ECS/Fargate/PHPͰͷ؀ڥΛ͓࿩͠·͢ʂ

Slide 25

Slide 25 text

2020/9/18 ʲΞιϏϡʔ×ϥϯαʔζʳAWSͰͷΦʔέετϨʔγϣϯπʔϧͷ׆༻ࣄྫ(EKS vs ECS)