AGENT SKILL

compute-spot-capacity-advice

Evaluates Google Compute Engine (GCE) Spot VM capacity obtainability, placement likelihood, and machine family or regional flexibility. Use when planning batch workloads, finding available Spot CPU or GPU capacity, assessing stockout risks, or optimizing instance distribution across zones. Don't use for TPU availability, on-demand reservation capacity (use compute-on-demand-reservations), or future GPU/TPU calendar bookings (use compute-future-reservations).

License 许可
Apache-2.0
所属仓库
google/skills
最近更新
2026-11-14
Stars
★ 2.4w
Forks
2.0k

01 前言 Front Matter

name
compute-spot-capacity-advice
metadata
{ "version": "1.0.0", "category": "Compute" }
description
Evaluates Google Compute Engine (GCE) Spot VM capacity obtainability, placement likelihood, and machine family or regional flexibility. Use when planning batch workloads, finding available Spot CPU or GPU capacity, assessing stockout risks, or optimizing instance distribution across zones. Don't use for TPU availability, on-demand reservation capacity (use compute-on-demand-reservations), or future GPU/TPU calendar bookings (use compute-future-reservations).

02 资源文件 1

03 SKILL.md 正文

<!-- 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 the gcloud beta release track (gcloud beta compute advice capacity) — never omit beta even if gcloud compute advice capacity appears in --help, as the v1 backend rejects SPOT. 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:

  1. 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):
    gcloud config set project {project_id}
    gcloud config set compute/region {region}
    
  2. Billing & API Enablement: Ensure the project has an active billing account attached and the Compute Engine API is enabled:
    gcloud services enable compute.googleapis.com --project={project_id}
    
  3. 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, or gcloud components install beta without explicit user approval; direct the user to the installation guide instead), then authenticate via gcloud auth login (for interactive CLI), gcloud auth application-default login (for SDKs), or GOOGLE_APPLICATION_CREDENTIALS (for service accounts).
  4. IAM Permissions: Grant roles/compute.viewer (or a custom role containing the compute.advice.capacity permission) following the principle of least privilege.
  5. 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.txt suffixes 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}]

Flag Reference & CLI Constraints

For complete flag definitions, refer to the gcloud beta compute advice capacity reference documentation. When constructing commands, apply these non-obvious CLI constraints:

  • --region vs. --zones: --region is automatically inferred when --zones is specified.
  • --size Bounds: Accepts 1 to 1000 VMs per query.
  • --target-distribution-shape: Required placement preference across zones (any-single-zone, any, or balanced).
  • Instance Selection & Unsupported Flags: Specify up to 5 machine types total across the request using a single --instance-selection-machine-types flag, a single --instance-selection flag (gcloud supports only one --instance-selection flag per command), or --instance-flexibility-policy (up to 10 named selections). Do not pass --max-run-duration, --accelerator-topology, rank, min-cpu-platform, minCpuPlatform, or disks on the CLI.

Output Interpretation: Scores & Recommendations

The command returns one or more recommendations containing placement shards and evaluation scores (or {} if zero candidate zones in the region support the requested machine series; regional stockouts still return a recommendation with obtainability: 0.1 and estimatedUptime: 60s), as shown in the following example output:

# Example output
recommendations:
- scores:
    obtainability: 0.9
    estimatedUptime: 3600s
  shards:
  - instanceCount: 100
    machineType: n2-standard-32
    provisioningModel: SPOT
    zone: https://compute.googleapis.com/compute/beta/projects/example-project/zones/us-central1-a

Score Evaluation Rubric

Refer to View the availability of Spot VMs for full definitions of scores.obtainability (0.0 to 1.0, emitted in discrete buckets such as 0.9, 0.5, and 0.1) and scores.estimatedUptime (3600s, 600s, or 60s). Treat obtainability >= 0.7 as strongly obtainable, 0.4–0.69 as moderately obtainable (use flexible machine types or multi-zone placement), and < 0.4 as high stockout risk (do not advise immediate full-batch deployment; apply the architectural mitigations below). Interpret scores.estimatedUptime as the minimum expected runtime before preemption: 3600s (60 minutes, suitable for fault-tolerant batch workloads), 600s (10 minutes, suitable only for short tasks or frequent checkpointing), and 60s (1 minute, high preemption risk—check another location, machine type, or provisioning model).


