Skip to main content
友田 陽大

Category

Google Cloud Run 本番運用ガイド(コンテナ契約・並行性/スケールトゥゼロ・リクエスト課金/インスタンス課金・リビジョンとトラフィック分割・最小権限SAとSecret Manager・Direct VPC egress・コスト最適化・技術選定)

Cloud Runは『コード・関数・コンテナをGoogleのインフラ上で動かす』フルマネージドのサーバーレス基盤で、ノードもクラスタも持たずにコンテナを本番運用できます。本クラスタは、Cloud Runを採用した後の『どう本番で作るか』に集中します——$PORTで0.0.0.0待受・SIGTERMで10秒以内に後始末・状態を持たない・重い処理はJobs/Workflowsへ切り離すというコンテナ契約、原価とスケールを決める並行性(既定80・最大1000)、60%使用率を目標にゼロまで縮むオートスケールと最小/最大インスタンス、リクエスト課金とインスタンス課金を稼働率で選ぶコスト設計、リビジョンの不変スナップショットを使ったトラフィック分割(カナリア→Blue/Green→即時ロールバック)、startup/livenessプローブ、サービスごとの最小権限サービスアカウントとSecret Manager(環境変数=起動時固定/ボリューム=常に最新)・認証必須・Cloud Armor、コネクタ常駐費を消すDirect VPC egress、そしてCloud Run/GKE Autopilot/App Engine/Cloud Run functionsの技術選定まで——可観測性・回復性・冪等性・最小権限・コスト効率・テスト容易性を軸に体系化します。国内大手放送事業者の社内AIプラットフォームをGCP上にTerraformでIaC構築し、Cloud Run(サービス+ジョブ)でFastAPI・音声合成・OCRパイプライン・ClamAVマルウェアスキャナを本番運用し、Workload Identity Federationで鍵レスCI/CDを組んだ知見を根拠に、Google Cloud公式ドキュメントに忠実な実コードで解説します。AWS ECS on Fargate・Azure Container Appsとのクロスクラウドの勘所は地続きで、各クラスタからも相互に参照できます。

7 articles in total

Foundational guide

Foundational guide (start here)

GCP
Cloud Run
サーバーレス
コンテナ
インフラ

Google Cloud Run Production-Operations Guide: Container Contract, Concurrency, Auto-Scale, Deploy, Cost, and Security in Real Code

A Cloud Run production-operations guide faithful to the Google Cloud official documentation. From the container contract (PORT/SIGTERM), concurrency (default 80, max 1000), scale-to-zero, request billing and instance billing, traffic splitting by revisions (Blue/Green, canary), health checks, least-privilege service accounts and Secret Manager, to Direct VPC egress — systematized with real gcloud, Terraform, and FastAPI/Node code.

22 min read

Related practical articles