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

Cloud runユーザーから見たk8s

taxin
April 20, 2022

Cloud runユーザーから見たk8s

taxin

April 20, 2022
Tweet

More Decks by taxin

Other Decks in Technology

Transcript

  1. WHO AM I? • @taxin_tt • Kubernetes Novice Tokyoͷதͷਓ •

    ࠷ۙ͸ɺGCP࢖͍ͭͭSRE΍ͬͯ·͢ • SREͬͯԿ…? ͬͯਓ͸ͥͻSRE Next 2022΁
  2. • KubernetesͬͯศརͰ͢ΑͶ :) • ଟछଟ༷ͳϫʔΫϩʔυ΁ͷରԠΛՄೳʹ͢Δk8sͷػೳੑ 
 (scheduling, scaling etc.) •

    એݴతͳઃఆʹΑΔߏ੒ (Πϯϑϥͷঢ়ଶ) ͷ؅ཧ • OSSɺPublic Cloudͷ׆༻ʹΑ࣮ͬͯݱ͢Δج൫ͱͯ͠ͷ֦ுੑ ಥવͰ͕͢
  3. • KubernetesͬͯศརͰ͢ΑͶ :) • ଟछଟ༷ͳϫʔΫϩʔυ΁ͷରԠΛՄೳʹ͢Δk8sͷػೳੑ 
 (scheduling, scaling etc.) •

    એݴతͳઃఆʹΑΔߏ੒ (Πϯϑϥͷঢ়ଶ) ͷ؅ཧ • OSSɺPublic Cloudͷ׆༻ʹΑ࣮ͬͯݱ͢Δج൫ͱͯ͠ͷ֦ுੑ ಥવͰ͕͢ Ϣʔβʔͱͯ͠k8sΛ ར༻͢Δࡍʹײ͡ΔϝϦοτ
  4. • KubernetesͬͯศརͰ͢ΑͶ :) • ଟछଟ༷ͳϫʔΫϩʔυ΁ͷରԠΛՄೳʹ͢Δk8sͷػೳੑ 
 (scheduling, scaling etc.) •

    એݴతͳઃఆʹΑΔߏ੒ (Πϯϑϥͷঢ়ଶ) ͷ؅ཧ • OSSɺPublic Cloudͷ׆༻ʹΑ࣮ͬͯݱ͢Δج൫ͱͯ͠ͷ֦ுੑ • Not k8sϢʔβʔͷࢹ఺͔ΒݟͯΈΔͱݟํ͸Ͳ͏มΘΔͩΖ͏͔? ಥવͰ͕͢ Ϣʔβʔͱͯ͠k8sΛ ར༻͢Δࡍʹײ͡ΔϝϦοτ
  5. • KubernetesͬͯศརͰ͢ΑͶ :) • ଟछଟ༷ͳϫʔΫϩʔυ΁ͷରԠΛՄೳʹ͢Δk8sͷػೳੑ 
 (scheduling, scaling etc.) •

    એݴతͳઃఆʹΑΔߏ੒ (Πϯϑϥͷঢ়ଶ) ͷ؅ཧ • OSSɺPublic Cloudͷ׆༻ʹΑ࣮ͬͯݱ͢Δج൫ͱͯ͠ͷ֦ுੑ • Not k8sϢʔβʔͷࢹ఺͔ΒݟͯΈΔͱݟํ͸Ͳ͏มΘΔͩΖ͏͔? • k8sͷϝϦοτ / σϝϦοτɺࢥ͏͜ͱ ಥવͰ͕͢ Ϣʔβʔͱͯ͠k8sΛ ར༻͢Δࡍʹײ͡ΔϝϦοτ
  6. • ࠓ೔͸ ʮCloud runϢʔβʔ͔Βݟͨk8sʯͱ͍͏؍఺Ͱ͓࿩͠͠·͢ • ࠷ۙ͸ɺCloud run͹͔ͬ৮͍ͬͯΔͷͰ͜Μͳ಺༰ʹͳΓ·͢ :bow: • Disclaimer

    • ຊεϥΠυ͸GCPʹؔ͢Δઆ໌ΛؚΈ·͢ • ※ Cloud run / k8s (GKE etc.) ͷͲͪΒ͔ͷར༻Λਪ঑͢Δ΋ͷͰ͸͋Γ·ͤΜ • ϫʔΫϩʔυͷੑ࣭ɺϢʔεέʔεʹ߹Θͤͯ͝ར༻͍ͩ͘͞ ͱ͍͏Θ͚Ͱ
  7. • [FYI] Cloud run : Knativeޓ׵ͷAPIΛఏڙ͍ͯ͠Δ • ʮKnative : Cloud

    Run ͷج൫Ͱ͋ΔΦʔϓϯ API ͓ΑͼϥϯλΠϜ؀ڥͰ͢ɻ…ʯ • Knativeʹؔ͢ΔLTɾηογϣϯ͸ noviceͷ#9, #11 Ͱ͝ཡ͍͚ͨͩ·͢ • Thanks to @ch0312 ͞Μɺ@mochizuki875 ͞Μʂ ABOUT CLOUD RUN Reference: https://cloud.google.com/blog/ja/products/serverless/knative-based-cloud-run-services-are-ga
  8. • [FYI] Cloud run : Knativeޓ׵ͷAPIΛఏڙ͍ͯ͠Δ • ʮKnative : Cloud

    Run ͷج൫Ͱ͋ΔΦʔϓϯ API ͓ΑͼϥϯλΠϜ؀ڥͰ͢ɻ…ʯ • knativeʹؔ͢ΔLTɾηογϣϯ͸ noviceͷ#9 #11 Ͱ͝ཡ͍͚ͨͩ·͢ • Thanks to @ch0312 ͞Μɺ@mochizuki875 ͞Μʂ ABOUT CLOUD RUN Reference: https://cloud.google.com/blog/ja/products/serverless/knative-based-cloud-run-services-are-ga গ͠લͷεϥΠυʹ ໭ͬͯ…
  9. • k8s → Cloud runͱ৮ͬͯײͨ͜͡ͱ • 1. ֮͑Δ͜ͱ͕ (k8sͱൺֱ͢Δͱ) গͳ͍

    • Cloud runϢʔβʔ͸KnativeΛཧղ͠ͳͯ͘΋ར༻Ͱ͖Δ • ※ Cloud run Admin API ͷར༻࣌͸service, revisionͳͲͷKnativeͷ֓೦ʹ৮ΕΔ 
 (https://cloud.google.com/run/docs/reference/rest?hl=ja) • ཁ݅࣍ୈͰ͸ɺGCPͰҰ௨Γ׬݁͢Δ 
 (e.g. Cloud run + Cloud SQL + Cloud Storage + MemoryStore) CLOUD RUN / K8S
  10. • k8s → Cloud runͱ৮ͬͯײͨ͜͡ͱ • 1. ֮͑Δ͜ͱ͕ (k8sͱൺֱ͢Δͱ) গͳ͍

    • Cloud runϢʔβʔ͸Knative (k8s) Λཧղ͠ͳͯ͘΋ར༻Ͱ͖Δ • ※ Cloud run Admin API ͷར༻࣌͸service, revisionͳͲͷknativeͷ֓೦ʹ৮ΕΔ 
 (https://cloud.google.com/run/docs/reference/rest?hl=ja) • ཁ݅࣍ୈͰ͸ɺGCPͰҰ௨Γ׬݁͢Δ 
 (e.g. Cloud run + Cloud SQL + Cloud Storage + MemoryStore) CLOUD RUN / K8S ӡ༻໘Ͱͷෛ୲Λ࠷খݶʹͰ͖Δ - Πϯϑϥ͕Ͱ͖Δϝϯόʔ͕গͳ͍ 
 - ਓతϦιʔεͷ഑෼ͷ؍఺ͰΞϓϦέʔγϣϯ 
 ։ൃʹϦιʔεΛ౤ೖ͍ͨ͠ etc.
  11. • k8s → Cloud runͱ৮ͬͯײͨ͜͡ͱ • 1. ֮͑Δ͜ͱ͕ (k8sͱൺֱ͢Δͱ) গͳ͍

    • Cloud runϢʔβʔ͸Knative (k8s) Λཧղ͠ͳͯ͘΋ར༻Ͱ͖Δ • ※ Cloud run Admin API ͷར༻࣌͸service, revisionͳͲͷknativeͷ֓೦ʹ৮ΕΔ 
 (https://cloud.google.com/run/docs/reference/rest?hl=ja) • ཁ݅࣍ୈͰ͸ɺGCPͰҰ௨Γ׬݁͢Δ 
 (e.g. Cloud run + Cloud SQL + Cloud Storage + MemoryStore) CLOUD RUN / K8S ͢ͰʹGCPΛར༻͍ͯ͠Δ৔߹ɺ Πϯϑϥؔ࿈ͷֶशίετΛ࠷খݶʹͰ͖Δ
  12. • k8s → Cloud runͱ৮ͬͯײͨ͜͡ͱ • 2. Cloud run͸ʮ͔Ώ͍ͱ͜Ζʯʹख͕ಧ͔ͳ͍͜ͱ͕͋Δ •

    1. scheduling, scalingͳͲͷઃఆ͸ϢʔβʔଆͰߦ͏ඞཁ͕ͳ͍ 
 = MetricsΛར༻ͨ͠Auto scalingͷઃఆ (e.g. HPA) 
 schedulingͷࢦఆ (e.g. Node / Pod Af f inity) ͸ࡉ͔͘ઃఆͰ͖ͳ͍ • ʮ…طଘͷΠϯελϯεͷCPU ࢖༻཰ʢεέδϡʔϧ͞ΕͨΠϯελϯεΛ CPU ࢖༻཰ 60% ʹҡ࣋͢ΔͨΊͷλʔήςΟϯάʣ... ʯ CLOUD RUN / K8S Reference: https://cloud.google.com/run/docs/about-instance-autoscaling?hl=ja
  13. • k8s → Cloud runͱ৮ͬͯײͨ͜͡ͱ • 2. Cloud run͸ʮ͔Ώ͍ͱ͜Ζʯʹख͕ಧ͔ͳ͍͜ͱ͕͋Δ •

    2. Πϯϑϥج൫ʹؔ͢Δ؅ཧ΋ෆཁ 
 = k8sΛલఏͱͨ͠ػೳ֦ுΛߦ͏OSSΛ༗͢Δk8sͱൺֱͯ͠πʔϧ౳ͷબ୒ࢶ͕ݶఆత 
 (e.g. Argo CD, Istio ͳͲ͸Kubernetes NativeͰ͋Δͱ໌ه͞Ε͍ͯΔ) • ※ ʮબ୒ࢶ͕ແ͍ʯΘ͚Ͱ͸ແ͍ CLOUD RUN / K8S
  14. • Disclaimer • ຊεϥΠυ͸GCPʹؔ͢Δઆ໌ΛؚΈ·͢ • Cloud run / k8s (GKE)

    ͷͲͪΒ͔ͷར༻Λਪ঑͢Δ΋ͷͰ͸͋Γ·ͤΜ • ϫʔΫϩʔυͷੑ࣭ɺϢʔεέʔεʹ߹Θͤͯ͝ར༻͍ͩ͘͞ 
 CLOUD RUN / K8S গ͠લͷεϥΠυʹ ໭ͬͯ…
  15. • Disclaimer • ຊεϥΠυ͸GCPʹؔ͢Δઆ໌ΛؚΈ·͢ • Cloud run / k8s (GKE)

    ͷͲͪΒ͔ͷར༻Λਪ঑͢Δ΋ͷͰ͸͋Γ·ͤΜ • ϫʔΫϩʔυͷੑ࣭ɺϢʔεέʔεʹ߹Θͤͯ͝ར༻͍ͩ͘͞ 
 → ಈ͔͍ͨ͠ϫʔΫϩʔυʹʮࡉ͔͘ઃఆɾ੍ޚ͍ͨ͠ (ٕज़) ཁ݅ʯ 
 ͕͋Δ͔Ͳ͏͔͕ॏཁʹͳΔ CLOUD RUN / K8S
  16. • ϝϦοτɾσϝϦοτΛ౿·͑ͯײͨ͜͡ͱ… • 2. ʮ͔Ώ͍ͱ͜Ζʯʹख͕ಧ͔ͳ͍͜ͱ͕͋Δ • scheduling, scalingͳͲͷઃఆ͸ϢʔβʔଆͰߦ͏ඞཁ͕ͳ͍ 
 =

    HPAͷΑ͏ͳࡉ͔͍εέʔϦϯάͷઃఆ͸ఆٛͰ͖ͳ͍ • ࡉ͔͘ઃఆ͠ͳͯ͘΋͍͍ϫʔΫϩʔυ͔Ͳ͏͔ 
 (e.g. ϦΫΤετͷεύΠΫ͕ൃੜ͠ͳ͍ = εέʔϦϯάͷৄࡉͳ੍ޚ͸ෆཁ?) CLOUD RUN / K8S
  17. • ϝϦοτɾσϝϦοτΛ౿·͑ͯײͨ͜͡ͱ… • 2. ʮ͔Ώ͍ͱ͜Ζʯʹख͕ಧ͔ͳ͍͜ͱ͕͋Δ • scheduling, scalingͳͲͷઃఆ͸ϢʔβʔଆͰߦ͏ඞཁ͕ͳ͍ 
 =

    HPAͷΑ͏ͳࡉ͔͍εέʔϦϯάͷઃఆ͸ఆٛͰ͖ͳ͍ • ࡉ͔͘ઃఆ͠ͳͯ͘΋͍͍ϫʔΫϩʔυ͔Ͳ͏͔ 
 (e.g. ϦΫΤετͷεύΠΫ͕ൃੜ͠ͳ͍ = εέʔϦϯάͷৄࡉͳ੍ޚ͸ෆཁ?) • → ٕज़తͳॊೈੑ(֦ுੑ)ͱ࣮૷ɾӡ༻ίετͷτϨʔυΦϑͷੈքʹͳͬͯ͘Δ CLOUD RUN / K8S
  18. • ϝϦοτɾσϝϦοτΛ౿·͑ͯײͨ͜͡ͱ… • 2. ʮ͔Ώ͍ͱ͜Ζʯʹख͕ಧ͔ͳ͍͜ͱ͕͋Δ • scheduling, scalingͳͲͷઃఆ͸ϢʔβʔଆͰߦ͏ඞཁ͕ͳ͍ 
 =

    HPAͷΑ͏ͳࡉ͔͍εέʔϦϯάͷઃఆ͸ఆٛͰ͖ͳ͍ • ࡉ͔͘ઃఆ͠ͳͯ͘΋͍͍ϫʔΫϩʔυ͔Ͳ͏͔ 
 (e.g. ϦΫΤετͷεύΠΫ͕ൃੜ͠ͳ͍ = εέʔϦϯάͷৄࡉͳ੍ޚ͸ෆཁ?) • → ٕज़తͳॊೈੑ(֦ுੑ)ͱ࣮૷ɾӡ༻ίετͷτϨʔυΦϑͷੈքʹͳͬͯ͘Δ CLOUD RUN / K8S GKE? / GKE Autopilot? / Cloud run?
  19. • Kubernetesͷྑ͍ͱ͜Ζ • ଟछଟ༷ͳϫʔΫϩʔυ΁ͷରԠΛՄೳʹ͢Δk8sͷػೳੑ 
 (scheduling, scaling etc.) • એݴతͳઃఆʹΑΔߏ੒

    (Πϯϑϥͷঢ়ଶ) ͷ؅ཧ • OSSɺPublic Cloudͷ׆༻ʹΑ࣮ͬͯݱ͢Δج൫ͱͯ͠ͷ֦ுੑ ·ͱΊ ɾ্هͷϝϦοτ (ଠࣈ෦෼) ͷཪଆʹ͋Δɺ 
 ʮॊೈੑ(֦ுੑ)ͱ࣮૷ɾӡ༻ίετͷτϨʔυΦϑʯ͸ΑΓڧ͘ҙࣝ͢ΔΑ͏ʹͳͬͨ ɾӡ༻ίετɺֶशίετͷ؍఺͔ΒCloud runࣗମ͸༗༻ͱࢥ͏ͷͰʮk8sΛબ୒͠ͳ͔ͬͨʯ 
 ࣄྫ͕૿͑Δͱk8sϢʔβʔʹͱͬͯ΋ࢀߟʹͳΔ (ͱࢥ͍ͬͯΔ)