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

20200805 GCP Cloud Run

saramune
August 05, 2020

20200805 GCP Cloud Run

GCP Cloud Runで始める簡単モダンなコンテナアプリ開発

saramune

August 05, 2020
Tweet

More Decks by saramune

Other Decks in Technology

Transcript

  1. ϋογϡλάLVNPCFO ࣌։࢝༧ఆͰ͢ɻ͠͹Β͓͘଴ͪԼ͍͞

  2. λΠϜεέδϡʔϧ w JSFUʹ͍ͭͯ w ษڧձ w ࣭ٙԠ౴

  3. () 392 (4 ( ( 10 5 .(

  4. 

  5.       !   

  6. ($1$MPVE3VOͰ࢝ΊΔ ؆୯ϞμϯͳίϯςφΞϓϦ։ൃ $MPVE3VO͔Θ͍͍Α$MPVE3VO

  7. ࣗݾ঺հ w ݹ԰ܒհ w ॴଐJSFUגࣜձࣾDMPVEQBDL w ໾৬։ൃ͕͋ΓͷΠϯϑϥΤϯδχΞ w ࢓ࣄ"84ͱΠνϟΠνϟ w

    झຯυϥϜ
  8. ஫ҙ఺ w ($1ެࣜͷղઆ΍ࢿྉͱࣅͯ·͢ w Ͳ͏ͯ͠΋ࣅͯ͠·͏ʜ w $MPVE3VOʹ໨֮Ίͦ͏ͳํ͸ੋඇެࣜ΋ࢀর͍ͩ͘͞ w ·͡Ͱ$MPVE3VOͷ࿩͚ͩͰ͢ w

    ίϯςφ΍,VCFSOFUFTͷਂ͍࿩͸͠·ͤΜ w ࣭໰౳͸:PVUVCF-JWFͷίϝϯτʹͲ͏ͧʂ w ࢿྉ͸ޙ೔ڞ༗͠·͢
  9. ؆୯ϞμϯͳίϯςφΞϓϦ։ൃ

  10. ؆୯ϞμϯͳίϯςφΞϓϦ։ൃʁ w Έͳ͞·ͷϞνϕʔγϣϯʢ૝૾ʣ w ίϯςφΞϓϦ w ίϯςφ࿩୊͔ͩΒڵຯ͋Δ w ؆୯Ϟμϯͳ w

    ίϯςφͷ࣮ӡ༻ͬͯ೉͍͠Πϝʔδ ,VCFSOFUFTͱ͔ʜ
  11. ίϯςφͱ͸ w ࣮ߦ؀ڥͱϓϩηεΛ࠶ݱՄೳͳঢ়ଶͰݻΊͨ΋ͷ w ͳͥίϯςφʁ w ։ൃͱຊ൪Ͱ؀ڥࠩҟ͕Ͱͳ͍ w Ͳ͜Ͱ΋ಈ͘ʢΦϯϓϨɾΫϥ΢υʣ w

    ܰྔ
  12. ίϯςφͱ͍͑͹,VCFSOFUFTʁ w ίϯςφΛຊ൪؀ڥͰӡ༻͢ΔͨΊͷΤίγεςϜ w ͳͥ,VCFSOFUFTʁ w ࣗಈͰίϯςφ෮چ w ͍͍ײ͡ʹίϯςφ഑උ w

    ϩʔυόϥϯγϯά w ӡ༻͸͏·ΈͭΒΈ
  13. $MPVE3VOΛ࢖͏ͱʁ ࠓ࿩୊ʢʁʣͷίϯςφΞϓϦΛ ,VCFSOFUFTͷ஌ࣝͳ͠ʹ ࠷৽ͷΞʔΩςΫνϟͰຊ൪ӡ༻Ͱ͖Δ

  14. $MPVE3VOΛ࢖͏ͱʁ ࠓ࿩୊ʢʁʣͷίϯςφΞϓϦΛ ,VCFSOFUFTͷ஌ࣝͳ͠ʹ ࠷৽ͷΞʔΩςΫνϟͰຊ൪ӡ༻Ͱ͖Δ

  15. ໨࣍ w $MPVE3VOͱ͸ w $MPVE3VOͷίϯηϓτ w $MPVE3VOͱ$*$% w ͦͷଞτϐοΫ

  16. ໨࣍ w $MPVE3VOͱ͸ w $MPVE3VOͷίϯηϓτ w $MPVE3VOͱ$*$% w ͦͷଞτϐοΫ

  17. $MPVE3VOͱ͸ ࠓ࿩୊ʢʁʣͷίϯςφΞϓϦΛ ,VCFSOFUFTͷ஌ࣝͳ͠ʹ ࠷৽ͷΞʔΩςΫνϟͰຊ൪ӡ༻Ͱ͖Δ

  18. $MPVE3VOͱ͸ w ϑϧϚωʔδυͳ,OBUJWFϕʔεͷαʔόϨείϯϐϡʔτ

  19. $MPVE3VOͱ͸ w ϑϧϚωʔδυͳ,OBUJWFϕʔεͷαʔόϨείϯϐϡʔτ

  20. ,OBUJWFͱ͸ w ,VCFSOFUFTͰͷΞϓϦӡ༻Λॿ͚Δ044 w ,VCFSOFUFTΛ1BB4MJLFʹந৅Խ͢Δ w ։ൃऀ͕zΑΓzίʔυΛॻ͘͜ͱʹઐ೦Ͱ͖Δ

  21. αʔόϨεͱ͸ w αʔό؅ཧΛඞཁͱ͠ͳ͍ΞϓϦέʔγϣϯͷߏஙͱ࣮ߦ w 㱠αʔό͕ͳ͍ɺӡ༻ΤϯδχΞ͕͍Βͳ͍ w ར༻ऀ͕αʔόͷ؅ཧʹϦιʔεΛඅ΍͢ඞཁ͕ͳ͍ ˞$/$'4FSWFSMFTT8IJUFQBQFSWΑΓ

  22. ʢ࠶ܝʣ$MPVE3VOͱ͸ w ϑϧϚωʔδυͳ,OBUJWFϕʔεͷαʔόϨείϯϐϡʔτ

  23. ʢ࠶ܝʣ$MPVE3VOͱ͸ w ϑϧϚωʔδυͳ,OBUJWFϕʔεͷαʔόϨείϯϐϡʔτ ($1͕؅ཧɾӡ༻͢Δ ,VCFSOFUFT ,OBUJWFͳαʔόϨε؀ڥͰ ίϯςφΛಈ͔ͤΔαʔϏε

  24. Կ͕͏Ε͍͠ͷʁ w ,VCFSOFUFTͷ͓कΓΛ͠ͳͯ͘Α͍ w ίϯςφͭ͘Δ͚ͩͰ0,ʂ w ࢖Θͳ͍ͱ͖͸͓͕͔͔ۚΒͳ͍ w ίϯςφ͸UP/εέʔϧ͢Δ w

    ଞ؀ڥ΁ͷࡌͤସ͕͑༰қ w Ͳ͔ͬͪͱ͍͏ͱίϯςφͷ͍͍ͱ͜Ζ
  25. $MPVE3VOϓϥοτϑΥʔϜ w $MPVE3VO ϑϧϚωʔδυ  w ࠓճ͸ͪ͜ΒʹϑΥʔΧε w $MPVE3VOGPS"OUIPT w

    "OUIPT(,&্ʹߏங͞ΕΔ$MPVE3VO w ΑΓࣗ༝౓͕ߴ͍ (16࢖͑ΔͳͲ
  26. ໨࣍ w $MPVE3VOͱ͸ w $MPVE3VOͷίϯηϓτ w $MPVE3VOͱ$*$% w ͦͷଞτϐοΫ

  27. $MPVE3VO ,OBUJWF ͷ֓೦ w αʔϏε w ίϯςφΠϯελϯε w ϦϏδϣϯ

  28. αʔϏε w ࠷্Ґͷ࿦ཧϦιʔε w ಉҰίϯςφΛ·ͱΊͯந৅Խ͢Δ w ΞϓϦͷΤϯυϙΠϯτ )5514 Λఏڙ͢Δ w

    BSVOBQQυϝΠϯ·ͨ͸ΧελϜυϝΠϯ͕બ୒Մೳ w -FU`T&ODSZQUͷ44-ূ໌ॻΛࣗಈͰੜ੒ɺׂΓ౰ͯͯ͘ΕΔ
  29. ίϯςφΠϯελϯε  w <W$16> w PS w ϝϞϦ<.#> w <.#>ʙ<(#>

    w ϑΝΠϧγεςϜಡΈॻ͖Մ w Ͱ΋جຊ͸εςʔτϨεʹ͠·͠ΐ͏
  30. ίϯςφΠϯελϯε  w ੍໿ w -JOVYY@؀ڥ w ͔ͭ؀ڥม਺z1035zʹରͯ͠-JTUFO͢Δ w ΞϓϦଆͰ؀ڥม਺z1035zΛҙࣝ͢Δඞཁ༗Γ

    w ϨεϙϯελΠϜΞ΢τ͸σϑΥϧτ෼ ."9෼
  31. ϦϏδϣϯ w ίϯςφΠϝʔδͱ؀ڥม਺Λ·ͱΊͨ΋ͷ w Πϛϡʔλϒϧ w ϩʔϧόοΫ΍$BOBSZϦϦʔε͕Ͱ͖Δ

  32. ਤͰ͍͏ͱ

  33. $MPVE3VO ,OBUJWF ͷεέʔϦϯά w ಉ࣮࣌ߦ਺ͷ੍ޚ w UP/εέʔϧ

  34. ಉ࣮࣌ߦ਺ͷ੍ޚ w ֤ίϯςφ͕͍ͭ͘ϦΫΤετΛॲཧ͢Δ੍͔ޚՄೳ w ίϯςφ͋ͨΓ࠷େϦΫΤετ·Ͱ w ͪͳΈʹɺ$MPVE'VODUJPOT͸ϦΫΤετίϯςφ w ϦΫΤετͷϦιʔε࢖༻ྔͱ૬ஊͯ͠࠷దͳ஋Λݟ͚ͭΔ

  35. ਤͰ͍͏ͱ

  36. UP/εέʔϧ w Φʔτεέʔϧ w ϦΫΤετΛ͞͹͚Δ͚ͩͷίϯςφ͕উखʹ্ཱ͕ͪΔ w σϑΥϧτ࠷େίϯςφʢ؇࿨Մೳʣ w ϦΫΤετ͕ͳ͘ͳͬͨΒίϯςφ͸΁

  37. ίʔϧυελʔτ໰୊ w ίϯςφʹͳΔίʔϧυελʔτ w ʹͳΔͱ·ͨΠν͔Βίϯςφ࡞Γ௚͕͔͔࣌ؒ͠Δ w ରࡦ w ಉ࣮࣌ߦ਺ͷௐ੔ w

    ίϯςφࣗମΛܰ͘͢Δ w ʢ$MPVE4DIFEVMFSͱ͔Ͱͪΐ͍ͪΐ͍ىಈʣ
  38. ଞͷαʔϏεͱͷൺֱ w "QQ&OHJOF w ϥϯλΠϜ੍໿͋Γɺ؅ཧର৅͸ιʔείʔυ w ϓϩδΣΫτϦʔδϣϯͷറΓ w $MPVE'VODUJPOT w

    ϥϯλΠϜ੍໿͋Γɺ؅ཧର৅͸ιʔείʔυ w Πϕϯτۦಈɺ͋͘·Ͱؔ਺
  39. $MPVE3VO͔͍ͭͲ͜Ζ w "QQ&OHJOF΍$MPVE'VODUJPOTඇରԠͷݴޠΛ࢖͍͍ͨʂ w ίϯςφͳͷͰϥϯλΠϜ੍໿ͳ͠ w طଘͷࢿ࢈Λ༗ޮ׆༻Ͱ͖Δ w ࠓޙΛݟਾ͑ͯίϯςφͰ࣮૷ͯ͠Έ͍ͨʂ w

    Πϯϑϥ໘౗ݟΔඞཁͳ͠ɺεϞʔϧελʔτՄೳ w ,VCFSOFUFT஌Βͳͯ͘΋େৎ෉
  40. %FNP w ($1ίϯιʔϧʹͯαʔϏεͷ࡞੒

  41. ໨࣍ w $MPVE3VOͱ͸ w $MPVE3VOͷίϯηϓτ w $MPVE3VOͱ$*$% w ͦͷଞτϐοΫ

  42. $MPVE3VOͰͷ$*$%

  43. $MPVE#VJME w lαʔόϨεzͰϏϧυͰ͖Δ w $MPVE4PVSDF3FQPTJUPSJFTͷมߋΛτϦΨʔՄೳ w σϓϩΠ΋Մೳ

  44. %FNP w ιʔείʔυॻ͖׵͑ͯQVTIͯ͠มߋ֬ೝ

  45. ໨࣍ w $MPVE3VOͱ͸ w $MPVE3VOͷίϯηϓτ w $MPVE3VOͱ$*$% w ͦͷଞτϐοΫ

  46. ͦͷଞτϐοΫ w ϩΪϯάɺϞχλϦϯά w ྉۚ w ࠷ۙͷ6QEBUF

  47. ϩΪϯάɺϞχλϦϯά w ϦΫΤετϩάɺίϯςφϩά w $MPVE-PHHJOH w ֤छϝτϦΫε $16౳  w

    $MPVE.POJUPSJOH ࡞Γࠐ·ͳͯ͘΋͍͍ײ͡ʹܭଌͰ͖Δ
  48. ྉۚ w "MXBZT'SFF࿮͋Γ w $16ɺϝϞϦɺϦΫΤετɺωοτϫʔΫͷ߹ܭֹ

  49. ࠷ۙͷ6QEBUF  w 5SB⒏D.BOBHFNFOU w ϦϏδϣϯؒͷϩʔϧόοΫɺ#(σϓϩΠ͕Մೳʹ w ΋ͱ΋ͱ,OBUJWFͷػೳ

  50. ࠷ۙͷ6QEBUF  w 4FSWFSMFTT71$"DDFTTDPOOFDUPS w 71$಺ͷϦιʔε .FNPSZTUPSFͳͲ ʹΞΫηεՄೳʹ

  51. ࠷ۙͷ6QEBUF  w 4FSWFSMFTT/&(ରԠ #FUB  w ϩʔυόϥϯαͷഎޙʹ഑උՄೳʹ w αʔϏεͷҰ෦͚ͩ$MPVE3VOɺΈ͍ͨͳ͜ͱ͕Մೳ

  52. ࠷ۙͷ6QEBUF  w ؇΍͔ͳϩʔϧΞ΢τ w ৽نϦϏδϣϯʹྲྀ͢τϥϑΟοΫͷׂ߹Λ੍ޚՄೳʹ w ৽نϦϏδϣϯσϓϩΠ w λά෇͖63-͕ੜ੒͞ΕΔ

    w τϥϑΟοΫͷͷΈ৽نϦϏδϣϯʹ޲͚Δ gcloud beta run deploy myservice —image image:f5bd774 --no-traffic --tag green https://green---myservice-abcdef.a.run.app gcloud beta run services update-traffic myservice --to-tags green=1
  53. ·ͱΊ w $MPVE3VOɺ͍Ζ͍ΖָͰ͢ w Ϛωʔδυͳ,OBUJWFʹίϯςφ࡞ͬͯஔ͚ͩ͘ w ূ໌ॻɺεέʔϧ౳ඞཁͳػೳ΋͓·͔ͤ w ৽͍͠ΞϓϦ΍৽ػೳ͚ͩ೚ͤͯΈͯ͸

  54. ͓·͚ʢ࣮૷ྫʣ w γϯϓϧͳ8FCΞϓϦ େࡕͷۭ͖ԻָελδΦݕࡧ  w ϑϩϯτͱόοΫ ελδΦݕࡧ෦ ͸ผͷ$MPVE3VO w

    3&45"1*Ͱ઀ଓ w ϚΠΫϩαʔϏεͬΆ͍͜ͱ͕͔ͨͬͨ͠ w ࠓ͸ޙչ͍ͯ͠Δʢແཧʹͪ͗Δͱ͠ΜͲ͍ʣ w $*$%ɺϞχλϦϯά΋׬උ w <&3303>Ͱͻ͔͚ͬͯΞϥʔτ
  55. $MPVE3VO͔Θ͍͍Α͓͡͞Μ

  56.  c a d

  57. Ξϯέʔτͷ͝ڠྗΛ͓Ͷ͕͍͠·͢