コンテナオーケストレーションにとどまらないKubernetesの魅力 / osc19tk_yukirii_k8s

0afd6627ba803c260fad3387f90c9d15?s=47 yukirii
November 24, 2019

コンテナオーケストレーションにとどまらないKubernetesの魅力 / osc19tk_yukirii_k8s

0afd6627ba803c260fad3387f90c9d15?s=128

yukirii

November 24, 2019
Tweet

Transcript

  1. ίϯςφΦʔέετϨʔγϣϯʹ ͱͲ·Βͳ͍ ,VCFSOFUFTͷັྗ גࣜձࣾαΠόʔΤʔδΣϯτ ٕज़ຊ෦αʔϏεϦϥΠΞϏϦςΟάϧʔϓ ۅҪ༞थ 0QFO4PVSDF$POGFSFODF5PLZP'BMM!໌੕େֶ 

  2. "CPVUNF 2 ,*3**:VLJ *OGSBTUSVDUVSF&OHJOFFS גࣜձࣾαΠόʔΤʔδΣϯτ ٕज़ຊ෦αʔϏεϦϥΠΞϏϦςΟάϧʔϓ $FSUJpFE,VCFSOFUFT"ENJOJTUSBUPS  ZVLJSJJ ZVLJSJJ@

  3.  ,VCFSOFUFTͷಛ௃ͱಈ࡞Λ͓͞Β͍ w %FDMBSBUJWF"1* w 3FDPODJMJBUJPO-PPQ w $VTUPN3FTPVSDF$VTUPN$POUSPMMFS  ,VCFSOFUFTͷಛ௃Λ׆༻͢Δ

    w ,VCFSOFUFT0QFSBUPS w $MVTUFS"1*  ·ͱΊ 3
  4. ,VCFSOFUFTͷಛ௃ͱಈ࡞ ͓͞Β͍ ಛ௃%FDMBSBUJWF એݴతͳ "1*ͱઃఆ w Ϣʔβ͸γεςϜͷl๬·͍͠ঢ়ଶz EFTJSFETUBUF Λఆٛ w

    "1*Λհͯ͠Ϋϥελʹొ࿥ˠϦιʔεΦϒδΣΫτ͕࡞੒͞ΕΔ Service apiVersion: v1 kind: Service metadata: name: my-service spec: type: LoadBalancer ports: - protocol: TCP port: 80 targetPort: 8080 selector: app: my-app my-service.yaml ྫ4FSWJDF UZQF-PBE#BMBODFS  Ϣʔβ͸ެ։͢ΔΞϓϦέʔγϣϯϓϩτίϧϙʔτ൪߸Λࢦఆ create/modify object Kubernetes API kubectl apply Cloud
  5. ,VCFSOFUFTͷಛ௃ͱಈ࡞ ͓͞Β͍ ಛ௃ίϯτϩʔϥʹΑΔ3FDPODJMJBUJPO-PPQ ௐ੔ϧʔϓ  w ,VCFSOFUFTΫϥελ͸༷ʑͳίϯτϩʔϥͷ૊Έ߹ΘͤͰಈ͍͍ͯΔ w ֤ίϯτϩʔϥ͸ࣗ਎ͷ୲౰͢ΔϦιʔεΦϒδΣΫτΛಡΈऔΓ ఆٛ͞Εͨཁ݅Λຬͨ͢Α͏ʹϦιʔεͷ࣮ମ

    BDUSVBMTUBUF Λૢ࡞ Service LB Service
 Controller watch create/modify 0CTFSWF %J⒎ "DU Cloud ΦϒδΣΫτͷ ߋ৽Λݕ஌ ΦϒδΣΫτͷ಺༰ͱ ࣮ࡍͷϦιʔεͷঢ়ଶΛ ൺֱ ࠩ෼͕͋Δ৔߹͸ ࣮ࡍͷϦιʔεΛ मਖ਼͢Δ
  6. ,VCFSOFUFTͷಛ௃ͱಈ࡞ ͓͞Β͍ ಛ௃ϢʔβಠࣗͷϦιʔείϯτϩʔϥΛ࣮૷Ͱ͖Δ w $VTUPN3FTPVSDF w ϢʔβʹΑͬͯಠࣗʹఆٛ͞ΕͨϦιʔε w $VTUPN3FTPVSDF%FpOJUJPOT $3%T

    ʹΑͬͯLT"1*Λ֦ு͢Δͱѻ͑Δ w $VTUPN$POUSPMMFS w ϢʔβʹΑͬͯಠࣗʹ࣮૷͞Εͨίϯτϩʔϥ $VTUPN3FTPVSDF %FpOJUJPO %BUBCBTF$MVTUFS $POUSPMMFS $VTUPN$POUSPMMFS %BUBCBTF$MVTUFS $VTUPN3FTPVSDF kind: DatabaseCluster kind: CustomResourceDefinition spec: names: kind: DatabaseCluster Kubernetes API watch Reconcile
 Loop
  7. ,VCFSOFUFTͷಛ௃Λ׆༻͢Δ ಛ௃%FDMBSBUJWF"1*ͱઃఆ ಛ௃ίϯτϩʔϥʹΑΔ3FDPODJMJBUJPO-PPQ ಛ௃ಠࣗͷϦιʔείϯτϩʔϥΛ࣮૷Ͱ͖Δ ,VCFSOFUFT0QFSBUPS ΞϓϦέʔγϣϯ΍Ϋϥ΢υϦιʔεΛࣗ཯؅ཧ $MVTUFS"1* ,TΫϥελͰ,TΫϥελΛ࡞ͬͯ؅ཧ͢Δ ୯ʹίϯςφΛσϓϩΠ͢Δ͚ͩͰͳ͘ ͜ΕΒͷಛ௃Λ׆͔ͨ͠։ൃɾӡ༻Λ͢Δʹ͸ʜ

  8. ,VCFSOFUFT0QFSBUPS 8 ಛఆͷΞϓϦέʔγϣϯΛ,VCFSOFUFT্Ͱ࣮ߦɾ؅ཧ͢ΔͨΊͷ ιϑτ΢ΣΞ ίϯτϩʔϥ  w த਎͸$3%ͱΧελϜίϯτϩʔϥ w ΞϓϦέʔγϣϯͷӡ༻্ͷφϨοδΛίϯτϩʔϥͱ࣮ͯ͠૷

    w ίϯτϩʔϥࣗମ΋ίϯςφԽ͞ΕͨΞϓϦͱͯ͠,VCFSOFUFT্Ͱಈ࡞͢Δ %BUBCBTF$MVTUFS $POUSPMMFS $VTUPN$POUSPMMFS %BUBCBTF$MVTUFS $VTUPN3FTPVSDF watch Reconcile
 Loop %BUBCBTF$MVTUFS
  9. ,VCFSOFUFT0QFSBUPS 9 ಛఆͷΞϓϦέʔγϣϯΛ,VCFSOFUFT্Ͱ࣮ߦɾ؅ཧ͢ΔͨΊͷ ιϑτ΢ΣΞ ίϯτϩʔϥ  w த਎͸$3%ͱΧελϜίϯτϩʔϥ w ΞϓϦέʔγϣϯͷӡ༻্ͷφϨοδΛίϯτϩʔϥͱ࣮ͯ͠૷

    w ίϯτϩʔϥࣗମ΋ίϯςφԽ͞ΕͨΞϓϦͱͯ͠,VCFSOFUFT্Ͱಈ࡞͢Δ %BUBCBTF$MVTUFS $POUSPMMFS $VTUPN$POUSPMMFS %BUBCBTF$MVTUFS $VTUPN3FTPVSDF watch Reconcile
 Loop %BUBCBTF$MVTUFS ྫσʔλϕʔεγεςϜ ϊʔυ਺Λͭʹઃఆ
  10. ,VCFSOFUFT0QFSBUPS 10 ಛఆͷΞϓϦέʔγϣϯΛ,VCFSOFUFT্Ͱ࣮ߦɾ؅ཧ͢ΔͨΊͷ ιϑτ΢ΣΞ ίϯτϩʔϥ  w த਎͸$3%ͱΧελϜίϯτϩʔϥ w ΞϓϦέʔγϣϯͷӡ༻্ͷφϨοδΛίϯτϩʔϥͱ࣮ͯ͠૷

    w ίϯτϩʔϥࣗମ΋ίϯςφԽ͞ΕͨΞϓϦͱͯ͠,VCFSOFUFT্Ͱಈ࡞͢Δ %BUBCBTF$MVTUFS $POUSPMMFS $VTUPN$POUSPMMFS %BUBCBTF$MVTUFS $VTUPN3FTPVSDF watch Reconcile
 Loop %BUBCBTF$MVTUFS ରԠ͢Δίϯτϩʔϥ͕ ઃఆΛ΋ͱʹ1PEΛσϓϩΠ
  11. ,VCFSOFUFT0QFSBUPS 11 0QFSBUPSͰͲΜͳ͜ͱ͕Ͱ͖Δʁ ྫσʔλϕʔε w Ϋϥελͷ࡞੒࡟আ w Ϋϥελͷεέʔϧ w ো֐ͷݕ஌ͱ෮چ

    w όοΫΞοϓϦετΞͷࣗಈԽ ྫΫϥ΢υ w Ϋϥ΢υ্ͷϦιʔεͷ؅ཧ w Ϛωʔδυ%# w ΦϒδΣΫτετϨʔδͷόέοτ w ͳͲʜ
  12. ,VCFSOFUFT0QFSBUPS 12 0QFSBUPSΛ͕͢͞ʹ͸ʁ BXFTPNFPQFSBUPST ެ։͞Ε͍ͯΔ0QFSBUPSΛΞϓϦέʔ γϣϯ͝ͱʹू໿ͨ͠υΩϡϝϯτ 0QFSBUPS)VCJP 0QFSBUPSΛΞϓϦέʔγϣϯ։ൃ ϑΣʔζผʹ·ͱΊͨαΠτ

  13. ,VCFSOFUFT0QFSBUPS 13 IUUQTTQFBLFSEFDLDPNZVLJSJJDOEULTPQFSBUPS 0QFSBUPSʹؔ͢ΔΑΓৄ͍͠ղઆ͸ʜ

  14. $MVTUFS"1* w ,VCFSOFUFTͷαϒϓϩδΣΫτ w $MVTUFS-JGFDZDMF4*(ͷ΋ͱ։ൃ͕ਐΊΒΕ͍ͯΔ w ΫϥελͷϥΠϑαΠΫϧʹؔΘΔૢ࡞Λ,Tͷએݴతͳ"1*Ͱఏڙ͢Δ w Ϋϥελͷʮ࡞੒ɾεέʔϧɾΞοϓάϨʔυɾ࡟আʯ w

    ֤छΫϥ΢υΦϯϓϨϛεͳͲͷ؀ڥͰར༻Մೳ 5IF$MVTUFS"1*#PPL IUUQTDMVTUFSBQJTJHTLTJP
  15. ,VCFSOFUFTΫϥελͷߏஙɾӡ༻͸େมʂ Πϯϑϥߏங 44-ূ໌ॻͷ؅ཧ ωοτϫʔΫ 7. ετϨʔδ ߋ৽ ൃߦ ϊʔυ΁഑ஔ ιϑτ΢ΣΞͷ؅ཧ

    ύοέʔδͷΠϯετʔϧ ΫϥελΞυΦϯͷಋೖ LTͷόʔδϣϯΞοϓ $MVTUFS"1*͕ొ৔ͨ͠എܠ
  16. ΫϥελϚωδϝϯτ༻ͷ༷ʑͳπʔϧ͕ొ৔ w LVCFTQSBZ,VCFSOFUFTΛΠϯετʔϧ͢Δ"OTJCMF1MBZCPPL w LPQT"84؀ڥʹ,VCFSOFUFTΫϥελΛߏஙɾ؅ཧ͢Δπʔϧ w LVCFBENΫϥελίϯϙʔωϯτͷϒʔτετϥοϓʹಛԽͨ͠πʔϧ ͳͲʜɹ πʔϧʹΑͬͯ࡞ۀ͸ϥΫʹͳͬͨʂ͕ɺ ͜ͷΑ͏ʹͰ͖Δͱ͏Ε͍͠

    w ؀ڥπʔϧʹґଘ͠ͳ͍ڞ௨ͷΫϥελ؅ཧํ๏͕΄͍͠ wରԠ؀ڥΛ௥Ճ͢ΔͨΊͷ࣮૷͸؆୯ʹ࣮૷Ͱ͖Δͱ͏Ε͍͠ w Ϋϥελͷϊʔυͷεέʔϧ΍ΞοϓσʔτΛࣗಈԽ͍ͨ͠ w ͜ΕΒͷૢ࡞Λએݴతͳ"1*ઃఆͰ࣮ݱ͍ͨ͠ Ͳ͏΍ͬͯղܾ͢Δʁʁ $MVTUFS"1*͕ొ৔ͨ͠എܠ
  17. $MVTUFS"1*͕ొ৔ͨ͠എܠ ,VCFSOFUFT͕͢Ͱʹ͍࣋ͬͯΔΞΠσΟΞΛ࢖͏ ࠶ͼ4FSWJDFͷྫ w ઃఆ :".-ϚχϑΣετ ͷ಺༰͸؀ڥඇґଘ˞ w ֤Ϋϥ΢υ޲͚ͷίϯτϩʔϥ͕؀ڥʹ߹Θͤͯ-#Λઃఆ Service

    Service apiVersion: v1 kind: Service metadata: name: my-service spec: type: LoadBalancer ports: - protocol: TCP port: 80 targetPort: 8080 selector: app: my-app my-service.yaml apply apply GCLB LBaaS cloud-provider
 gcp cloud-provider
 openstack watch create watch create ˞ઃఆ಺༰ʹΑͬͯ͸ҟͳΔ؀ڥͰ࢖༻Ͱ͖ͳ͍΋ͷ΋͋Γ·͢ ྫBOOPUBUJPOΛ࢖ͬͨΫϥ΢υ؀ڥݻ༗ͷઃఆͳͲ
  18. 1SPWJEFS*NQMFNFOUBUJPOT ؀ڥݻ༗ͷॲཧ͸$MVTUFS"1*1SPWJEFSͱͯ͠ຊମ͔Β੾Γग़͞Ε͍ͯΔ ֤छΠϯϑϥ؀ڥ#PPUTUSBQํࣜ޲͚ʹϓϩόΠμ͕։ൃ͞Ε͍ͯΔ https://cluster-api.sigs.k8s.io/reference/providers.html *OGSBTUSVDUVSF1SPWJEFS Ϋϥ΢υ؀ڥʹ7.΍-#ͳͲͷ ඞཁͳϦιʔεΛ࡞੒ w "84 w

    "[VSF w #BSF.FUBM w ($1 w 0QFO4UBDL w W4QIFSF w FUDʜ #PPUTUSBQ1SPWJEFS 7.ʹ,TͷίϯϙʔωϯτΛ Πϯετʔϧ͢ΔεΫϦϓτΛੜ੒ w LVCFBEN w 5BMPT
  19. $MVTUFS"1*ʹΑΔΫϥελߏஙɾ؅ཧ ৽͍͠ΫϥελΛͭ͘Δʹ͸  ˠΫϥελ $MVTUFS ͱϊʔυ .BDIJOF ͷ:".-Λ༻ҙ͢Δ apiVersion: cluster.x-k8s.io/v1alpha2

    kind: Cluster metadata: name: my-cluster spec: clusterNetwork: pods: cidrBlocks: [“192.168.0.0/16”] infrastructureRef: # লུ # Ϋϥ΢υ؀ڥݻ༗ͷઃఆ΁ͷࢀর cluster.yaml apiVersion: cluster.x-k8s.io/v1alpha2 kind: MachineDeployment metadata: name: my-first-cluster-node01 spec: replicas: 3 template: spec: version: v1.15.3 bootstrap: # লུ # k8sίϯϙʔωϯτͷbootstrapͷ # ํ๏Λఆٛͨ͠ઃఆ΁ͷࢀর infrastructureRef: # Ϋϥ΢υ؀ڥݻ༗ͷઃఆ΁ͷࢀর machine.yaml
  20. $MVTUFS"1*ʹΑΔΫϥελߏஙɾ؅ཧ Cloud Environment Management Cluster Cluster Infrastructure
 Cluster Machine Infrastructure


    Machine Bootstrap
 Config Cluster API Infrastructure Provider CRDs Controller Bootstrap Provider Workload Cluster kind: Cluster kind: Machine CRDs Controller CRDs Controller
  21. $MVTUFS"1*ʹΑΔΫϥελߏஙɾ؅ཧ Cloud Environment Management Cluster Cluster Infrastructure
 Cluster Machine Infrastructure


    Machine Bootstrap
 Config Cluster API Infrastructure Provider CRDs Controller Bootstrap Provider Workload Cluster kind: Cluster kind: Machine CRDs Controller CRDs Controller ଞͷΫϥελΛ؅ཧ͢ΔΫϥελ $MVTUFS"1*ͷίϯϙʔωϯτ͕ Πϯετʔϧ͞Ε͍ͯΔ
  22. $MVTUFS"1*ʹΑΔΫϥελߏஙɾ؅ཧ Cloud Environment Management Cluster Cluster Infrastructure
 Cluster Machine Infrastructure


    Machine Bootstrap
 Config Cluster API Infrastructure Provider CRDs Controller Bootstrap Provider Workload Cluster kind: Cluster kind: Machine CRDs Controller CRDs Controller ϥΠϑϥΠΫϧΛ؅ཧ͞Ε͍ͯΔΫϥελ ࣮ࡍͷΞϓϦέʔγϣϯΛಈ࡞ͤ͞Δ ϫʔΫϩʔυ༻Ϋϥελͱͯ͠࢖ΘΕΔ
  23. $MVTUFS"1*ʹΑΔΫϥελߏஙɾ؅ཧ Cloud Environment Management Cluster Cluster Infrastructure
 Cluster Machine Infrastructure


    Machine Bootstrap
 Config Cluster API Infrastructure Provider CRDs Controller Bootstrap Provider Workload Cluster kind: Cluster kind: Machine CRDs Controller CRDs Controller $MVTUFSͱ.BDIJOFͷ ΦϒδΣΫτΛ࡞੒
  24. $MVTUFS"1*ʹΑΔΫϥελߏஙɾ؅ཧ Cloud Environment Management Cluster Cluster Infrastructure
 Cluster Machine Infrastructure


    Machine Bootstrap
 Config Cluster API Infrastructure Provider CRDs Controller Bootstrap Provider Workload Cluster kind: Cluster kind: Machine CRDs Controller CRDs Controller $MVTUFS"1*ίϯτϩʔϥ͕ Ϋϥελߏஙʹඞཁͳ৘ใΛੜ੒
  25. $MVTUFS"1*ʹΑΔΫϥελߏஙɾ؅ཧ Cloud Environment Management Cluster Cluster Infrastructure
 Cluster Machine Infrastructure


    Machine Bootstrap
 Config Cluster API Infrastructure Provider CRDs Controller Bootstrap Provider Workload Cluster kind: Cluster kind: Machine CRDs Controller CRDs Controller Ϋϥ΢υ؀ڥʹ7.͕࡞੒͞Ε Ϋϥελ্ཱ͕͕ͪΔ
  26. <ٕज़ॻయ>͸͡ΊΔ$MVTUFS"1* 26 IUUQTUFDIJFNFEJBCPPUIQNJUFNT lΫϥελͰΫϥελΛ࡞Γ؅ཧ͢ΔzΛ ମݧ͢ΔͨΊͷղઆॻ ʲ಺༰ʳ  $MVTUFS"1*ͷഎܠͱ֓ཁ  "84؀ڥʹΫϥελΛͭ͘Δ

    ϋϯζΦϯ  ,VCFSOFUFTͷΤίγεςϜͱ ૊Έ߹Θ͔ͤͯͭ͏ #005)ʹͯిࢠॻ੶൛΋ൢചதʂ ຊ೔ͷ04$ϒʔε  ʹͯ ൦෍͍ͯ͠·͢ʂ
  27. ·ͱΊ w ,VCFSOFUFT͸એݴతͳ"1* ίϯτϩʔϥͰߏ੒͞ΕΔ w lίϯςφͷσϓϩΠz͚ͩʹͱͲ·Βͣ ,VCFSOFUFTͷ࢓૊Έ͸͞·͟·ͳ໨తʹԠ༻Ͱ͖Δ w ,VCFSOFUFT0QFSBUPS ΞϓϦέʔγϣϯݻ༗ͷӡ༻ૢ࡞Λ,VCFSOFUFTʹ೚ͤΔ

    w $MVTUFS"1* LTΫϥελͰLTΫϥελΛͭ͘Δ એݴతͳ"1*Ͱ͞·͟·ͳΫϥ΢υ؀ڥ΁ΫϥελΛσϓϩΠ ʮϓϥοτϑΥʔϜΛͭ͘ΔͨΊͷϓϥοτϑΥʔϜʯ ͱͯ͠΋,VCFSOFUFTΛ׆༻͍ͯ͜͠͏ʂ