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 でシェルスクリプトを動かす
Search
Takumasa Sakao
June 29, 2019
Technology
2.8k
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.2k
OSSを作っている時に 考えていること ーUNIX哲学を添えてー
sachaos
2
600
GCPをフル活用したゲームログ収集基盤の構築
sachaos
6
3.2k
Other Decks in Technology
See All in Technology
Data + AI Summit 2026 イベントレポート: 「AIがビジネスで意思決定するデータ基盤」へ
nek0128
0
260
「AIに依存している」と 「AIを使いこなしている」の違い
k8yasuma
0
110
誤解だらけの開発生産性 / Myths and Misconceptions about Developer Productivity
i35_267
2
780
第67回コンピュータビジョン勉強会CVPR2026読会前編
tsukamotokenji
0
140
企業でAWS Organizationsを動かすための組織設計の考え方
nrinetcom
PRO
1
110
知らん間に、回ってる
ming_ayami
0
710
Kaggleで成長するために意識したこと
prgckwb
2
410
「早く出す」より「事業に効く」 ── 顧客の業務サイクルから逆算するAI時代の二重ループ開発と「変化の設計者」 / devsumi2026
rakus_dev
1
350
脱金融のフューチャー・デザイン / Future Design Beyond Finance
ks91
PRO
0
150
AIと共生する開発者プラットフォーム:バクラクのモノレポ×マイクロサービス基盤
sakajunquality
2
3.7k
関数型の考えを TypeScript に持ち込んで、テストしやすい純粋関数を増やす / Pure at the Core, Effects at the Edge: Bringing Functional Thinking into TypeScript
kaminashi
2
130
ファミコンでPHPを動かす / PHP on the Famicom
tomzoh
2
330
Featured
See All Featured
Designing for Performance
lara
611
70k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
410
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
62
45k
Design in an AI World
tapps
1
260
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.6k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
490
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
240
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
360
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
380
Abbi's Birthday
coloredviolet
3
8.7k
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にポストしたり ◦ 負荷試験するコンテナを整えて雑に大規模負荷試験をしたり
以上、ありがとうございました