Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Cloud RunとCloud PubSubでサーバレスなデータ基盤2024 with Ter...
Search
Shinichi Nakagawa
PRO
March 08, 2024
Programming
9
3.3k
Cloud RunとCloud PubSubでサーバレスなデータ基盤2024 with Terraform / Cloud Run and PubSub with Terraform
Google Cloudのサーバレスなサービスでデータ基盤を作った話.
Shinichi Nakagawa
PRO
March 08, 2024
Tweet
Share
More Decks by Shinichi Nakagawa
See All by Shinichi Nakagawa
実践Dash - 手を抜きながら本気で作るデータApplicationの基本と応用 / Dash for Python and Baseball
shinyorke
PRO
2
1.8k
Terraform, GitHub Actions, Cloud Buildでデータ基盤をProvisioningする / Data Platform provisioning for Google Cloud and Terraform
shinyorke
PRO
2
2.9k
自らを強いエンジニアにするための3つの習慣 / I need to be myself, I can't be no one else
shinyorke
PRO
79
79k
阪神タイガース優勝のひみつ - Pythonでシュッと調べた件 / SABRmetrics for Python
shinyorke
PRO
1
1.3k
Pythonとクラウドと野球の推し活. / Baseball Data Platform for Python and Google Cloud
shinyorke
PRO
2
2.8k
月額コーヒー3.34杯分のコストでオオタニサンの活躍を見守るデータ基盤のはなし / Pyhack Con
shinyorke
PRO
2
470
俺のDXを実現するためのサーバレスなデータ基盤開発と運用 / Serverless Data Platform and Baseball
shinyorke
PRO
5
12k
機械学習エンジニアが目指すキャリアパスとその実話 / My Journey to Become a ML Engineer
shinyorke
PRO
9
17k
一人でも小さく始められるGoogle Cloudで実現するほぼサーバレスなデータ基盤 / Serverless Dataplatform for Google Cloud
shinyorke
PRO
0
550
Other Decks in Programming
See All in Programming
Beyond ORM
77web
11
1.6k
今年のアップデートで振り返るCDKセキュリティのシフトレフト/2024-cdk-security-shift-left
tomoki10
0
360
盆栽転じて家具となる / Bonsai and Furnitures
aereal
0
1.8k
PicoRubyと暮らす、シェアハウスハック
ryosk7
0
200
ゼロからの、レトロゲームエンジンの作り方
tokujiros
3
1k
EC2からECSへ 念願のコンテナ移行と巨大レガシーPHPアプリケーションの再構築
sumiyae
3
580
AHC041解説
terryu16
0
330
AWS re:Invent 2024個人的まとめ
satoshi256kbyte
0
100
GitHub CopilotでTypeScriptの コード生成するワザップ
starfish719
26
5.9k
20241217 競争力強化とビジネス価値創出への挑戦:モノタロウのシステムモダナイズ、開発組織の進化と今後の展望
monotaro
PRO
0
280
カンファレンス動画鑑賞会のススメ / Osaka.swift #1
hironytic
0
160
為你自己學 Python
eddie
0
510
Featured
See All Featured
The Pragmatic Product Professional
lauravandoore
32
6.4k
The Power of CSS Pseudo Elements
geoffreycrofte
74
5.4k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.9k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.2k
How STYLIGHT went responsive
nonsquared
96
5.3k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
365
25k
GraphQLの誤解/rethinking-graphql
sonatard
68
10k
We Have a Design System, Now What?
morganepeng
51
7.3k
Fashionably flexible responsive web design (full day workshop)
malarkey
406
66k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Transcript
Cloud RunͱCloud Pub/SubͰ αʔόϨεͳσʔλج൫Λ ࡞ͬͨ2024 ΫϥυωΠςΟϒͳ࣌ͷMicro ServiceͱIaCͷࡏΓํͷߟͱ࣮ફ Shinichi Nakagawa(@shinyorke) 2024/3/8
ୈ22ճ ञͱήʔϜͱΠϯϑϥͱGCP
TL;DRʢ͜ͷͷ֓ཁʣ • Cloud RunͱCloud Pub/SubͰαʔόϨεͳσʔλج൫Λ࡞ͬͨ. • Micro ServiceΛTerraformͰؙͬͱIaCʢInfrastructure as Codeʣ.
SoIʢSystem Of InsightsʣͷγεςϜ࣮ݱͷҰྫͱͯ͠ฉ͍ͯԼ͍͞. ※͜ͷࣄྫۀͰͳ͘झຯͰ͢ʢ͕࣮Ͱ͑Δͣʣ.
ࣗݾհ • Shinichi Nakagawa(@shinyorke) • େख֎ࢿܥITίϯαϧاۀϚωʔδϟʔ/SRE • Google Cloud Partner
Top Engineer 2024 • ͖ͳGCP: Cloud Run, BigQuery, Cloud Pub/Sub, etc… • ͖ͳήʔϜ: ৴ͷ, Πχϯάϙετ, ͖Ύͭ͘ • झຯϓϩάϥϛϯάΛ͓ञยखʹΓ·͢ • 🍶: ෩ͷ, ࡞ʢ७ถܥ͖ʣ • 🍺: ଖͷेʢࢤլߴݪϏʔϧͷIPAʣ • ීஈϗοϐʔͱ๐ιʔμׂΓ͕Έ
ٿσʔλੳج൫ ※ݸਓ։ൃͰ͢ • झຯͷٿΛຊ֨తʹσʔλͰݟΔͨΊͷج൫ΛຊؾͰ ࡞͍ͬͯ·͢ʢٕज़తͳݕূΛ݉Ͷͯʣ. • ಛʹϝδϟʔϦʔάʮBaseball Savantʯͱ͍͏ެࣜͷ σʔλαΠτ͕͋Γ, ϑΝϯͷզʑͰCSVܗࣜͰσʔλ
͕खʹೖΓ·͢&σʔλͷத͕݁ߏ͍͜͠Ͱ͢. • ͦͷʮ͍͜͠CSVσʔλʯΛऔΓࠐΈ, ੳɾղੳΛ ߦ͏ϝδϟʔϦʔάੳΞϓϦΛ2022͔Β։ൃɾӡ༻. ຖϦΞʔΩςΫνϟʢ࡞Γ͠ʣ͍ͯ͠·͢, ࠓ Cloud Runͷ৽ػೳʢCloud Run JobsʣͰ࡞Γ͠. ੳج൫ͷΞϓϦέʔγϣϯʢ2022൛ʣ
ٿσʔλੳج൫શମ૾ʢ2024൛ʣ
ٿσʔλੳج൫શମ૾ʢ2024൛ʣ
ຊͷτʔΫͷൣғͪ͜ΒͷData Work fl owʢσʔλج൫ʣʹ͍ͭͯ.
Cloud RunͱCloud Pub/SubͰWork fl ow • Cloud Run JobsΛSchedulerܦ༝Ͱ࣮ߦ, ֤Micro
ServiceʢCloud RunʣΛݺͼग़͢ߏ. • ֤Micro ServicePub/SubͷϝοηʔδͰಈ͘Cloud RunΞϓϦʹ. • Cloud Run Jobs্ͷWork fl ow͕Micro ServiceͷPub/SubʹPublish. • ͜ΕΒͯ͢Google CloudͷυΩϡϝϯτʹਅࣅͰ͖Δώϯτ༗Γ. • Pub/SubͰCloud Run https://cloud.google.com/run/docs/tutorials/pubsub?hl=ja • SchedulerΛͬͨఆظ࣮ߦ https://cloud.google.com/run/docs/triggering/using-scheduler?hl=ja খ͍͞Work fl owͳΒAir fl ow(Cloud Composer)ΛΘͳͯ͘(K8sΫϥελ͕ແͯ͘)Cloud Run͚ͩͰ࣮ݱՄೳ.
ʲࢀߟʳ֤Micro ServiceͰͬͯΔϞϊͱղઆ .JDSP4FSWJDFPSׂ (PPHMF$MPVE4FSWJDF ֓ཁ ࣮ݴޠɾ'8 5JNFS $MPVE4DIFEVMFS 5SJHHFSΛఆظ࣮ߦ ˞γʔζϯ։࢝ޙຖ
DSPOࣜͰͷ5JNFS 5SJHHFS 8PSL fl PX $MPVE3VO+PCT &YQPSUFS*NQPSUFSΛ࣮ߦ ͢Δ5SJHHFSͱͳΔόον 1SFGFDU 1ZUIPO Ͱ࣮ -VJHJ ଞͷ࣮Ͱ0, &YQPSUFS $MPVE3VO #BTFCBMM4BWBOUΫΤϦΛ࣮ ߦ͠$47Λμϯϩʔυ (Pͷ8FC"1* 1VC4VC5PQJD͔Βىಈ %BUBMBLF $MPVE4UPSBHF &YQPSUFS͕ग़ྗͨ͠$47Λ ແՃͷੜσʔλͱͯ͠อ ͳ͠ *NQPSUFS $MPVE3VO $47σʔλΛνΣοΫ͠ #JH2VFSZʹ&YQPSU (Pͷ8FC"1* 1VC4VC5PQJD͔Βىಈ %8) #JH2VFSZ ੳऀPSΞϓϦ͔Β͏ %BUB8BSF)PVTF 42-Ͱ7JFXΛ࡞ͬͯӡ༻
αʔόϨεͳͷͰ͓ࡒʹ༏͍͠, ֹ݄Ͱίʔώʔ3.34ഋఔʢ֓ࢉʣ Cloud ComposerͷΫϥελΛMinimumͰӡ༻ͨ͠ͱͯ$100Ҏ্͔͔Δͣ?࣍Ͱಈ͔͢Cloud RunͳΒػίετ΄΅θϩʹ.
TerraformͰIaCʢInfrastructure as CodeʣେͰʢझຯͰʣ
ʲ࠶ܝʳ֤Micro ServiceͰͬͯΔϞϊͱղઆ .JDSP4FSWJDFPSׂ (PPHMF$MPVE4FSWJDF ֓ཁ ࣮ݴޠɾ'8 5JNFS $MPVE4DIFEVMFS 5SJHHFSΛఆظ࣮ߦ ˞γʔζϯ։࢝ޙຖ
DSPOࣜͰͷ5JNFS 5SJHHFS 8PSL fl PX $MPVE3VO+PCT &YQPSUFS*NQPSUFSΛ࣮ߦ ͢Δ5SJHHFSͱͳΔόον 1SFGFDU 1ZUIPO Ͱ࣮ -VJHJ ଞͷ࣮Ͱ0, &YQPSUFS $MPVE3VO #BTFCBMM4BWBOUΫΤϦΛ࣮ ߦ͠$47Λμϯϩʔυ (Pͷ8FC"1* 1VC4VC5PQJD͔Βىಈ %BUBMBLF $MPVE4UPSBHF &YQPSUFS͕ग़ྗͨ͠$47Λ ແՃͷੜσʔλͱͯ͠อ ͳ͠ *NQPSUFS $MPVE3VO $47σʔλΛνΣοΫ͠ #JH2VFSZʹ&YQPSU (Pͷ8FC"1* 1VC4VC5PQJD͔Βىಈ %8) #JH2VFSZ ੳऀPSΞϓϦ͔Β͏ %BUB8BSF)PVTF 42-Ͱ7JFXΛ࡞ͬͯӡ༻
.JDSP4FSWJDFPSׂ (PPHMF$MPVE4FSWJDF ֓ཁ ࣮ݴޠɾ'8 5JNFS $MPVE4DIFEVMFS 5SJHHFSΛఆظ࣮ߦ ˞γʔζϯ։࢝ޙຖ DSPOࣜͰͷ5JNFS 5SJHHFS
8PSL fl PX $MPVE3VO+PCT &YQPSUFS*NQPSUFSΛ࣮ߦ ͢Δ5SJHHFSͱͳΔόον 1SFGFDU 1ZUIPO Ͱ࣮ -VJHJ ଞͷ࣮Ͱ0, &YQPSUFS $MPVE3VO #BTFCBMM4BWBOUΫΤϦΛ࣮ ߦ͠$47Λμϯϩʔυ (Pͷ8FC"1* 1VC4VC5PQJD͔Βىಈ %BUBMBLF $MPVE4UPSBHF &YQPSUFS͕ग़ྗͨ͠$47Λ ແՃͷੜσʔλͱͯ͠อ ͳ͠ *NQPSUFS $MPVE3VO $47σʔλΛνΣοΫ͠ #JH2VFSZʹ&YQPSU (Pͷ8FC"1* 1VC4VC5PQJD͔Βىಈ %8) #JH2VFSZ ੳऀPSΞϓϦ͔Β͏ %BUB8BSF)PVTF 42-Ͱ7JFXΛ࡞ͬͯӡ༻ ʲ࠶ܝʳ֤Micro ServiceͰͬͯΔϞϊͱղઆ શ෦खಈͰઃఆ͢Δͱഁ͢Δະདྷ͕͍ͬͯ·͢ʂ
Micro ServiceʹTerraform͖Ͱ͢Ͷઆ. • ෳͷΞϓϦέʔγϣϯΛचͭͳ͗ʢϐλΰϥεΠονʣ͢Δ߹, TerraformΛೖΕ͓ͯ͜͏, খنͰ͋ͬͨͱͯ͠. • ࠓճͷߏͰ·͋·͋ͷͷGoogle CloudͷServiceΛར༻. •
Cloud RunΞϓϦ͕3ݸ + Volume, LoggingͳͲͷݻ༗ઃఆ • Pub/Sub TopicͱSchema͕ͦΕͧΕ2ݸ • Cloud Schedulerͷઃఆ • Cloud StorageͷBucketͱΞΫηε੍ޚ • ͜ΕΒͱ৭ʑඥͮ͘ઃఆ, ಛʹService Account͓ΑͼIAM←͜Ε͕࠷ۂऀʢηΩϡϦςΟతʹʣ • ҎલCloud Console or GUIͰ࡞͍͕ͬͯͨഁ͢Δʢྫ: ʹ͕֮͑ແ͍Service Account, InstanceͳͲʣͷͰࠓ͔ΒIaCԽ. ઃܭͱ࣮ͷॳظίετʢओʹ࣌ؒͱΩϟονΞοϓʣͳ͍Ͱ͕͢, ࢿͨ͠΄͏͕ઈରʹྑ͍.
Google CloudͰTerraformΛ࢝ΊΔ࣌ • Quick StartͳͲ, ެࣜυΩϡϝϯτʹsnippet͕͋ΔͷͰ͓͏ʂ • gcloud commandGUIઃఆͱͷฒͼʹTerraformͷsnippet͕ଘࡏ. •
ࢲެࣜυΩϡϝϯτͷTerraformͷsnippetΛmain.tfʹషΓ͚, ಈ࡞ ֬ೝ͠ͳ͕Βຊ൪༻ͷ࣮Λߦͬͨʢ͘͢͝ḿͬͨʣ. શͯͷυΩϡϝϯτʹ͋Δ༁Ͱແͦ͞͏͕ͩੵۃతʹ͓͏.
݁ͼ • Cloud RunͱCloud Pub/Sub͚ͩͰ͓҆͘σʔλج൫࡞ΕΔ. • ෳࡶʹͳΓ͕ͪͳMicro ServiceIaCԽ͠·͠ΐ͏, झຯͰ. •
⚾γʔζϯ࢝·ͬͨΒຊ֨ӡ༻͠·͢&ͦͷͲ͔͜Ͱ·ͨ. ͱΓ͋͑ͣσʔλج൫తͳϞϊ͕ཉ͘͠ͳͬͨΒਅࣅΞϦ͔ͳͱ. গͳ͘ͱCloud Run૬͑·͢ʢϑΝϯͳͷͰେͰݴ͏ʣ.
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠. Shinichi Nakagawa ©Shinichi Nakagawa