Kubectl Apply 2019: 闇の魔術に対する防衛術 / Kubectl Apply 2019: Defence Against the Dark Arts

Kubectl Apply 2019: 闇の魔術に対する防衛術 / Kubectl Apply 2019: Defence Against the Dark Arts

A talk at Kubernetes Meetup Tokyo #20 @ Google Japan Office

Ad22fcf5773b906c08330f4d57242212?s=128

Kohei Ota

June 18, 2019
Tweet

Transcript

  1. ,VCFDUM"QQMZ %FGFOTF"HBJOTUUIF%BSL"SUT !@JOEVDUPS@ ,VCFSOFUFT.FFUVQ5PLZP

  2. ,VCFDUM"QQMZ ҋͷຐज़ʹର͢Δ๷Ӵज़ !@JOEVDUPS@ ,VCFSOFUFT.FFUVQ5PLZP

  3. ,VCFDUM"QQMZ ҋͷຐज़ʹର͢Δ๷Ӵज़ !@JOEVDUPS@ ,VCFSOFUFT.FFUVQ5PLZP

  4. ࣗݾ঺հ w 5XJUUFS!@JOEVDUPS@ w (JU)VC!JOEVDUPS w .-0QT&OHJOFFS!;0;05FDI w 'BWPSJUFIPVTF)V⒐FQV⒎

  5. ηογϣϯͷΞδΣϯμ w ,VCF$PO&6ݸਓతؾʹͳͬͨৼΓฦΓ NJO  w ຊ୊ͷ3FDBQ NJO  w

    ֶͼΛӡ༻ʹಋೖ͢Δʹ͸ NJO  w ·ͱΊ
  6. ,VCF$PO&6 w ৔ॴεϖΠϯ όϧηϩφ w ࢀՃऀ਺ਓҎ্ w γΞτϧਓ ͷ଴ͪϦετ 

    w ίϖϯϋʔήϯਓ
  7. ,VCF$PO&6

  8. None
  9. None
  10. None
  11. None
  12. None
  13. None
  14. None
  15. ,VCFDUM"QQMZ ҋͷຐज़ʹର͢Δ๷Ӵज़

  16. ҋͷຐज़ʁ

  17. ҋͷຐज़ʁ

  18. ຊ୊ͷલʹͭ֬ೝ

  19. ,VCFDUMBQQMZͷཪଆͰ͸ Կ͕ى͍ͬͯ͜Δͷ͔

  20. ,VCFSOFUFTΞʔΩςΫνϟͷ ͓͞Β͍

  21. None
  22. w ͢΂ͯͷϦΫΤετ͸"1*4FSWFSΛܦ༝ w FUDE͕4JOHMF4PVSDFPG5SVUI w $POUSPMMFS.BOBHFS͔Βݺͼग़͞Εͨ$POUSPMMFS͕࣮ࡍͷ ॲཧʢϦιʔεͷ࡞੒΍࡟আʣΛߦ͏

  23. IUUQTHJUIVCDPNKBNJFIBOOBGPSE XIBUIBQQFOTXIFOLT

  24. IUUQTTQFBLFSEFDLDPNEBJLVSPTBXB LVCFSOFUFTTPVSDFDPEFSFBEJOH

  25. ͜Ε·Ͱͷ,VCFDUMBQQMZͷಈ࡞ w "QQMZ3FTPVSDF$POpHΛ༻͍ͨʮએݴతͬΆ͍ʯϦιʔε؅ཧ w "QQMZͰ౉͞Εͨ$POpHΛύʔε w ,VCFSOFUFT্ʹ࣮ࡏ͢ΔϦιʔεΛಡΈऔΓ w $SFBUFɺ1BUDIɺ%FMFUFͳͲͷ໋ྩతͳ"1*ϦΫΤετΛߏங

  26. None
  27. એݴతͳΠϯϑϥ؅ཧ WT ໋ྩతͳ"1*ͷݺͼग़͠ͱ͍͏࣮ଶ

  28. None
  29. None
  30. IUUQTRJJUBDPNULVTVNJ JUFNTCGDFGC

  31. ઃఆ߲໨ͷଥ౰ੑʁ w ,VCFSOFUFTʹ౉͢$POpH͕ਖ਼͍͜͠ͱΛ୭͕Ͳ͏΍ͬͯ୲อ͢Δͷ͔ w ESZSVOΛ࢖͏ʁ w ΫϥΠΞϯταΠυʹͯɺ"1*ʹ࣮ࡍʹ౉͢ϦΫΤετΛੜ੒͢ΔίϚϯυ w ͍ΘΏΔʮESZSVOʯͱҧ͍ɺ"1*αʔόͱ͸΍ΓͱΓ͠ͳ͍ w

    PΦϓγϣϯͰZBNMܗࣜͷग़ྗ͸Ͱ͖Δ͕ɺ΍͸ΓϦΫΤετ͕Ͳ͏ͳΔ ͔ΛγϛϡϨʔγϣϯͰ͖ΔΘ͚Ͱ͸ͳ͍ͷͰɺ๻͕ͨͪຊདྷཉ͔ͬͨ͠ ESZSVOͱ͸ҧ͏
  32. None
  33. ˞ࠇຐज़ʹ͖ͭ Α͍͜ͷΈΜͳ͸ਅࣅ͠ͳ͍ͰͶʂ

  34. "QQMZ͢Δ௚લʹϢʔβʔ͕ ,Tʹظ଴͢ΔΞϓϩʔν w ԼهͭΛ·ͱΊͯEJ⒎Λ͍͍ײ͡ʹද͍ࣔͨ͠ w ݱଘ͢ΔϦιʔε w ࠷ޙʹద༻ͨ͠$POpH w ͜Ε͔Βద༻͍ͨ͠$POpH

    w ࠩ෼ͷΈਖ਼͘͠1BUDIϦΫΤετΛૹΓ͍ͨ
  35. "QQMZ͢Δ௚લʹϢʔβʔ͕ ,Tʹظ଴͢ΔΞϓϩʔν w ԼهͭΛ·ͱΊͯEJ⒎Λ͍͍ײ͡ʹද͍ࣔͨ͠ w ݱଘ͢ΔϦιʔε w ࠷ޙʹద༻ͨ͠$POpH w ͜Ε͔Βద༻͍ͨ͠$POpH

    w ࠩ෼ͷΈਖ਼͘͠1BUDIϦΫΤετΛૹΓ͍ͨ
  36. ៉ྷʹϦΫΤετΛੜ੒͢Δ ʹ͸Ͳ͏͢΂͖ͳͷ͔

  37. ҆͝৺͍ͩ͘͞ʂ ,VCFSOFUFTଆͰରԠ͞Ε·ͨ͠

  38. ,VCFSOFUFTͷมߋ w 4FSWFSTJEFBQQMZ w "QQMZͷΤϯυϙΠϯτʹ৽ͨͳϑϥά͕௥Ճ w ௚ۙͰద༻͞Εͨ$POpHͱͷ%J⒎ΛऔΕΔΑ͏ʹ w ΫϥΠΞϯταΠυͰ໋ྩΛ͝ʹΐ͝ʹΐ͠ͳͯ͘Α͘ͳͬͨ

  39. ,VCFSOFUFTͷมߋ w ΫϥΠΞϯταΠυ w ࣮ࡍͷ,VCFSOFUFTϢʔβ͸એݴతʹϦιʔεΛ؅ཧ͍ͨ͠ w ϦιʔείϯϑΟάΛू໿ w $POpH.BQ΍4FDSFUTͳͲͷ୯Ұʹ࡞ΒΕΔϦιʔε w

    ˠ$-*πʔϧʹ,VTUPNJ[FΛ౷߹
  40. ,VCFSOFUFTͷมߋ w ,VCFDUMEJ⒎ w 4FSWFSTJEFBQQMZͱESZSVOͷΞϓϩʔνΛ౷߹ w ͭ·Γɺݱଘ͢ΔϦιʔε͕ߟྀ͞ΕͨEJ⒎͕ग़ྗ͞ΕΔ w ࣍ʹBQQMZ͢Δͱ͖ʹͲͷΑ͏ͳ݁ՌʹͳΔ͔͕໌֬ʹ

  41. ·ͨ·ͨ͊ɺͲ͏ͤ·ͩ ϦϦʔε·Ͱ͔͔࣌ؒΔΜͰ͠ΐʁ

  42. ͍ͭ࢖͑ΔΑ͏ʹͳΔͷ͔ w ,VCFDUMEJ⒎ w ͔Β$-*ʹ௥Ճ͞Ε͓ͯΓར༻Մೳ w "1*4FSWFSଆͷόʔδϣϯࣗମ΋ରԠ͕ඞཁ

  43. ͍ͭ࢖͑ΔΑ͏ʹͳΔͷ͔ w $-*ʹ͓͚Δ,VTUPNJ[Fͷ౷߹Խ w ͔Β$-*ʹ௥Ճ͞Ε͓ͯΓར༻Մೳ w ͪ͜Β͸७ਮͳ$MJFOU4JEF'FBUVSFͳͷͰɺαʔόଆͷ όʔδϣϯʹґଘͤͣར༻͕Մೳ

  44. ࠓޙͷϩʔυϚοϓ͸ʁ w 1SVOFͷվળ w ཁ͢Δʹ͍͍ײ͡ʹϦιʔεΛ࡟আ͢Δํ๏ w ੜ੒͞Εͨ$POpH.BQ΍4FDSFUTͷ͓૟আػೳΛ͚ͭΔ w 4UBUVT w

    طଘͷϦιʔελΠϓ΍$3%ͳͲʹର͢Δએݴతมߋͷ ίϯτϩʔϥىಈ࣌ͷϒϩοΩϯάΛαϙʔτ
  45. ࠓޙͷϩʔυϚοϓ͸ʁ w ,VCFDUM,VTUPNJ[F w ౷߹͞Εͨࠓޙʹ͍ͭͯ΋,VTUPNJ[FࣗମͷΞοϓετ ϦʔϜ։ൃ͸ܧଓ w ,VTUPNJ[Fଆ͕,VCFDUMଆΑΓ΋ৗʹ࠷৽ w ,VCFDUMͷϓϩδΣΫτ͸LVCFSOFUFTLVCFDUMͷϦϙδ

    τϦʹҠߦத
  46. ·ͱΊ w ,VTUPNJ[Fͷ౷߹Խʹؔͯ͠͸ར༻ࣗମ͸೚ҙ w طʹಋೖ͍ͯ͠Δਓʹͱͬͯ͸ϥοΩʔ w EJ⒎͕࢖͑ΔΑ͏ʹͳͬͨͷͰɺͲ͜ͰͲΜͳࠩ෼͕૸Δ͔͕໌֬ʹ w ʢݸਓతʹʣṖͷࠩ෼͕ൃੜͯ͠υΩϡϝϯτړΔ͕࣌ؒݮͬͨ

  47. ͱ͋Δ,VCFSOFUFTར༻ऀ͔ΒΈͨɺ ຊηογϣϯʹର͢Δֶͼͱ࣮ફ

  48. ͱ͋Δ,VCFSOFUFTར༻ऀ͔ΒΈͨɺ ຊηογϣϯʹର͢Δֶͼͱ࣮ફ

  49. "QQMZͷා͞ w ਖ਼௚Ͳ͏΍ͬͯಈ͍ͯΔͷ͔Α͘Θ͔Βͣ࢖ͬͯΔʢʣ w Կ΋ࠩ෼ൃੜͯ͠ͳ͍͸ͣͳͷʹ$POpHVSFEʹͳͬͯ1PE ͕5FSNJOBUJOHʹͳͬͨ͜ͱ͕͋Δ w Ϋϥελͱ͔/BNFTQBDFؒҧ͑ͯ"QQMZͪ͠ΌͬͯΞϨͳ ͜ͱʹͳͬͨ͜ͱ͕͋Δ

  50. ZBNMϑΝΠϧͷ؅ཧ w ؀ڥ͝ͱʹ͍͍ͪͪ࡞Δͷ͸ΊΜͲ͍͘͞ w Լखʹڞ௨Խ͢Δͱม਺ͷ؅ཧͱ͔େม w ઃܭϛεΔͱҋುʹͳΓ͕ͪ w ؀ڥYαʔϏε਺ͰͲΜͲΜ਺͕૿͍͑ͯ͘

  51. P kubernetes @MELANIECEBULA kubectl apply Production Deployment Canary Deployment Production

    ConfigMap Canary ConfigMap Production Service Canary Service kubernetes cluster Dev Deployment Dev ConfigMap Dev Service kubernetes config files lots of boilerplate repetitive by environment resources environments
  52. :".-ͷzਖ਼͍͠z؅ཧํ๏ ͕Θ͔Βͳ͍

  53. None
  54. Πϯϑϥߏ੒؅ཧͷύΠϓϥΠϯ w ͦ΋ͦ΋,VCFSOFUFT͕:".-Λ࢖͍ͬͯΔͷ͸
 એݴతʹߏ੒؅ཧ͕Ͱ͖Δʢͱ͞Ε͍ͯΔʣ͔Β w :".-ͷ೰Έͱ͍͏ΑΓ͸ɺΠϯϑϥߏ੒؅ཧͷ೰Έ w ߏ੒؅ཧͷͲ͜ʹ೰ΈΛ๊͍͑ͯΔ͔ w ূ੻Λ࢒͍ͨ͠

    w ώϡʔϚϯΦϖϨʔγϣϯΛݮΒ͍ͨ͠ w ࣗಈతʹ൓өͯ͠΋੾Γ໭͕͠Ͱ͖ΔΑ͏ͳ࢓૊Έʹ͍ͨ͠
  55. Θ͕··ϘσΟͰ ͢Έ·ͤΜ

  56. ੈͷதʹ͸͍͔ͭ͘ͷํ๏͕͋Δ w (JU0QT w 8FBWFXPSLT͕ఏএͨ͠ɺ(JUΛ4JOHMF4PVSDFPG5SVUI ͱ͢ΔࣗಈԽϑϩʔͷܗ w 1VMMܕͷ$%͕(JUͷεςʔλεΛఆظతʹνΣοΫͯ͠؀ ڥʹ൓ө͢Δ w

    (JUʹ1VTIͯ͠ຊ൪ʹࣗಈ൓ө͢Δ΍ͭ͸$*0QT
  57. ʁʁʁʮ$*0QT͸ΞϨͳͷͰ (JU0QTʹ͠Α͏ͥʯ

  58. Θ͔ΔΜ͚ͩͲɾɾɾ w (JU0QTେมͦ͏ w $%πʔϧΛ৽͘͠ݐͯͳ͍ͱ͍͚ͳ͍ w Πϯϑϥͷߏ੒؅ཧΛ؅ཧ͢ΔͨΊͷ$%πʔϧͷߏ੒؅ཧ w ͿͬͪΌ͚ͦΜͳن໛େ͖͘ͳ͍͠ͳ͋

  59. ͳʹʁ ,VCFDUMʹEJ⒎͕ೖΔͩͱ

  60. ,VCFDUMEJ⒎͕΋ͨΒ͢ޫ w ϝϦοτ w $*πʔϧ಺ͰEJ⒎ͱͬͯϩά͕࢒ͤΔΑ͏ʹͳͬͨ w ࠷୹Ͱߦ௥Ճ͢Δ͚ͩͳͷͰΒͪ͘Μ w σϝϦοτ w

    ࠜຊతͳ໰୊͕ղܾ͢ΔΘ͚Ͱ͸ͳ͍ w ϩʔϧόοΫͳͲ͸૬มΘΒͣҰఆͷͭΒΈ͕͋Δ w ,VCFSOFUFTͷΤίγεςϜͰΧόʔ͍͔ͯ͘͠͠ͳ͍
  61. ͏ʔΜͰ΋ɺZBNM͍ͬͺ͍͋Δͱ؅ཧ େมʹͳΔ͠EJ⒎࢖͏γʔϯ࣮͸ݶΒΕ ͯΔΜ͡Όͳ͍͔ͳ͋ʁ

  62. ͑ʁ ,VCFDUMʹ,VTUPNJ[F͕ೖΔͩͱ

  63. ,VTUPNJ[Fͷ౷߹͕΋ͨΒ͢ޫ w ϝϦοτ w ܧঝܕͷςϯϓϨʔτ͕ॻ͚Δ w ϕʔε͸ͭͷ··ʹɺࣗ༝ʹ֦ு֤ͯ͠؀ڥɾαʔϏεʹల։͕Մೳ w %3:͗͢Δڞ௨Խͷ੍ݶ͕ͳ͍ w

    σϝϦοτ w ࠜຊతʹϑΝΠϧ਺͕࡟ݮͰ͖ΔΘ͚Ͱ͸ͳ͍ w ग़ྗ݁Ռ͕Ͳ͔͜ʹ࢒ΔΘ͚͡Όͳ͍
  64. ͜ͷͭͷมߋ͕΋ͨΒ͢ޫ w ͦͷ࣌ʑʹ͓͚ΔZBNMͷग़ྗ݁Ռ͕อূ͞ΕΔ ,VTUPNJ[F (JU  w ࣮ࡍʹ࣮ߦ͞Εͨͱ͖ͷ൓өঢ়گ͕Θ͔Δ EJ⒎ 

    w طଘͷߏ੒ʹରͯ͠େ͖͘Ճ͑Δมߋ͕ͳ͍ w ࣮֬ʹطଘͷߏ੒ΑΓ͸ϦεΫΛݮΒͭͭࣗ͠ಈԽΛ࣮ݱͰ͖Δ
  65. ౴͑ͷͳ͍͜ͷઓ͍ʹ ྑ͍ϥΠϯ͕Ҿ͚ͦ͏ʢʁʣ

  66. ݁Ռߟ͑ͨߏ੒ w ߏ੒ w $*0QT ,VTUPNJ[F EJ⒎Ͱ͕Μ͹Δ w બఆཧ༝ w

    ͦΜͳʹن໛͕େ͖͘ͳ͍ w (JU0QT͕Μ͹ΕΔ΄Ͳӡ༻νʔϜ͕੒ख़͍ͯ͠ͳ͍ w 4JNQMFJTCFTU
  67. ͜͜Ͱ͍͍ײ͡ͷΞʔΩςΫνϟਤ Λγϡοͱग़͢

  68. ແ೦ʢ࣌ؒ଍Γͳ͔ͬͨʣ

  69. ·ͱΊ w ,VCFSOFUFTͷΞʔΩςΫνϟ͸ͬ͘͟ΓͰ΋஌͓ͬͯ͘΂͖ w ࣗ෼ͷӡ༻ίετʹݟ߹͏౒ྗΛ͢Δ w "DUJWF%FWFMPQNFOUͳϓϩδΣΫτ͸6QTUSFBNͷػೳʹؔ͢Δ ৘ใΛੵۃతʹऔΓೖΕ͍ͯ͘΂͖

  70. ࠷ޙʹ͜Ε͚ͩݴ͍͍ͨ

  71. ,VCFSOFUFTZBQQB OBONPXBLBSBO

  72. 5IBOLZPVGPS ZPVSBUUFOUJPO