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
2.9k
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.4k
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
77
72k
阪神タイガース優勝のひみつ - Pythonでシュッと調べた件 / SABRmetrics for Python
shinyorke
PRO
1
1.3k
Pythonとクラウドと野球の推し活. / Baseball Data Platform for Python and Google Cloud
shinyorke
PRO
2
2.7k
月額コーヒー3.34杯分のコストでオオタニサンの活躍を見守るデータ基盤のはなし / Pyhack Con
shinyorke
PRO
2
470
俺のDXを実現するためのサーバレスなデータ基盤開発と運用 / Serverless Data Platform and Baseball
shinyorke
PRO
5
11k
機械学習エンジニアが目指すキャリアパスとその実話 / My Journey to Become a ML Engineer
shinyorke
PRO
9
16k
一人でも小さく始められるGoogle Cloudで実現するほぼサーバレスなデータ基盤 / Serverless Dataplatform for Google Cloud
shinyorke
PRO
0
540
Other Decks in Programming
See All in Programming
RWC 2024 DICOM & ISO/IEC 2022
m_seki
0
200
生成AIでGitHubソースコード取得して仕様書を作成
shukob
0
200
フロントエンドのディレクトリ構成どうしてる? Feature-Sliced Design 導入体験談
osakatechlab
8
4.1k
今年のアップデートで振り返るCDKセキュリティのシフトレフト/2024-cdk-security-shift-left
tomoki10
0
190
たのしいparse.y
ydah
3
120
103 Early Hints
sugi_0000
1
220
create_tableをしただけなのに〜囚われのuuid編〜
daisukeshinoku
0
240
talk-with-local-llm-with-web-streams-api
kbaba1001
0
170
Full stack testing :: basic to basic
up1
1
930
Асинхронность неизбежна: как мы проектировали сервис уведомлений
lamodatech
0
650
LLM Supervised Fine-tuningの理論と実践
datanalyticslabo
3
960
事業成長を爆速で進めてきたプロダクトエンジニアたちの成功談・失敗談
nealle
3
1.4k
Featured
See All Featured
We Have a Design System, Now What?
morganepeng
51
7.3k
Gamification - CAS2011
davidbonilla
80
5.1k
Typedesign – Prime Four
hannesfritz
40
2.4k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.9k
How STYLIGHT went responsive
nonsquared
95
5.2k
GraphQLとの向き合い方2022年版
quramy
44
13k
Designing for humans not robots
tammielis
250
25k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
Reflections from 52 weeks, 52 projects
jeffersonlam
347
20k
[RailsConf 2023] Rails as a piece of cake
palkan
53
5k
Fireside Chat
paigeccino
34
3.1k
Designing for Performance
lara
604
68k
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