Slide 1

Slide 1 text

ΤϯδχΞ޲͚SaaSΛࢧ͑Δ Infrastructure as Code YAP(achimon)C::Asia Hachioji 2016 Day2

Slide 2

Slide 2 text

ࣗݾ঺հ • ౉ᬒҰਅ (@wata727_) • Engineer in Actcat, Inc.
 ΠϯϑϥدΓαʔόαΠυ

Slide 3

Slide 3 text

࠷ॳʹ

Slide 4

Slide 4 text

ཧ૝ͱݱ࣮

Slide 5

Slide 5 text

ImmutableͰ͋Δ͜ͱͷ೉͠͞ • ࠷ॳ͸Immutable Infrastructureʹ͍ͭͯτʔ Ϋ͢Δͭ΋Γͩͬͨ • ࣮ݱ͢ΔͨΊʹ͸՝୊͕ଟ͗ͨ͢ʢޙड़ʣ

Slide 6

Slide 6 text

ΤϯδχΞ޲͚ SaaS

Slide 7

Slide 7 text

SideCI

Slide 8

Slide 8 text

SideCI ࣗಈίʔυϨϏϡʔ

Slide 9

Slide 9 text

GitHub࿈ܞ

Slide 10

Slide 10 text

https://github.com/integrations/sideci

Slide 11

Slide 11 text

ࠓ೔ͷ͓࿩ • SideCIͷAWSҠߦࣄྫ • Πϯϑϥͷӡ༻ํࣜΛબ୒ͨ͠࿩ • ࣮ݱ͢ΔͨΊͷInfrastructure as Code

Slide 12

Slide 12 text

AWS΁ͷҠߦ

Slide 13

Slide 13 text

Ҏલͷߏ੒

Slide 14

Slide 14 text

ϋΠϒϦοτΫϥ΢υߏ੒ • AWS + GCP • VPNͰ઀ଓͯ͠ωοτϫʔΫΛߏங • Ұํͷϕϯμʔͷো֐ͰαʔϏε͕མͪΔ͜ ͱ͕͋ͬͯɺҰຊԽ͍ͨ͠ͱ͍͏࿩͕͋ͬͨ

Slide 15

Slide 15 text

Ҡߦͷ՝୊

Slide 16

Slide 16 text

ߏ੒؅ཧ͞Ε͍ͯͳ͍ • Ҿ͖ܧ͕Εͨखॱॻ.mdͷΈ • νʔϜ͕εέʔϧ͢ΔͱଐਓԽͷ໰୊Λট͖ ͦ͏ͱ͍͏ผͷ໰୊΋… • ԿΒ͔ͷࣗಈԽ͕ඞཁ

Slide 17

Slide 17 text

ߏ੒؅ཧ͞Ε͍ͯͳ͍ • Ҿ͖ܧ͕Εͨखॱॻ.mdͷΈ • νʔϜ͕εέʔϧ͢ΔͱଐਓԽͷ໰୊Λট͖ ͦ͏ͱ͍͏ผͷ໰୊΋… • ԿΒ͔ͷࣗಈԽ͕ඞཁ Infrastructure as Code Λ΍Δͧʂʂ

Slide 18

Slide 18 text

Πϯϑϥͷ ӡ༻ํࣜͷબ୒

Slide 19

Slide 19 text

Ͳ͏΍ͬͯίʔυԽ͢Δ͔ • ·ͣ͸ΠϯϑϥɺσϓϩΠͷ؅ཧɺӡ༻ΛͲ ͏͢Δ΂͖͔ߟ͔͑ͯΒɺπʔϧΛબ୒͢Δ • PushܕɺPullܕɺImmutable…

Slide 20

Slide 20 text

Pushܕ

Slide 21

Slide 21 text

Pushܕͷӡ༻ɺσϓϩΠ • ΫϥΠΞϯτ͔Β֤αʔόʹϛυϧ΢ΣΞม ߋ΍ΞϓϦέʔγϣϯͷσϓϩΠΛSSHܦ༝ ͳͲͰߦ͏ • Ansible, Itamae, CapistranoͳͲ

Slide 22

Slide 22 text

Pushܕͷӡ༻ɺσϓϩΠ

