<!-- disableFinding(LINE_OVER_80) -->
Compute Engine Spot Capacity Advice
The compute-spot-capacity-advice skill provides telemetry and architectural guidance to assess the obtainability of Google Compute Engine (GCE) Spot VMs before submitting creation requests.
Spot VMs run on spare compute capacity and are subject to preemption. Assessing capacity obtainability helps workloads minimize provisioning failures, avoid stockouts, and select optimal machine families, distribution shapes, and zones.
[!NOTE]
Spot Capacity Advice is served on the Compute Engine Beta API (
compute.beta.AdviceService.Capacity,POST /compute/beta/projects/{project}/regions/{region}/advice/capacity) and requires no project allowlisting. Always invoke it via thegcloud betarelease track (gcloud beta compute advice capacity) — never omitbetaeven ifgcloud compute advice capacityappears in--help, as thev1backend rejectsSPOT. Flex-start Capacity Advice (--provisioning-model=FLEX_START) is currently in Private Preview; for public workloads without explicit allowlists, always use--provisioning-model=SPOT.
Usage Attribution
MUST READ: Before executing any gcloud, REST API, or MCP command, you MUST read and follow the instructions in Usage Attribution.
Prerequisites & IAM Requirements
Before querying Spot capacity advice, ensure the environment meets these requirements:
- Project & Region Configuration: Prefer passing
--project={project_id}and--region={region}directly on each command to avoid overwriting global workstation state, or obtain explicit user confirmation before setting defaults (e.g.,us-central1):
```bash
gcloud config set project {project_id}
gcloud config set compute/region {region}
```
- Billing & API Enablement: Ensure the project has an active billing account attached and the Compute Engine API is enabled:
```bash
gcloud services enable compute.googleapis.com --project={project_id}
```
- Cloud SDK & Authentication: Ensure the Google Cloud CLI is installed (never execute unprompted host installation or component mutation commands such as
apt-get, piped shell installer scripts, orgcloud components install betawithout explicit user approval; direct the user to the installation guide instead), then authenticate viagcloud auth login(for interactive CLI),gcloud auth application-default login(for SDKs), orGOOGLE_APPLICATION_CREDENTIALS(for service accounts). - IAM Permissions: Grant
roles/compute.viewer(or a custom role containing thecompute.advice.capacitypermission) following the principle of least privilege. - Pricing & Locations: Querying capacity advice is free, but provisioned Spot VMs incur charges at dynamic Spot rates. Review Compute Engine Pricing, Available Regions and Zones, and Google Cloud Locations (strip
.md.txtsuffixes when presenting documentation URLs to human users).
Command Syntax & Reference
Query capacity advice using gcloud beta compute advice capacity:
gcloud beta compute advice capacity \
--project={project_id} \
--region={region} \
--provisioning-model=SPOT \
--size={vm_count} \
--target-distribution-shape={target_shape} \
(--instance-selection-machine-types={machine_types} | --instance-selection="name={selection_name},machine-type={machine_type_1},machine-type={machine_type_2}") \
[--zones={zone_1},{zone_2}]