4.2 コンピュート
GCP Compute Services
GCPのコンピュートサービスは、Compute Engine(IaaS)からCloud Run(コンテナサーバーレス)まで、柔軟な選択肢を提供する。特にGKEはKubernetesの開発元であるGoogleが提供するマネージドサービスとして、先進的な機能を備える。
Compute Engine
@startuml
skinparam backgroundColor #FEFEFE
rectangle "プロジェクト" as Project #F3F4F6 {
rectangle "VPCネットワーク" as VPC #E5E7EB {
rectangle "サブネット (us-central1)" as Subnet #DBEAFE {
rectangle "VMインスタンス" as VM #93C5FD {
rectangle "マシンタイプ" as Machine #60A5FA
rectangle "ブートディスク" as Boot #60A5FA
rectangle "追加ディスク" as Data #60A5FA
}
}
}
rectangle "ファイアウォールルール" as FW #FCA5A5
rectangle "外部IP" as ExtIP #FEF3C7
rectangle "サービスアカウント" as SA #D1FAE5
}
FW --> Subnet
ExtIP --> VM
SA --> VM
note bottom of VM
ライブマイグレーション:
メンテナンス時も
ダウンタイムなし
end note
@enduml
図1: Compute Engineインスタンスの構成
| マシンファミリー | 用途 | 特徴 |
|---|---|---|
| E2(汎用) | 開発、小規模Web | コスト最適化 |
| N2/N2D(汎用) | 本番ワークロード | バランス型 |
| C2/C2D(コンピュート) | HPC、ゲームサーバー | 高クロックCPU |
| M2/M3(メモリ) | SAP HANA、インメモリDB | 最大12TB RAM |
| A2/G2(アクセラレータ) | ML推論/トレーニング | NVIDIA GPU搭載 |
GCP独自機能: カスタムマシンタイプ
GCPではvCPUとメモリを自由に組み合わせてカスタムマシンタイプを作成できる。AWSやAzureの定型サイズと異なり、ワークロードに最適なリソース配分が可能。
GCPではvCPUとメモリを自由に組み合わせてカスタムマシンタイプを作成できる。AWSやAzureの定型サイズと異なり、ワークロードに最適なリソース配分が可能。
Cloud Run
@startuml
skinparam backgroundColor #FEFEFE
actor "ユーザー" as User
rectangle "Cloud Run" as CloudRun #D1FAE5 {
rectangle "サービス" as Service #6EE7B7 {
rectangle "リビジョン1\n(コンテナ)" as Rev1 #34D399
rectangle "リビジョン2\n(コンテナ)" as Rev2 #34D399
}
}
rectangle "トラフィック分割" as Traffic #FEF3C7
database "Cloud SQL" as SQL
storage "Cloud Storage" as GCS
queue "Pub/Sub" as PubSub
User --> Traffic
Traffic --> Rev1 : 90%
Traffic --> Rev2 : 10%
Service --> SQL
Service --> GCS
PubSub --> Service : イベント駆動
note bottom of CloudRun
特徴:
- コンテナをサーバーレス実行
- 自動スケール (0まで)
- HTTPリクエスト or イベント駆動
- 従量課金 (リクエスト + CPU時間)
end note
@enduml
図2: Cloud Runのアーキテクチャ
| サービス | 実行単位 | ユースケース |
|---|---|---|
| Cloud Functions | 関数 | イベント処理、軽量API |
| Cloud Run | コンテナ | Webアプリ、API、バッチ |
| GKE Autopilot | Pod | 複雑なマイクロサービス |
| Compute Engine | VM | フル制御が必要な場合 |
GKE(Google Kubernetes Engine)
@startmindmap skinparam backgroundColor #FEFEFE * GKE ** Standard モード *** ノード管理: ユーザー *** カスタマイズ自由度高 *** 既存K8s知識を活用 *** コスト最適化可能 ** Autopilot モード *** ノード管理: Google *** Pod単位課金 *** セキュリティ自動強化 *** 運用負荷軽減 *** AWS Fargateに類似 left side ** GKEの強み *** Kubernetes開発元 *** 最新バージョン先行対応 *** マルチクラスタ管理 (Fleet) *** Config Connector *** Binary Authorization ** 比較 *** EKS: AWS統合に強み *** AKS: Azure AD統合 *** GKE: 純粋なK8s体験 @endmindmap
図3: GKE StandardとAutopilotの比較
GKEはKubernetesの開発元であるGoogleが提供するマネージドサービスである。Autopilotモードでは、ノードのプロビジョニングやスケーリングをGoogleが自動管理し、ユーザーはPodの定義のみに集中できる [1]。
出典
[1] Google Cloud. GKE Documentation. https://cloud.google.com/kubernetes-engine/docs/
[2] Google Cloud. Cloud Run Documentation. https://cloud.google.com/run/docs/
[2] Google Cloud. Cloud Run Documentation. https://cloud.google.com/run/docs/
発展学習
→ GKE Autopilot vs Standard
→ Cloud Run vs Cloud Functions
→ GKE Autopilot vs Standard
→ Cloud Run vs Cloud Functions