Slide 23

Slide 23 text

Pushܕͷӡ༻ɺσϓϩΠ

Slide 24

Slide 24 text

ϝϦοτͱσϝϦοτ • ΫϥΠΞϯτͷΈͰಈ࡞͢ΔͷͰαʔόଆʹ ઃఆ͕ෆཁͰ؅ཧָ͕ • αʔόͷ୆਺͕ଟ͔ͬͨΓɺΦʔτεέʔϦ ϯάͰ૿ݮ͢Δͱద༻͕೉͘͠ͳΔ

Slide 25

Slide 25 text

Pullܕ

Slide 26

Slide 26 text

Pullܕͷӡ༻ɺσϓϩΠ • ֤αʔό͕ࣗ෼Ͱඞཁͳϛυϧ΢ΣΞɺΞϓ ϦέʔγϣϯͷมߋΛࣗ෼ࣗ਎ʹద༻͢Δ • Chef, AWS CodeDeploy, StretcherͳͲ

Slide 27

Slide 27 text

Pullܕͷӡ༻ɺσϓϩΠ

Slide 28

Slide 28 text

Pullܕͷӡ༻ɺσϓϩΠ

Slide 29

Slide 29 text

Pullܕͷӡ༻ɺσϓϩΠ

Slide 30

Slide 30 text

ϝϦοτͱσϝϦοτ • ֤αʔό͕੹຿Λ࣋ͭͷͰεέʔϧ͢ΔɺΦʔ τεέʔϦϯάͰ΋౰વ໰୊ͳ͠ • ֤αʔόʹର͢Δ഑෍ݩͱͳΔαʔό͕SPOF ʹͳΓ͕ͪͳͷͰɺ৑௕ԽͳͲߟ͑Δͱϝϯ ςφϯείετ͕ߴ͍

Slide 31

Slide 31 text

Immutable

Slide 32

Slide 32 text

Immutableͳӡ༻ɺσϓϩΠ • ֤αʔό͸࠷ॳ͔ΒมߋࡁΈͰɺมߋΛཁ͢ Δ৔߹ʹ͸αʔό͝ͱഁغ͢Δ • ؔ࿈πʔϧ͸Packer, DockerͳͲ

Slide 33

Slide 33 text

Immutableͳӡ༻ɺσϓϩΠ

Slide 34

Slide 34 text

Immutableͳӡ༻ɺσϓϩΠ

Slide 35

Slide 35 text

ϝϦοτͱσϝϦοτ • ֤αʔό͸׬શʹෳ੡ՄೳͰɺϩʔϧόοΫ ͕༰қʢBlue-Green Deployʣ • ΰʔϧσϯΠϝʔδͷੜ੒ίετ͕ߴ͍

Slide 36

Slide 36 text

Immutableͳ ํࣜͷ࠾༻

Slide 37

Slide 37 text

ΰʔϧσϯΠϝʔδͷϏϧυ • αʔϏεΠϯՄೳͳϚγϯΠϝʔδΛ౎౓ PackerͰϏϧυ͢Δ • αʔϏεΠϯՄೳͰ͋Δ͜ͱ͸PackerͷϏϧ υͷ࠷ޙʹServerspecΛ࣮ߦͯ͠୲อ͢Δ

Slide 38

Slide 38 text

ImmutableͳσϓϩΠ • ৽͍͠ϚγϯΠϝʔδ͝ͱʹαʔόΛBlue- GreenతʹೖΕସ͑Δ • TerraformʹΑΔαʔό࠶഑ஔͷࣗಈԽ • طଘͷϦιʔε͸TerraformingͰநग़

Slide 39

Slide 39 text

αʔόߏஙϑϩʔ QBDLFSCVJMETFSWFSKTPO

Slide 40

Slide 40 text

QBDLFSCVJMETFSWFS KTPO Server ݩʹͳΔ αʔόͷىಈ αʔόߏஙϑϩʔ

Slide 41

Slide 41 text

