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

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

yukirii
November 24, 2019

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

yukirii

November 24, 2019
Tweet

More Decks by yukirii

Other Decks in Technology

Transcript

  1. ,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
  2. ,VCFSOFUFTͷಛ௃ͱಈ࡞ ͓͞Β͍ ಛ௃ίϯτϩʔϥʹΑΔ3FDPODJMJBUJPO-PPQ ௐ੔ϧʔϓ  w ,VCFSOFUFTΫϥελ͸༷ʑͳίϯτϩʔϥͷ૊Έ߹ΘͤͰಈ͍͍ͯΔ w ֤ίϯτϩʔϥ͸ࣗ਎ͷ୲౰͢ΔϦιʔεΦϒδΣΫτΛಡΈऔΓ ఆٛ͞Εͨཁ݅Λຬͨ͢Α͏ʹϦιʔεͷ࣮ମ

    BDUSVBMTUBUF Λૢ࡞ Service LB Service
 Controller watch create/modify 0CTFSWF %J⒎ "DU Cloud ΦϒδΣΫτͷ ߋ৽Λݕ஌ ΦϒδΣΫτͷ಺༰ͱ ࣮ࡍͷϦιʔεͷঢ়ଶΛ ൺֱ ࠩ෼͕͋Δ৔߹͸ ࣮ࡍͷϦιʔεΛ मਖ਼͢Δ
  3. ,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
  4. ,VCFSOFUFT0QFSBUPS 8 ಛఆͷΞϓϦέʔγϣϯΛ,VCFSOFUFT্Ͱ࣮ߦɾ؅ཧ͢ΔͨΊͷ ιϑτ΢ΣΞ ίϯτϩʔϥ  w த਎͸$3%ͱΧελϜίϯτϩʔϥ w ΞϓϦέʔγϣϯͷӡ༻্ͷφϨοδΛίϯτϩʔϥͱ࣮ͯ͠૷

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

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

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

    w όοΫΞοϓϦετΞͷࣗಈԽ ྫΫϥ΢υ w Ϋϥ΢υ্ͷϦιʔεͷ؅ཧ w Ϛωʔδυ%# w ΦϒδΣΫτετϨʔδͷόέοτ w ͳͲʜ
  8. ,VCFSOFUFTΫϥελͷߏஙɾӡ༻͸େมʂ Πϯϑϥߏங 44-ূ໌ॻͷ؅ཧ ωοτϫʔΫ 7. ετϨʔδ ߋ৽ ൃߦ ϊʔυ΁഑ஔ ιϑτ΢ΣΞͷ؅ཧ

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

    w ؀ڥπʔϧʹґଘ͠ͳ͍ڞ௨ͷΫϥελ؅ཧํ๏͕΄͍͠ wରԠ؀ڥΛ௥Ճ͢ΔͨΊͷ࣮૷͸؆୯ʹ࣮૷Ͱ͖Δͱ͏Ε͍͠ w Ϋϥελͷϊʔυͷεέʔϧ΍ΞοϓσʔτΛࣗಈԽ͍ͨ͠ w ͜ΕΒͷૢ࡞Λએݴతͳ"1*ઃఆͰ࣮ݱ͍ͨ͠ Ͳ͏΍ͬͯղܾ͢Δʁʁ $MVTUFS"1*͕ొ৔ͨ͠എܠ
  10. $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Λ࢖ͬͨΫϥ΢υ؀ڥݻ༗ͷઃఆͳͲ
  11. $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
  12. $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
  13. $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*ͷίϯϙʔωϯτ͕ Πϯετʔϧ͞Ε͍ͯΔ
  14. $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 ϥΠϑϥΠΫϧΛ؅ཧ͞Ε͍ͯΔΫϥελ ࣮ࡍͷΞϓϦέʔγϣϯΛಈ࡞ͤ͞Δ ϫʔΫϩʔυ༻Ϋϥελͱͯ͠࢖ΘΕΔ
  15. $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ͷ ΦϒδΣΫτΛ࡞੒
  16. $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*ίϯτϩʔϥ͕ Ϋϥελߏஙʹඞཁͳ৘ใΛੜ੒
  17. $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.͕࡞੒͞Ε Ϋϥελ্ཱ͕͕ͪΔ
  18. <ٕज़ॻయ>͸͡ΊΔ$MVTUFS"1* 26 IUUQTUFDIJFNFEJBCPPUIQNJUFNT lΫϥελͰΫϥελΛ࡞Γ؅ཧ͢ΔzΛ ମݧ͢ΔͨΊͷղઆॻ ʲ಺༰ʳ  $MVTUFS"1*ͷഎܠͱ֓ཁ  "84؀ڥʹΫϥελΛͭ͘Δ

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

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