Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ECSのサービスをslack botでデプロイする // ecs-goploy

h3poteto
July 22, 2017

ECSのサービスをslack botでデプロイする // ecs-goploy

「JAWS-UG コンテナ支部 #9」

h3poteto

July 22, 2017
Tweet

More Decks by h3poteto

Other Decks in Technology

Transcript

  1. ࣗݾ঺հ • Akira Fukushimaʢ෱ౡ ໌ʣ • github: h3poteto • twitter:

    h3_poteto • ࢓ࣄɿCrowdWorksʢ࠷ۙ͸ΠϯϑϥपΓ
  2. 3FRVJSFEBSHVNFOUT LcBXTBDDFTTLFZ"84"DDFTT,FZ*%.BZBMTPCFTFUBTFOWJSPONFOUWBSJBCMF"84@"$$&44@,&:@*% TcBXTTFDSFULFZ"844FDSFU"DDFTT,FZ.BZBMTPCFTFUBTFOWJSPONFOUWBSJBCMF"84@4&$3&5@"$$&44@,&: ScSFHJPO"843FHJPO/BNF.BZBMTPCFTFUBTFOWJSPONFOUWBSJBCMF"84@%&'"6-5@3&(*0/ QcQSPpMF"841SPpMFUPVTF*GZPVTFUUIJTBXTBDDFTTLFZ BXTTFDSFULFZBOESFHJPOBSFOPUOFFEFE cBXTJOTUBODFQSPpMF6TFUIF*".SPMFBTTPDJBUFEXJUIUIFDVSSFOU"84JOTUBODF$BOPOMZCFVTFEGSPNXJUIJOBSVOOJOH"84 JOTUBODF*GZPVTFUUIJT BXTBDDFTTLFZBOEBXTTFDSFULFZBSFOPUOFFEFE DcDMVTUFS/BNFPG&$4DMVTUFS

    OcTFSWJDFOBNF/BNFPGTFSWJDFUPEFQMPZ JcJNBHF/BNFPG%PDLFSJNBHFUPSVO FYSFQPJNBHFMBUFTU 'PSNBU<EPNBJO><QPSU><SFQP><><JNBHF><UBH> &YBNQMFTNBSJBEC NBSJBECMBUFTU TJMJOUMNBSJBEC  TJMJOUMNBSJBECMBUFTU QSJWBUFSFHJTUSZDPNSFQPJNBHFUBH 0QUJPOBMBSHVNFOUT %cEFTJSFEDPVOU5IFOVNCFSPGJOTU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VF^ >  MPH$POpHVSBUJPO\ MPH%SJWFSqVFOUE  PQUJPOT\ UBHDSPXEXPSLTTUBHJOHFDTMQ ^ ^ ^ > ͚ͩ͜͜ม͍͑ͨ
  4. $ ./ecs-goploy --help Deploy commands for ECS Usage: ecs-goploy [command]

    Available Commands: help Help about any command service Service deploy to ECS task Run task on ECS version Print the version number Flags: -h, --help help for ecs-goploy Use "ecs-goploy [command] --help" for more information about a command. αʔϏεσϓϩΠ ୯ൃλεΫ࣮ߦ
  5. FDTHPQMPZTFSWJDFŠIFMQ 4FSWJDFEFQMPZUP&$4 6TBHF FDTHPQMPZTFSWJDF<qBHT> 'MBHT D DMVTUFSTUSJOH/BNFPG&$4DMVTUFS FOBCMFSPMMCBDL3PMMCBDLUBTLEFpOJUJPOJGOFXWFSTJPOJTOPU SVOOJOHCFGPSF5*.&065 I

    IFMQIFMQGPSTFSWJDF J JNBHFTUSJOH/BNFPG%PDLFSJNBHFUPSVO FYSFQPJNBHFMBUFTU Q QSPpMFTUSJOH"841SPpMFUPVTF S SFHJPOTUSJOH"843FHJPO/BNF O TFSWJDFOBNFTUSJOH/BNFPGTFSWJDFUPEFQMPZ E UBTLEFpOJUJPOTUSJOH/BNFPGCBTFUBTLEFpOJUJPOUPEFQMPZ'BNJMZ BOESFWJTJPO GBNJMZSFWJTJPO PSGVMM"3/ U UJNFPVUJOU5JNFPVUTFDPOET4DSJQUNPOJUPST&$44FSWJDFGPS OFXUBTLEFpOJUJPOUPCFSVOOJOH EFGBVMU
  6. ecs-goploy service • ಈ͍͍ͯΔECS Serviceͷ৘ใऔಘ • ্هͷ৘ใ͔ΒTask DefinitionΛׂΓग़͢ • Docker

    Imageͷ߲໨͚ͩ৽͍͠ImageͰ্ॻ͖ͯ͠ొ࿥ • ৽͍͠Task DefinitionΛࢦఆͯ͠ update-service૬౰ͷAPIΛୟ͘ • ৽͍͠λεΫ͕ಈ͖ग़͢ͷΛ଴ͭ • ΋͠৽͍͠λεΫ͕ಈ͖ग़͞ͳ͍৔߹ɼݩʑಈ͍͍ͯͨTask Definition Ͱ࠶౓ update-service͠ϩʔϧόοΫ͢Δ
  7. ecs-goploy task • Ҿ਺Ͱ༩͑ΒΕͨTask Definition͕ଘࡏ͢Δ͔֬ೝ • Ҿ਺Ͱ༩͑ΒΕͨTask DefinitionͷDocker Image߲໨͚ͩ৽͠ ͍ImageͰ্ॻ͖ͯ͠ొ࿥

    • ৽͍͠Task DefinitionΛࢦఆͯ͠ run-task ૬౰ͷAPIΛୟ͘ • ৽͍͠λεΫͷ࣮ߦ׬ྃΛ଴ͭ • λεΫͷ࣮ߦ͕ऴྃͨ͠ΒɼͦͷExitCodeʹԠͨ͡ग़ྗΛฦ͢
  8. JNQPSUlHJUIVCDPNDSPXEXPSLTFDTHPQMPZEFQMPZ GVODNBJO \ T FSSEFQMPZ/FX4FSWJDF DMVTUFS TFSWJDFOBNF  OHJOYTUBCMF OJM

     UJNF.JOVUF USVF    JGFSSOJM\ MPH'BUBMG <&3303>W FSS  ^ EFQMPZOFXJNBHF JGFSST%FQMPZ FSSOJM\ MPH'BUBMG <&3303>W FSS  ^ ^
  9. JNQPSUlHJUIVCDPNDSPXEXPSLTFDTHPQMPZEFQMPZ GVODNBJO \ NJHSBUJPOλεΫ࣮ߦ UBTL FSSEFQMPZ/FX5BTL DMVTUFS DPOUBJOFSOBNF OHJOYTUBCMF FDIPIPHF

    TBNQMFUBTL EFpOJUJPO   UJNF.JOVUF    JGFSSOJM\ MPH'BUBM FSS  ^ JG@ FSSUBTL3VO FSSOJM\ MPH'BUBM FSS  ^ MPH1SJOUMO <*/'0>5BTLTVDDFTT  αʔϏεσϓϩΠ T FSSEFQMPZ/FX4FSWJDF DMVTUFS TFSWJDFOBNF OHJOYTUBCMF OJM  UJNF.JOVUF USVF    JGFSSOJM\ MPH'BUBMG <&3303>W FSS  ^ EFQMPZOFXJNBHF JGFSST%FQMPZ FSSOJM\ MPH'BUBMG <&3303>W FSS  ^ ^