αʔόߏஙϑϩʔ QBDLFSCVJMETFSWFS KTPO Server αʔόΛߏங QSPWJTJPOFST< \ UZQFTIFMM FYFDVUF@DPNNBOE\\7BST^^TVEP&CBTIF \\1BUI^^\\VTFSAFOWJSPONFOUA^^ TDSJQUT< TDSJQUTSPPU@VQHSBEFTI TDSJQUTSPPU@JOTUBMMTI > ^ ʜ

Slide 42

Slide 42 text

αʔόߏஙϑϩʔ QBDLFSCVJMETFSWFS KTPO Server 4FSWFSTQFDͰ ಈ࡞ςετ

Slide 43

Slide 43 text

αʔόߏஙϑϩʔ QBDLFSCVJMETFSWFS KTPO Server Machine Image αʔό͔ΒϚγϯ ΠϝʔδΛநग़

Slide 44

Slide 44 text

αʔόߏஙϑϩʔ QBDLFSCVJMETFSWFS KTPO Machine Image αʔόΛ࡟আ

Slide 45

Slide 45 text

αʔόߏஙϑϩʔ UFSSBGPSNBQQMZ Machine Image

Slide 46

Slide 46 text

αʔόߏஙϑϩʔ UFSSBGPSNBQQMZ Machine Image ݩʹͳΔϚγϯ ΠϝʔδΛࢦఆ

Slide 47

Slide 47 text

αʔόߏஙϑϩʔ UFSSBGPSNBQQMZ Machine Image Security Group ࢖༻͢ΔηΩϡϦςΟ άϧʔϓΛࢦఆ

Slide 48

Slide 48 text

αʔόߏஙϑϩʔ UFSSBGPSNBQQMZ Machine Image Security Group Server ͦΕͧΕͷઃఆ͔Β αʔόΛىಈ

Slide 49

Slide 49 text

໰୊ൃੜ

Slide 50

Slide 50 text

ΠϝʔδͷϏϧυ͕஗͗͢Δ • 30෼͘Β͍͔͔Δ • σϓϩΠͷ଎౓͕2෼ˠ30෼ʙͱ͔ʹͳΔ • ϦϦʔεʹର͢Δ఍߅ײͷ૿େ

Slide 51

Slide 51 text

σϓϩΠ͚ͩPushܕʹ • σϓϩΠ͸ैདྷ௨ΓCapistrano • ϛυϧ΢ΣΞมߋ࣌ͷΈϚγϯΠϝʔδΛߋ ৽͢ΔΑ͏ʹมߋ

Slide 52

Slide 52 text

Ҡߦ࡞ۀͷ࣮ࢪ

Slide 53

Slide 53 text

ҠߦͷྲྀΕ • ฒྻͰࣄલʹϓϩμΫγϣϯ؀ڥΛՔಇͤ͞ ͓ͯ͘ʢNOT εςʔδϯάʣ • ՄೳͳݶΓɺELBͱRoute53ͷ੾Γସ͚͑ͩͰ τϥϑΟοΫͷྲྀΕΛมߋ͢ΔΑ͏ʹ͢Δ

Slide 54

Slide 54 text

Ҡߦલ

Slide 55

Slide 55 text

Ҡߦޙ

Slide 56

Slide 56 text

ແࣄ׬ྃ

Slide 57

Slide 57 text

Infrastructure as CodeΛಋೖ͢Δ ͱ͍͏͜ͱ

Slide 58

Slide 58 text

ָͳӡ༻Λߟ͑Δ • ྫ͑͹ɺΠϝʔδͷϏϧυʹ͕͔͔࣌ؒΓ͢ ͗ͨΓɺϏϧυͷͨΊʹෳࡶͳ؀ڥΛߏங͢ Δඞཁ͕͋Δͱɺͳ͔ͳ͔ਁಁ͠ͳ͍ • ·ͩ·ͩվળͷ༨஍͋Γ…

Slide 59

Slide 59 text

ن໛ʹ͋ͬͨํ๏ΛબͿ • AutoScalingΛඞཁͱ͠ͳ͍গ਺ͷαʔόͳΒ ͹PushܕͰे෼ͳ͜ͱ΋͋Δ • ͦΕͧΕʹదͨ͠πʔϧ͕͋ΔͷͰɺྲྀߦΓ ഇΓʹ࿭Θ͞Εͳ͍

Slide 60

Slide 60 text

Thank you!