Architectural Mitigation & Best Practices

When capacity is constrained (obtainability < 0.4 or empty {} returned when the machine series is unavailable in the region):

  1. Broaden Distribution Shape:
    • Switch from --target-distribution-shape=any-single-zone to --target-distribution-shape=any (or balanced) so Compute Engine can distribute instances across all available zones in the region.
  2. Inject Instance Flexibility:
    • Add alternative machine shapes within the same generation (e.g., n2-standard-32, n2-standard-48) or across families (e.g., c2-standard-30, c3-standard-44) using --instance-selection or --instance-selection-machine-types (note that Gen 4+ families such as c4*, n4*, m4*, h4d*, a4*, and a3-ultragpu-8g require Hyperdisk boot volumes rather than pd-* disks when creating instances or templates; for newly released machine series, verify supported disk types via gcloud compute machine-types describe or the official machine family documentation).
  3. Regional Fallbacks:
    • Evaluate adjacent regions with similar network latency or billing characteristics (e.g., fallback from us-central1 to us-east4, us-west1, or us-east1).
  4. Accelerator, SKU & Zone Limitations:
    • gcloud beta compute advice capacity evaluates GPU capacity via integrated accelerator machine types (such as g2-standard-*, a2-highgpu-*, a3-highgpu-*, a3-megagpu-*) and includes AI zones by default (users should confirm that AI zones are enabled for their project). Do not pass --accelerator-topology, and restrict --instance-selection strictly to name and machine-type (do not pass rank, min-cpu-platform, disks, or guest accelerator flags on the gcloud CLI; n1-* VMs with attached guest GPUs and machine types with non-default Local SSDs are supported only on the Beta REST API under instanceFlexibilityPolicy.instanceSelections.{selection_name} via guestAccelerators and disks with one type: SCRATCH entry per Local SSD disk).
    • Unsupported Spot SKUs, Free Tier & Day-0 Immutability: Spot VMs do not support a4x-* or bare metal (*-metal) shapes, Spot e2-micro VMs do not qualify for the Google Cloud Free Tier allowance, and existing STANDARD VMs cannot be converted in place to SPOT via set-scheduling (requires recreating the VM).
    • No TPU Availability Support: The advice.capacity API does not support viewing the availability of Cloud TPUs. For TPU capacity planning and calendar bookings, use compute-future-reservations (gcloud compute advice calendar-mode).
  5. Quota & Headroom Disclaimer:
    • Obtainability scores reflect physical datacenter capacity, not project quota allocation. Verify regional Spot CPU/GPU quota (via gcloud compute regions describe {region}, gcloud compute project-info describe, or the Google Cloud Console Quotas page) before provisioning. Attempting to launch instances without sufficient project quota will fail at runtime despite high physical capacity availability.
  6. Read-Only Advisory, Hardened VM Defaults & MCP Guardrail:
    • Capacity advice is strictly a read-only advisory tool. Never execute mutating commands (such as gcloud compute instances create or gcloud compute instances delete) without explicit human approval from the user; provide copy-pasteable commands instead.
    • When generating gcloud compute instances create commands for Spot VMs, recommend private networking (--no-address paired with IAP TCP forwarding), a custom least-privilege service account (--service-account), and --instance-termination-action=DELETE (so boot disks do not continue billing after Spot preemption). Remind users to delete temporary Spot VMs (gcloud compute instances delete {vm_name} --zone={zone}, which prompts interactively unless --quiet is passed) when workloads finish.
    • Compute Engine MCP create_instance Guardrail: Inspect the in-session MCP create_instance tool schema before invoking it (in case newer MCP server versions add support); unless verified in the current schema, MCP create_instance omits provisioning_model (silently provisioning full-price STANDARD VMs), hardcodes global/networks/default, and cannot set custom service accounts — always use gcloud compute instances create --provisioning-model=SPOT instead.

