Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Cloud Run でシェルスクリプトを動かす
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Takumasa Sakao
June 29, 2019
Technology
2.9k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Cloud Run でシェルスクリプトを動かす
Takumasa Sakao
June 29, 2019
More Decks by Takumasa Sakao
See All by Takumasa Sakao
k9s のプラグイン機構とモダンな watch コマンド、viddy の紹介
sachaos
0
1.6k
GAE を利用したゲーム内通貨管理サービスの運用〜可用性を損なわないための工夫〜
sachaos
0
1.3k
Go の静的解析ツールの作成と活用
sachaos
0
3.2k
レイトレーシングとGoroutine
sachaos
2
1.3k
OSSを作っている時に 考えていること ーUNIX哲学を添えてー
sachaos
2
610
GCPをフル活用したゲームログ収集基盤の構築
sachaos
6
3.2k
Other Decks in Technology
See All in Technology
Claude Code on Bedrock で統制をかける小ネタ集/claude-code-bedrock-governance-tips
emiki
1
8.4k
Refining Active Record
shugo
0
220
「Docker Desktop不要の時代」は来たのか?」
ueponx
0
100
Microsoft のサポート ライフサイクルを理解する
murachiakira
PRO
0
150
Browser Spec: Testing Hotwire with Ruby
takahashim
1
170
PHPカンファレンス関西の招待状 / Invitation to PHP Conference Kansai
ykanoh
0
230
Practical ransomware detection on macOS (via maths, not AI)
patrickwardle
0
110
AI駆動開発におけるハーネスエンジニアリングの勘所
tsukuboshi
1
660
freeeにおけるSoftware Factory
freee
PRO
0
420
React改造してみた
tsukina_7mochi
0
160
LambdaWebFunctionsを試してみた / exploring-lambda-web-functions
koukihosaka
1
400
国際カードブランドルール変更に伴うクレジットカード決済取引仕様変更について
k1style
0
200
Featured
See All Featured
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.4k
Making the Leap to Tech Lead
cromwellryan
135
10k
Everyday Curiosity
cassininazir
0
360
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.7k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
440
The agentic SEO stack - context over prompts
schlessera
0
980
How to build a perfect <img>
jonoalderson
1
6.2k
A Modern Web Designer's Workflow
chriscoyier
699
190k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
280
Agile that works and the tools we love
rasmusluckow
331
22k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
2
2.1k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
2
370
Transcript
Cloud Run で シェルスクリプトを動かす 株式会社アカツキ @sachaos
自己紹介 @sachaos 株式会社アカツキにてサーバーサイドエンジニア Go, GCPとか好き
Cloud Run とはなにか? • コンテナをサーバーレスで動かす Google Cloud Platform のサービス •
Cloud Run は マネージドの Cloud Run と Cloud Run on GKE がある ◦ 今日話すのは マネージドの Cloud Run だけ! • 現在 Beta バージョン • US リージョンのみ提供 • サーバーレス ◦ 使った分だけ費用が発生する ◦ オートスケールする ◦ 0 までスケールする ◦ つまり、全く使わなければ無料
Demo • Hello World するサーバーをデプロイしてみる gcloud beta run deploy hello
\ --image gcr.io/google-samples/hello-app:2.0 \ --region us-central1 \ --allow-unauthenticated
Cloud Run • Kubernetes 上でサーバーレス環境を構築する Knative というOSSをベースに作られている • PORT環境変数で指定されたポートでサーブする HTTPサーバのコンテナを用意すればそれをサーバーレスで動かせる
• コンテナを用意すればどんな言語で書かれたコード、バイナリでも動かすことができ る
Cloud Run で シェルスクリプト動かせたら 便利そうじゃない?
Cloud Run でシェルスクリプトを実行する • HTTP リクエストを受けたら 事前に渡されたシェルスクリプトを実行するようなものを雑に作ってみた • https://github.com/sachaos/cloud-exec
Cloud Exec cloud-exec ./echo.sh localhost:8080 ./echo.sh
GitHub の星の取得数を Slack に通知する 1. シェルスクリプトを書く a. https://github.com/yyx990803/starz の結果をごにょごにょして Slack
Webhook に POST 2. 使用するコマンドなど、依存をコンテナに詰める 3. Cloud Run にデプロイする 4. 定期的に叩くようにする こういうのをSlackに定期的に投げたい →
1. シェルスクリプトを書く
2. 依存をコンテナに詰める
3. Cloud Run にデプロイ
できた
4. 定期的に叩くようにする • Cloud Scheduler という GCP のマネージド cron サービスを使う
• 指定した時間に特定の HTTP リクエストを発行することが可能
まとめ • Cloud Run は簡単にデプロイして公開できるしオートスケールするし最高 • Cloud Run でシェルスクリプトを走らせる cloud-exec
を紹介しました • 安易バッチサーバとして 雑にスクリプトを走らせるようなことを行いました • 色々応用できそう ◦ 紹介したようにコマンドで得られる情報を定期的に Slackにポストしたり ◦ 負荷試験するコンテナを整えて雑に大規模負荷試験をしたり
以上、ありがとうございました