04 同仓库更多 Skills

google
google/skills

cloud-operator-share-context

Shares Google Cloud operating context the user or their team already have — environments, projects, services and regions, product preferences, best practices, architecture guidance, runbooks — found in agent instruction files, local memory, skills and workflows, and the repository's GCP docs, with the operator agent's memory after the user reviews the list. Use when the user runs this skill, accepts the cloud-operator or cloud-operator-setup skill's offer to share their existing Google Cloud context, or asks to share, import or save that context or a GCP fact for the operator agent. Don't use for ordinary GCP requests, which go to the cloud-operator skill.

★ 2.4w
google
google/skills

cloud-operator-setup

Sets up the operator agent in a Google Cloud project via the autocloud MCP server: picks the operator project, creates or checks the user's operator agent, saves the project, and offers to share the user's existing Google Cloud operating context with the operator agent's memory. Use when the user runs this skill, asks to set up the operator or create their operator agent, or chooses setup when the cloud-operator skill asks. Don't use for ordinary GCP requests or installing gcloud.

★ 2.4w
google
google/skills

developer-device-platform-device-run

Runs automated, non-interactive jobs on remote Android devices with Developer Device Platform (DDP) Device Run using `gcloud beta device-run sessions`: native Android executables or shell scripts (for example CLI tools, custom runners, test harnesses or benchmarks) and Android instrumentation tests, on one or many devices, then waits for completion and collects per-device outputs and logs. Use when running a binary or test suite on remote devices without an interactive connection. Don't use it for interactive device reservations, adb tunnels or screen streaming (use developer-device-platform-basics), or for local devices.

★ 2.4w
google
google/skills

compute-vm-creation

Guides the planning, configuration, and provisioning of standalone Google Compute Engine virtual machines (VMs) and bare metal (-metal) instances using gcloud CLI commands or direct MCP tool execution. Use ONLY when the user wants to create, configure, or provision a new standalone Compute Engine VM or bare metal instance from conversational intents (hardware sizing, region selection, OS image, networking, security defaults). DO NOT read or use for Google Kubernetes Engine (GKE) Autopilot or Standard clusters, Kubernetes node pools or Pods, container orchestration, managing existing VMs, Managed Instance Groups (MIGs), or Instance Templates.

★ 2.4w
google
google/skills

agent-platform-autorater-customization

Customizes an autorater (evaluation metric) for an AI agent so its grades match the user's own judgment, starting from the agent's real trajectories. Use when a user wants a metric tailored to their agent, wants to turn failing trajectories into rubrics, says an existing autorater grades their agent wrong, or wants an autorater to agree with human labels (autorater hillclimbing, judge calibration). Don't use for quick evals with built-in metrics or for improving the agent itself (use agent-platform-eval-flywheel).

★ 2.4w
google
google/skills

iap-agent-platform-troubleshooting

Diagnoses Identity-Aware Proxy (IAP) denials of outbound requests from Gemini Enterprise Agent Platform agents that run on Agent Runtime and send traffic through Agent Gateway. Use when an agent request fails with "Egress request is not authorized", when Cloud Audit Logs show an IAP egressViaIAP decision with granted false, when IAP audit entries are missing while debugging agent egress, or when Access policies, IAP allow policies, policy bindings, or Agent Registry entries might block agent egress. Don't use for Gemini model IAM permission errors (such as aiplatform.endpoints.predict), Agent Platform API errors, or Agent Runtime deployment or 500 errors (use agent-platform-troubleshooting instead). Don't use for setting up, creating, or connecting an Agent Gateway, or for IAP web apps, IAP TCP forwarding, or SSH.

★ 2.4w