compute-vm-creation

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Compute Engine VM Creation

Compute Engine VM 创建

This skill provides an interactive, intent-based experience for provisioning standalone Google Compute Engine VM and bare metal (
-metal
) instances. It supports users ranging from beginners asking to "create a VM" to cloud engineers requiring customized infrastructure, mapping natural language intents to secure Compute Engine configurations grounded in the Golden Path.
MCP Tools:
list_instances
,
create_instance
,
get_instance_basic_info
,
delete_instance
,
get_zone_operation
,
list_machine_types
,
list_accelerator_types
,
list_images
此 skill 提供交互式、基于意图的体验,用于置备独立的 Google Compute Engine VM 和裸金属 (
-metal
) 实例。它支持从初学者(仅会提出“创建一台 VM”)到需要定制基础设施的云工程师,并将自然语言意图映射为基于 Golden Path 的安全 Compute Engine 配置。
MCP 工具:
list_instances
,
create_instance
,
get_instance_basic_info
,
delete_instance
,
get_zone_operation
,
list_machine_types
,
list_accelerator_types
,
list_images

Usage Attribution

使用归因

MUST READ: Before executing any
gcloud
, REST API, or MCP command, you MUST read and follow the instructions in Usage Attribution. Never include attribution environment variables or
User-Agent
tags in generated scripts, Terraform, or copy-pasteable commands shown to the user.

必须阅读:在执行任何
gcloud
、REST API 或 MCP 命令前,您必须阅读并遵循 使用归因 中的说明。生成面向用户的脚本、Terraform 或可复制粘贴命令时,绝不要包含归因环境变量或
User-Agent
标签。

Prerequisites

前提条件

Ensure the following setup requirements are met before provisioning instances. Any host modifications (such as installing or updating the
gcloud
CLI, installing or configuring the Google Compute Engine MCP server, or modifying local environment configuration) must be explicitly approved by the user before execution.
  • Cloud SDK Installation: Verify
    gcloud
    is installed (
    gcloud --version
    , Google Cloud SDK >= 480.0.0) only when executing live CLI commands. If missing or outdated, ask the user for explicit approval before installing or updating via Install the gcloud CLI.
  • Compute Engine MCP Server: For direct MCP tool execution (
    list_instances
    ,
    create_instance
    ,
    get_instance_basic_info
    ,
    delete_instance
    ,
    get_zone_operation
    ,
    list_machine_types
    ,
    list_accelerator_types
    ,
    list_images
    ), check whether the Compute Engine MCP tools are loaded in your active tool declarations, or ask the user for approval to configure the server following Use the Compute Engine MCP server.
  • Billing Account: Confirm the target Google Cloud project has an active billing account linked (required even when using Google Cloud Free Tier resources).
  • Authentication: Authenticate your environment for CLI execution (
    gcloud auth login
    ), application/MCP SDKs (
    gcloud auth application-default login
    ), or service account credentials (
    GOOGLE_APPLICATION_CREDENTIALS
    ).
  • Project Selection & API Enablement: Set the target project and enable the Compute Engine API:
    bash
    gcloud config set project {project_id}
    gcloud services enable compute.googleapis.com
  • Required IAM Roles:
    • Caller Roles:
      roles/compute.instanceAdmin.v1
      (to create and manage instances),
      roles/iam.serviceAccountUser
      (to attach
      {custom_service_account}
      ), and
      roles/mcp.toolUser
      when invoking the Compute Engine MCP server.
    • IAP SSH/RDP Access for Private (
      --no-address
      ) VMs
      : Connecting via
      gcloud compute ssh {vm_name} --zone={zone} --tunnel-through-iap
      requires
      roles/iap.tunnelResourceAccessor
      plus a VPC firewall rule allowing TCP
      22
      (or
      3389
      for RDP) from IAP's forwarding range
      35.235.240.0/20
      (see Use IAP for TCP forwarding).
    • Custom VM Service Account Setup: Fresh projects only contain the default Compute Engine service account. If
      {custom_service_account}
      does not yet exist, create a dedicated least-privilege service account first (seeking user approval before granting IAM bindings):
      bash
      gcloud iam service-accounts create {sa_name} \
        --project={project_id} \
        --display-name="{sa_display_name}"
      gcloud projects add-iam-policy-binding {project_id} \
        --member="serviceAccount:{sa_name}@{project_id}.iam.gserviceaccount.com" \
        --role="roles/logging.logWriter"
      gcloud projects add-iam-policy-binding {project_id} \
        --member="serviceAccount:{sa_name}@{project_id}.iam.gserviceaccount.com" \
        --role="roles/monitoring.metricWriter"

在置备实例前,请确保满足以下设置要求。任何主机修改(例如安装或更新
gcloud
CLI、安装或配置 Google Compute Engine MCP server,或修改本地环境配置)都必须先获得用户明确批准。
  • Cloud SDK 安装:仅在执行实时 CLI 命令时,验证是否已安装
    gcloud
    (
    gcloud --version
    ,Google Cloud SDK >= 480.0.0)。如果缺失或版本过旧,请先获得用户明确批准,再通过 安装 gcloud CLI 安装或更新。
  • Compute Engine MCP Server:对于直接执行 MCP 工具(
    list_instances
    、
    create_instance
    、
    get_instance_basic_info
    、
    delete_instance
    、
    get_zone_operation
    、
    list_machine_types
    、
    list_accelerator_types
    、
    list_images
    ),请检查活动的 tool declarations 中是否已加载 Compute Engine MCP 工具,或请求用户批准按照 使用 Compute Engine MCP server 配置 server。
  • Billing Account:确认目标 Google Cloud 项目已关联有效的 billing account(即使使用的是 Google Cloud Free Tier 资源,也必须满足此要求)。
  • 身份验证:为 CLI 执行(
    gcloud auth login
    )、应用/MCP SDK(
    gcloud auth application-default login
    )或 service account 凭据(
    GOOGLE_APPLICATION_CREDENTIALS
    )认证环境。
  • 项目选择与 API 启用:设置目标项目并启用 Compute Engine API:
    bash
    gcloud config set project {project_id}
    gcloud services enable compute.googleapis.com
  • 必需的 IAM Roles:
    • 调用方 Roles:
      roles/compute.instanceAdmin.v1
      (用于创建和管理实例)、
      roles/iam.serviceAccountUser
      (用于附加
      {custom_service_account}
      ),以及调用 Compute Engine MCP server 时的
      roles/mcp.toolUser
      。
    • 私有 (
      --no-address
      ) VM 的 IAP SSH/RDP 访问
      :通过
      gcloud compute ssh {vm_name} --zone={zone} --tunnel-through-iap
      连接时,需要
      roles/iap.tunnelResourceAccessor
      ,以及允许从 IAP 转发范围
      35.235.240.0/20
      访问 TCP
      22
      (RDP 则为
      3389
      )的 VPC firewall rule(参见 使用 IAP 进行 TCP 转发)。
    • 自定义 VM Service Account 设置:新项目仅包含默认的 Compute Engine service account。如果
      {custom_service_account}
      尚不存在,请先创建一个专用的最小权限 service account(授予 IAM bindings 前须获得用户批准):
    bash
    gcloud iam service-accounts create {sa_name} \
      --project={project_id} \
      --display-name="{sa_display_name}"
    gcloud projects add-iam-policy-binding {project_id} \
      --member="serviceAccount:{sa_name}@{project_id}.iam.gserviceaccount.com" \
      --role="roles/logging.logWriter"
    gcloud projects add-iam-policy-binding {project_id} \
      --member="serviceAccount:{sa_name}@{project_id}.iam.gserviceaccount.com" \
      --role="roles/monitoring.metricWriter"

Workflow

工作流

  1. Determine Execution Method & MCP Capability Boundary:
    • Fast Conversational Intake (No Shell Probing on Missing Inputs): When a user asks to configure or create a VM without providing mandatory inputs (
      project_id
      ,
      vm_name
      ,
      region
      /
      zone
      , or public vs. private networking), respond immediately after reading
      SKILL.md
      without running
      gcloud config list
      ,
      gcloud --version
      , or any shell commands
      . Clarify that you can either execute provisioning once confirmed (Automated Execution) or provide copy-pasteable
      gcloud
      commands / JSON payloads (Manual Execution), recommend a sizing tier, and ask for the missing inputs in a single turn.
    • MCP vs.
      gcloud
      Routing Rule
      : Compute Engine MCP discovery tools (
      list_instances
      ,
      get_instance_basic_info
      ,
      list_machine_types
      ,
      list_accelerator_types
      ,
      list_images
      ,
      get_zone_operation
      ) are ideal for read-only inspection. However, MCP
      create_instance
      (
      McpCreateInstanceRequest
      ) accepts only eight flat top-level fields (
      project
      ,
      zone
      ,
      name
      , bare
      machineType
      ,
      imageProject
      ,
      imageFamily
      ,
      guestAccelerators
      ,
      maintenancePolicy
      ) and hardcodes
      global/networks/default
      without
      --no-address
      , custom subnets, custom service accounts, Shielded VM flags, OS Login, Spot scheduling, or custom disk sizes/types. Route all hardened (
      --no-address
      , custom
      --subnet={subnet}
      ,
      {custom_service_account}
      , Shielded VM, OS Login), Spot, custom-disk, 4th-gen Hyperdisk, and bare metal (
      -metal
      ) creations to
      gcloud compute instances create
      (or REST
      instances.insert
      )
      rather than dropping security guardrails to fit
      create_instance
      . Use MCP
      create_instance
      only for default-VPC prototyping when default disk and service-account settings are explicitly acceptable.
  2. Gather Mandatory Inputs: ALWAYS ask the user for any missing inputs:
    • Project ID (Ask directly if not provided in the prompt).
    • VM Name (Offer a friendly default suggestion if unsure, e.g.,
      my-first-web-server
      ).
    • Region & Zone (Explain why simply: "Choosing a location closer to you or your users reduces latency and makes things load faster." Recommend
      us-central1
      /
      us-central1-a
      if the user has no preference, and consult Regions and zones, GPU regions and zones, or Google Cloud locations only when verifying non-default regional availability):
      bash
      gcloud config set compute/region {region}
      gcloud config set compute/zone {zone}
  3. Conversational Triage (Sizing, Generation & OS): Map the user's workload to the Intent-Based Sizing Tiers and hardware generation defaults:
    • Default OS images: Use
      debian-12
      (
      debian-cloud
      ) for
      E2
      ,
      N2
      ,
      C3
      virtualized, and
      C2D
      ; use
      debian-13
      (
      debian-cloud
      ) for 4th-gen (
      C4
      ,
      N4
      ,
      X4
      ) and bare metal (
      c3-standard-192-metal
      ,
      c4-standard-288-metal
      , where
      debian-12
      is unsupported); use
      debian-12-arm64
      /
      debian-13-arm64
      for Arm
      C4A
      ; and use
      common-cu129-ubuntu-2404-nvidia-580
      (
      deeplearning-platform-release
      ) for
      G2
      GPUs. Consult Operating system details and Bare metal instances only when selecting non-default OS images or bare metal SKUs.
    • Storage by generation: Use
      hyperdisk-balanced
      on 4th-gen (
      C4
      ,
      N4
      ,
      C4A
      ,
      C4D
      ,
      M4
      ,
      X4
      ,
      A4
      ) and bare metal (
      -metal
      ) instances where
      pd-*
      disks are rejected (
      N4
      supports
      hyperdisk-balanced
      and
      hyperdisk-throughput
      , not
      hyperdisk-extreme
      ;
      H3
      supports
      pd-balanced
      and
      hyperdisk-balanced
      ). Consult the "Machine series support for Hyperdisk" section of About Google Cloud Hyperdisk only for non-default disk types.
  4. Determine Network Accessibility & Subnet: ALWAYS ask in plain, non-technical language whether the VM needs to be reachable from the public internet or kept private, noting that private networking (
    --no-address
    ) is the security best practice—even when hosting a website or web app. Use
    --subnet={subnet}
    (verifying whether a custom/Shared VPC subnet or
    default
    VPC exists, since many enterprise projects enforce
    constraints/compute.skipDefaultNetworkCreation
    ).
  5. Configure Security, OS Login & Service Accounts: Enable IAM-governed SSH via
    --metadata=enable-oslogin=TRUE
    , recommend a custom least-privilege service account (
    {custom_service_account}
    ), and enable Shielded VM flags (
    --shielded-secure-boot
    ,
    --shielded-vtpm
    ,
    --shielded-integrity-monitoring
    ) on virtualized VMs (on standard x86
    -metal
    bare metal instances, pass
    --no-shielded-secure-boot
    and omit vTPM/integrity flags).
  6. Summarize & Confirm (Mode-Aware): Present a clear summary of the proposed VM configuration, cost profile, and architectural warnings:
    • Automated Execution Mode: Always ask for explicit user confirmation before executing any mutating provisioning command or tool call (e.g., "Would you like me to proceed with provisioning this configuration, or adjust any settings first?").
    • Manual /
      "Do not execute"
      Mode
      : Instruct the user to review and substitute any
      {snake_case}
      placeholders (such as
      {subnet}
      or
      {custom_service_account}
      ) before running the command in their terminal; do not offer to execute provisioning when tools are disconnected or execution was forbidden.
  7. Execute or Deliver Payloads:
    • Automated: Execute
      gcloud compute instances create
      (prefixed with
      CLOUDSDK_METRICS_REQUEST_ATTRIBUTION
      per Usage Attribution) for hardened/Spot/4th-gen/ bare-metal configurations, or call MCP
      create_instance
      for default-VPC prototyping, tracking progress via
      get_zone_operation
      and verifying via
      get_instance_basic_info
      .
    • Manual: Output formatted, copy-pasteable
      gcloud
      CLI commands (without
      --quiet
      or attribution prefixes) or JSON payloads with clear instructions.
  8. Verify, Deliver Next Steps & Teardown Guidance: Provide post-provisioning access steps (for example, via
    --tunnel-through-iap
    with
    gcloud compute ssh
    ) and always include teardown instructions (omitting
    --quiet
    so interactive confirmation prevents accidental data loss; see Delete a VM):
    bash
    gcloud compute instances delete {vm_name} --zone={zone} --delete-disks=all
    Remind the user to pass
    --delete-disks=all
    (or
    --keep-disks=all
    if retaining data) so persistent disks are not orphaned.

  1. 确定执行方式与 MCP 能力边界:
    • 快速对话收集(输入缺失时不探测 Shell):当用户要求配置或创建 VM,但未提供必需输入(
      project_id
      、
      vm_name
      、
      region
      /
      zone
      、公网或私网网络)时,读取
      SKILL.md
      后立即响应,不要运行
      gcloud config list
      、
      gcloud --version
      或任何 shell 命令。说明您可以在确认后执行置备(Automated Execution),也可以提供可复制粘贴的
      gcloud
      命令或 JSON payload(Manual Execution);同时推荐一个 sizing tier,并一次性询问缺失的输入。
    • MCP 与
      gcloud
      路由规则
      :Compute Engine MCP discovery tools(
      list_instances
      、
      get_instance_basic_info
      、
      list_machine_types
      、
      list_accelerator_types
      、
      list_images
      、
      get_zone_operation
      )非常适合只读检查。但是,MCP
      create_instance
      (
      McpCreateInstanceRequest
      )仅接受八个扁平顶层字段(
      project
      、
      zone
      、
      name
      、裸
      machineType
      、
      imageProject
      、
      imageFamily
      、
      guestAccelerators
      、
      maintenancePolicy
      ),并将
      global/networks/default
      硬编码为默认网络,不支持
      --no-address
      、自定义 subnet、自定义 service account、Shielded VM flags、OS Login、Spot scheduling 或自定义磁盘大小/类型。所有安全加固型(
      --no-address
      、自定义
      --subnet={subnet}
      、
      {custom_service_account}
      、Shielded VM、OS Login)、Spot、自定义磁盘、第 4 代 Hyperdisk 和裸金属 (
      -metal
      ) 创建请求,都必须路由至
      gcloud compute instances create
      (或 REST
      instances.insert
      ),不能为了适配
      create_instance
      而移除安全护栏。只有在用户明确接受默认磁盘和 service account 设置时,才可使用 MCP
      create_instance
      进行 default-VPC 原型开发。
  2. 收集必需输入:对于任何缺失的输入,始终向用户询问:
    • Project ID(如果提示中未提供,直接询问)。
    • VM Name(如果不确定,可友好地建议一个默认值,例如
      my-first-web-server
      )。
    • Region 与 Zone(用简单方式解释原因:“选择离您或您的用户更近的位置可以降低延迟,让内容加载得更快。” 如果用户没有偏好,推荐
      us-central1
      /
      us-central1-a
      ;仅在验证非默认区域可用性时查阅 Regions and zones、GPU regions and zones 或 Google Cloud locations):
    bash
    gcloud config set compute/region {region}
    gcloud config set compute/zone {zone}
  3. 对话分类(规格、generation 与 OS):将用户的工作负载映射到基于意图的规格层级和硬件 generation 默认值:
    • 默认 OS 映像:对
      E2
      、
      N2
      、
      C3
      虚拟化实例和
      C2D
      使用
      debian-12
      (
      debian-cloud
      );对第 4 代(
      C4
      、
      N4
      、
      X4
      )和裸金属实例(
      c3-standard-192-metal
      、
      c4-standard-288-metal
      ,这些实例不支持
      debian-12
      )使用
      debian-13
      (
      debian-cloud
      );对 Arm
      C4A
      使用
      debian-12-arm64
      /
      debian-13-arm64
      ;对
      G2
      GPU 使用
      common-cu129-ubuntu-2404-nvidia-580
      (
      deeplearning-platform-release
      )。仅在选择非默认 OS 映像或裸金属 SKU 时查阅 Operating system details 和 Bare metal instances。
    • 按 generation 选择存储:对第 4 代(
      C4
      、
      N4
      、
      C4A
      、
      C4D
      、
      M4
      、
      X4
      、
      A4
      )和裸金属 (
      -metal
      ) 实例使用
      hyperdisk-balanced
      ,因为这些实例会拒绝
      pd-*
      磁盘(
      N4
      支持
      hyperdisk-balanced
      和
      hyperdisk-throughput
      ,但不支持
      hyperdisk-extreme
      ;
      H3
      支持
      pd-balanced
      和
      hyperdisk-balanced
      )。仅在使用非默认磁盘类型时查阅 About Google Cloud Hyperdisk 中的“Machine series support for Hyperdisk”部分。
  4. 确定网络可访问性与 Subnet:始终使用通俗、非技术性的语言询问 VM 是否需要从公共互联网访问,还是应保持私有;同时说明,即使用于托管网站或 Web 应用,私有网络(
    --no-address
    )也是最佳安全实践。使用
    --subnet={subnet}
    ,并验证自定义/Shared VPC subnet 或
    default
    VPC 是否存在,因为许多企业项目会强制执行
    constraints/compute.skipDefaultNetworkCreation
    。
  5. 配置安全、OS Login 与 Service Accounts:通过
    --metadata=enable-oslogin=TRUE
    启用由 IAM 管理的 SSH,推荐自定义的最小权限 service account(
    {custom_service_account}
    ),并在虚拟化 VM 上启用 Shielded VM flags(
    --shielded-secure-boot
    、
    --shielded-vtpm
    、
    --shielded-integrity-monitoring
    );对于标准 x86
    -metal
    裸金属实例,传入
    --no-shielded-secure-boot
    ,并省略 vTPM/完整性 flags。
  6. 总结并确认(区分模式):清晰呈现拟议 VM 配置、成本概况和架构警告的摘要:
    • Automated Execution 模式:执行任何会修改资源的置备命令或工具调用之前,始终要求用户明确确认(例如:“您希望我继续按此配置置备,还是先调整某些设置?”)。
    • Manual /
      "Do not execute"
      模式
      :指导用户检查并替换所有
      {snake_case}
      占位符(例如
      {subnet}
      或
      {custom_service_account}
      ),然后再在终端中运行命令;当工具未连接或明确禁止执行时,不要主动提出代为置备。
  7. 执行或交付 Payload:
    • Automated:对安全加固、Spot、第 4 代或裸金属配置执行
      gcloud compute instances create
      (根据 Usage Attribution 添加
      CLOUDSDK_METRICS_REQUEST_ATTRIBUTION
      前缀),或对 default-VPC 原型调用 MCP
      create_instance
      ;通过
      get_zone_operation
      跟踪进度,并通过
      get_instance_basic_info
      进行验证。
    • Manual:输出格式规范、可复制粘贴的
      gcloud
      CLI 命令(不带
      --quiet
      或归因前缀)或 JSON payload,并提供清晰说明。
  8. 验证、交付后续步骤与拆除指导:提供置备后的访问步骤(例如通过
    --tunnel-through-iap
    使用
    gcloud compute ssh
    ),并且始终包含拆除说明(省略
    --quiet
    ,让交互式确认防止意外数据丢失;参见 Delete a VM):
    bash
    gcloud compute instances delete {vm_name} --zone={zone} --delete-disks=all
    提醒用户传入
    --delete-disks=all
    (如需保留数据则传入
    --keep-disks=all
    ),避免遗留孤立 persistent disks。

Intent-Based Sizing Tiers

基于意图的规格层级

If a user says "I want to create a VM" or is unsure of hardware specs, use this table to recommend a tier. Point users to Google Cloud pricing and Compute Engine pricing for current regional rates rather than quoting hardcoded dollar figures.
Conversational TierBest For...Underlying MachineBoot Disk (Default)Cost Profile
Starter Tier (Dev/Test & Learning)"I just want to play around," "I'm learning Linux," "I have a tiny hobby script."
e2-micro
(Free Tier eligible) or
e2-small
10 GB Standard Disk (
pd-standard
; Free Tier covers up to 30 GB
pd-standard
)
Very Low (Google Cloud Free Tier covers one non-preemptible
e2-micro
instance/month
in
us-west1
,
us-central1
, or
us-east1
only;
e2-small
or other regions incur standard billing immediately; active billing account required)
Standard Tier (Websites & Apps) [GOLDEN PATH]"I want to host a website," "I'm running a small database," "I don't know, just give me a basic one."
e2-standard-2
(default baseline;
e2-medium
for light websites/apps, or
e2-standard-4
with 50 GB
pd-balanced
for higher concurrency)
30 GB Balanced Disk (
pd-balanced
)
Moderate (Pay-as-you-go; see Compute Engine pricing)
Powerhouse Tier (Heavy Processing)"I have heavy data pipelines," "I'm compiling large codebases," "I need maximum speed."3rd-gen General-purpose
c3-standard-4
or
n2-standard-4
(4th-gen
c4-standard-4
/
n4-standard-4
/ Arm
c4a-standard-4
; Compute-optimized
c2d-standard-4
/
h3-standard-88
)
100 GB
pd-ssd
(3rd-gen/
C2D
),
pd-balanced
or
hyperdisk-balanced
(
H3
), or
hyperdisk-balanced
(mandatory on 4th-gen
C4
/
N4
/
C4A
)
Premium (Pay-as-you-go)
Specialist Tier (AI, Graphics & Bare Metal)"I want to run an LLM," "I need a GPU workstation," "I need a bare metal
-metal
host."
g2-standard-4
(1 NVIDIA L4 GPU) or bare metal
c3-standard-192-metal
/
c4-standard-288-metal
100 GB
pd-balanced
(
G2
) or 200 GB
hyperdisk-balanced
(
-metal
/ 4th-gen
A4
)
High (Requires GPU or dedicated bare-metal CPU quota)
Rule: Default to the Standard Tier (
e2-standard-2
with a 30 GB
pd-balanced
boot disk) unless the user has specific requirements that other tiers or sizes satisfy. When a workload maps to a tier without an explicit vCPU/RAM count, always use the baseline machine type listed in the table (
e2-micro
or
e2-small
for Starter;
e2-standard-2
[or
e2-medium
/
e2-standard-4
when justified] for Standard;
c3-standard-4
or
n2-standard-4
for 3rd-gen Powerhouse,
c4-standard-4
/
n4-standard-4
for 4th-gen, or
c2d-standard-4
for Compute-optimized;
g2-standard-4
for L4 GPU) rather than upsizing to
-8
or
-16
.

如果用户表示“我想创建一台 VM”或不确定硬件规格,请使用此表推荐层级。应引导用户查看 Google Cloud pricing 和 Compute Engine pricing 以获取当前区域价格,而不要引用固定美元金额。
对话层级最适合……底层 Machine启动磁盘(默认)成本概况
Starter Tier(入门层级)(开发/测试与学习)“我只想随便体验一下”、“我在学习 Linux”、“我有一个很小的业余脚本。”
e2-micro
(符合 Free Tier 条件)或
e2-small
10 GB Standard Disk(
pd-standard
;Free Tier 最多涵盖 30 GB
pd-standard
)
极低(Google Cloud Free Tier 仅涵盖
us-west1
、
us-central1
或
us-east1
中每月一台非抢占式
e2-micro
实例
;
e2-small
或其他区域会立即按标准价格计费;仍需有效的 billing account)
Standard Tier(标准层级)(网站与应用) [GOLDEN PATH]“我想托管一个网站”、“我在运行一个小型数据库”、“我不确定,给我一个基础配置就行。”
e2-standard-2
(默认基线;轻量网站/应用使用
e2-medium
,更高并发可使用
e2-standard-4
和 50 GB
pd-balanced
)
30 GB Balanced Disk(
pd-balanced
)
中等(按用量计费;参见 Compute Engine pricing)
Powerhouse Tier(高性能层级)(繁重处理)“我有繁重的 data pipeline”、“我在编译大型 codebase”、“我需要最高速度。”第 3 代通用型
c3-standard-4
或
n2-standard-4
(第 4 代
c4-standard-4
/
n4-standard-4
、Arm
c4a-standard-4
;计算优化型
c2d-standard-4
/
h3-standard-88
)
100 GB
pd-ssd
(第 3 代/
C2D
)、
pd-balanced
或
hyperdisk-balanced
(
H3
),或
hyperdisk-balanced
(第 4 代
C4
/
N4
/
C4A
强制要求)
较高(按用量计费)
Specialist Tier(专业层级)(AI、图形与裸金属)“我想运行 LLM”、“我需要 GPU workstation”、“我需要一台裸金属
-metal
主机。”
g2-standard-4
(1 块 NVIDIA L4 GPU)或裸金属
c3-standard-192-metal
/
c4-standard-288-metal
100 GB
pd-balanced
(
G2
)或 200 GB
hyperdisk-balanced
(
-metal
/ 第 4 代
A4
)
高(需要 GPU 或专属裸金属 CPU 配额)
规则:默认使用 Standard Tier(
e2-standard-2
和 30 GB
pd-balanced
启动磁盘),除非用户有其他层级或规格可以满足的明确需求。当工作负载映射到某个层级但未明确指定 vCPU/RAM 数量时,始终使用表中列出的基线 machine type(Starter 使用
e2-micro
或
e2-small
;Standard 使用
e2-standard-2
,或有充分理由时使用
e2-medium
/
e2-standard-4
;第 3 代 Powerhouse 使用
c3-standard-4
或
n2-standard-4
,第 4 代使用
c4-standard-4
/
n4-standard-4
;计算优化型使用
c2d-standard-4
;L4 GPU 使用
g2-standard-4
),不要擅自升级到
-8
或
-16
。

Conversational Guidelines (How to Talk to Users)

对话指南(如何与用户沟通)

1. Early Fork: Establishing Execution Mode

1. 早期分支:确定执行模式

At the start of an interactive session, state whether execution is automated (provisioning after confirmation via
gcloud
/ Compute Engine MCP) or guided (outputting copy-pasteable
gcloud
commands or JSON payloads for Cloud Shell or terminal)—without running
gcloud config list
or shell commands while mandatory inputs are still missing
.
在交互式会话开始时,说明执行方式是自动化置备(经确认后通过
gcloud
/ Compute Engine MCP 执行),还是引导式执行(为 Cloud Shell 或终端输出可复制粘贴的
gcloud
命令或 JSON payload)。当必需输入仍缺失时,不要运行
gcloud config list
或 shell 命令
。

2. Handling Simple Requests (e.g., "Create a VM" or "Host a Small Website")

2. 处理简单请求(例如“创建 VM”或“托管一个小网站”)

Do not overwhelm beginners with block-storage IOPS or CPU architecture jargon, and do not run terminal commands before the user answers. Clarify execution mode, recommend the Standard Tier (Golden Path) baseline (
e2-standard-2
or
e2-medium
with a 30 GB
pd-balanced
boot disk
), and always ask for all four required inputs in your first response:
  1. Google Cloud Project ID
  2. VM Name (e.g.,
    my-first-web-server
    )
  3. Region or Zone (explaining that a location closer to users lowers network latency and makes pages load faster; suggest
    us-central1
    /
    us-central1-a
    if unsure)
  4. Public Internet vs. Private Networking (in plain language: "Does this VM need to be reachable from the public internet, or should we keep it private? Keeping it private is our default security best practice—even for websites, please confirm which you prefer.")
不要用块存储 IOPS 或 CPU 架构术语压倒初学者,并且在用户回答前不要运行终端命令。先澄清执行模式,推荐 Standard Tier(Golden Path)基线(
e2-standard-2
,或
e2-medium
搭配 30 GB
pd-balanced
启动磁盘
),并且
始终
在首次回复中询问全部四项必需输入:
  1. Google Cloud Project ID
  2. VM Name(例如
    my-first-web-server
    )
  3. Region 或 Zone(解释选择更靠近用户的区域可以降低网络延迟、加快页面加载;如果用户没有偏好,建议使用
    us-central1
    /
    us-central1-a
    )
  4. 公共互联网与私有网络(使用通俗语言:“这台 VM 是否需要从公共互联网访问,还是应保持私有?保持私有是默认的最佳安全实践——即使是网站也请确认您的选择。”)

3. Clear Cost, Quota & Resource Availability Guidance

3. 清晰说明成本、配额与资源可用性

  • Warn clearly before provisioning Powerhouse, GPU, or Bare Metal instances that specialized hardware and large
    pd-ssd
    / Hyperdisk volumes accumulate costs quickly (disks bill continuously while stopped) and require sufficient regional CPU/GPU quota.
  • If VM provisioning fails with
    ZONE_RESOURCE_POOL_EXHAUSTED
    (or
    ZONE_RESOURCE_POOL_EXHAUSTED_WITH_DETAILS
    ), explain that this is a physical zonal hardware supply shortage that a project quota increase will not fix. Consult Troubleshoot resource availability errors and guide the user to try another zone in the region (e.g.,
    us-central1-b
    or
    us-central1-c
    ), adjust machine series/size, or use Compute Engine reservations.

  • 在置备 Powerhouse、GPU 或 Bare Metal 实例前,明确警告:专用硬件和大型
    pd-ssd
    / Hyperdisk 卷会快速累积费用(磁盘在实例停止后仍持续计费),并且需要充足的区域 CPU/GPU 配额。
  • 如果 VM 置备因
    ZONE_RESOURCE_POOL_EXHAUSTED
    (或
    ZONE_RESOURCE_POOL_EXHAUSTED_WITH_DETAILS
    )失败,请说明这是特定 zone 的物理硬件供应不足,提高项目配额无法解决。查阅 排查资源可用性错误,并指导用户尝试该区域中的其他 zone(例如
    us-central1-b
    或
    us-central1-c
    )、调整 machine series/规格,或使用 Compute Engine reservations。

Best Practices & Hardening Rules

最佳实践与加固规则

Security & Networking

安全与网络

  1. Private-by-Default (
    --no-address
    )
    : Default to
    --no-address
    on custom or verified
    --subnet={subnet}
    subnets, using Cloud NAT for outbound egress and Identity-Aware Proxy (IAP) TCP forwarding (
    35.235.240.0/20
    , TCP
    22
    /
    3389
    ,
    roles/iap.tunnelResourceAccessor
    ; see Use IAP for TCP forwarding) for SSH/RDP.
  2. OS Login (
    --metadata=enable-oslogin=TRUE
    )
    : Enable OS Login so SSH access is tied to IAM roles rather than project-wide static SSH keys.
  3. Custom Service Accounts: Never use the default Compute Engine service account; attach
    {custom_service_account}
    with least-privilege IAM roles.
  4. Shielded VMs: Enable
    --shielded-secure-boot
    ,
    --shielded-vtpm
    , and
    --shielded-integrity-monitoring
    on all virtualized VMs (omit vTPM/integrity and set
    --no-shielded-secure-boot
    on standard x86
    -metal
    bare metal).
  1. 默认私有 (
    --no-address
    )
    :对于自定义或已验证的
    --subnet={subnet}
    subnet,默认使用
    --no-address
    ,通过 Cloud NAT 提供出站访问,并通过 Identity-Aware Proxy (IAP) TCP forwarding(
    35.235.240.0/20
    、TCP
    22
    /
    3389
    、
    roles/iap.tunnelResourceAccessor
    ;参见 使用 IAP 进行 TCP 转发)提供 SSH/RDP。
  2. OS Login (
    --metadata=enable-oslogin=TRUE
    )
    :启用 OS Login,使 SSH 访问由 IAM roles 控制,而不是依赖项目范围的静态 SSH keys。
  3. 自定义 Service Accounts:绝不使用默认的 Compute Engine service account;应附加具有最小权限 IAM roles 的
    {custom_service_account}
    。
  4. Shielded VMs:在所有虚拟化 VM 上启用
    --shielded-secure-boot
    、
    --shielded-vtpm
    和
    --shielded-integrity-monitoring
    ;在标准 x86
    -metal
    裸金属实例上省略 vTPM/完整性 flags,并设置
    --no-shielded-secure-boot
    。

Cost Optimization & Reliability

成本优化与可靠性

  1. Right-Sizing & Free Tier Accuracy: Use
    e2-micro
    (
    us-west1
    ,
    us-central1
    , or
    us-east1
    only, 1 non-preemptible instance/month, up to 30 GB
    pd-standard
    , with an active billing account still required on the Google Cloud project; see Google Cloud Free Tier) for Free Tier eligibility, or
    e2-medium
    for light dev/test workloads.
  2. Spot VMs: Offer Spot VMs (
    --provisioning-model=SPOT
    ,
    --instance-termination-action=DELETE
    [or
    STOP
    ],
    --maintenance-policy=TERMINATE
    ,
    --no-restart-on-failure
    ; see Create and use Spot VMs) for stateless, fault-tolerant batch workloads to achieve significant discounts compared to standard instances (see Compute Engine pricing).
  3. Storage & Host Maintenance: Default 3rd-gen/E2 boot disks to
    pd-balanced
    (
    hyperdisk-balanced
    on 4th-gen and
    -metal
    ), and set
    --maintenance-policy=MIGRATE
    on standard virtualized VMs (
    TERMINATE
    on Spot, GPU, and
    -metal
    instances; see Handle GPU host maintenance events).

  1. 合理规格与准确的 Free Tier:需要符合 Free Tier 条件时,使用
    e2-micro
    (仅限
    us-west1
    、
    us-central1
    或
    us-east1
    ,每月一台非抢占式实例,最多 30 GB
    pd-standard
    ,Google Cloud 项目仍需关联有效 billing account;参见 Google Cloud Free Tier);轻量开发/测试工作负载可使用
    e2-medium
    。
  2. Spot VMs:对于无状态、容错型批处理工作负载,可提供 Spot VMs(
    --provisioning-model=SPOT
    、
    --instance-termination-action=DELETE
    [或
    STOP
    ]、
    --maintenance-policy=TERMINATE
    、
    --no-restart-on-failure
    ;参见 创建和使用 Spot VMs),以显著低于标准实例的价格运行(参见 Compute Engine pricing)。
  3. 存储与宿主机维护:第 3 代/E2 启动磁盘默认使用
    pd-balanced
    (第 4 代和
    -metal
    使用
    hyperdisk-balanced
    ),并在标准虚拟化 VM 上设置
    --maintenance-policy=MIGRATE
    (Spot、GPU 和
    -metal
    实例使用
    TERMINATE
    ;参见 处理 GPU 宿主机维护事件)。

Technical Reference Templates

技术参考模板

Every row below summarizes the complete
gcloud compute instances create
flags (with
{vm_name}
,
--project={project_id}
, and
--zone={zone}
) and 8-field Compute Engine MCP
create_instance
schema for the five standard VM templates. Consult Technical Reference Templates when full multi-line examples or additional template context are needed, and always read Usage Attribution before executing any live
gcloud
, REST API, or MCP command:
TemplateComplete
gcloud compute instances create {vm_name} --project={project_id} --zone={zone}
Flags
MCP
create_instance
Routing & Schema
Required Warnings
1. Golden Path General Purpose (Production)
--machine-type=e2-standard-2 --network-tier=PREMIUM --subnet={subnet} --no-address --maintenance-policy=MIGRATE --metadata=enable-oslogin=TRUE --service-account={custom_service_account} --scopes=https://www.googleapis.com/auth/cloud-platform --create-disk=auto-delete=yes,boot=yes,device-name={vm_name},image=projects/debian-cloud/global/images/family/debian-12,mode=rw,size=30,type=projects/{project_id}/zones/{zone}/diskTypes/pd-balanced --shielded-secure-boot --shielded-vtpm --shielded-integrity-monitoring --reservation-affinity=any
7-field JSON (
project
,
zone
,
name
,
"machineType": "e2-standard-2"
,
"imageProject": "debian-cloud"
,
"imageFamily": "debian-12"
,
"maintenancePolicy": "MIGRATE"
) is for default-VPC prototyping only; route hardened (
--no-address
, custom subnet/SA) deploys to
gcloud
.
Recommend Cloud NAT for egress and IAP TCP forwarding (
35.235.240.0/20
,
roles/iap.tunnelResourceAccessor
) for SSH/RDP; never use the default Compute Engine service account; omit
--quiet
.
2. Developer Dev/Test VM (Cost-Optimized Spot)
--machine-type=e2-medium --subnet={subnet} --no-address --metadata=enable-oslogin=TRUE --service-account={custom_service_account} --scopes=https://www.googleapis.com/auth/cloud-platform --provisioning-model=SPOT --instance-termination-action=DELETE --maintenance-policy=TERMINATE --no-restart-on-failure --create-disk=auto-delete=yes,boot=yes,device-name={vm_name},image=projects/debian-cloud/global/images/family/debian-12,mode=rw,size=20,type=projects/{project_id}/zones/{zone}/diskTypes/pd-standard --shielded-secure-boot --shielded-vtpm --shielded-integrity-monitoring
CLI/REST only—Compute Engine MCP
create_instance
does not support Spot scheduling (
--provisioning-model=SPOT
,
--instance-termination-action
),
--no-address
, or custom subnets/service accounts.
Warn that Spot VMs can be preempted at any time (for stateless workloads only); use
DELETE
or
STOP
(never
TERMINATE
) on
--instance-termination-action
; include teardown command without
--quiet
.
3. High-Performance General Purpose & Compute-Heavy3rd-gen (
c3-standard-4
/
n2-standard-4
)
:
--machine-type=c3-standard-4 --subnet={subnet} --no-address --metadata=enable-oslogin=TRUE --service-account={custom_service_account} --scopes=https://www.googleapis.com/auth/cloud-platform --create-disk=auto-delete=yes,boot=yes,device-name={vm_name},image=projects/debian-cloud/global/images/family/debian-12,mode=rw,size=100,type=projects/{project_id}/zones/{zone}/diskTypes/pd-ssd --maintenance-policy=MIGRATE --shielded-secure-boot --shielded-vtpm --shielded-integrity-monitoring
(for 4th-gen
c4-standard-4
/
n4-standard-4
, replace
--subnet
/
--no-address
with
--network-interface=subnet={subnet},no-address,nic-type=GVNIC
, use
debian-13
, and use
hyperdisk-balanced
)
Default-VPC 3rd-gen prototyping only (
"machineType": "c3-standard-4"
); route custom-disk, 4th-gen Hyperdisk, and private-subnet deploys to
gcloud
.
Warn about continuous
pd-ssd
/Hyperdisk storage billing, 4th-gen Hyperdisk requirement (
pd-*
rejected on
C4
/
N4
/
C4A
), and accurate Day-0 mutability (disk shrink/type change uses snapshot +
detach-disk
/
attach-disk --boot
swap; stopped VMs rename via
gcloud compute instances set-name
and update subnet via
network-interfaces update
; VM recreation required for zone, CPU arch, or Encrypted-Memory VM).
4. GPU Workstation (ML Inference)
--machine-type=g2-standard-4 --accelerator=type=nvidia-l4,count=1 --subnet={subnet} --no-address --metadata=enable-oslogin=TRUE --service-account={custom_service_account} --scopes=https://www.googleapis.com/auth/cloud-platform --maintenance-policy=TERMINATE --create-disk=auto-delete=yes,boot=yes,device-name={vm_name},image=projects/deeplearning-platform-release/global/images/family/common-cu129-ubuntu-2404-nvidia-580,mode=rw,size=100,type=projects/{project_id}/zones/{zone}/diskTypes/pd-balanced --shielded-secure-boot --shielded-vtpm --shielded-integrity-monitoring
8-field JSON (
"project": "{project_id}"
,
"zone": "{zone}"
,
"name": "{vm_name}"
,
"machineType": "g2-standard-4"
,
"imageProject": "deeplearning-platform-release"
,
"imageFamily": "common-cu129-ubuntu-2404-nvidia-580"
,
"guestAccelerators": [{"acceleratorType": "nvidia-l4", "acceleratorCount": 1}]
,
"maintenancePolicy": "TERMINATE"
) is for default-VPC prototyping only; route hardened deploys to
gcloud
.
Warn about high GPU hourly costs, required regional GPU quota verification, and that GPU VMs do not support live migration (
--maintenance-policy=TERMINATE
is mandatory; never set
MIGRATE
).
5. Bare Metal Instance (
-metal
)
--machine-type=c3-standard-192-metal --network-interface=subnet={subnet},no-address,nic-type=IDPF --maintenance-policy=TERMINATE --metadata=enable-oslogin=TRUE --service-account={custom_service_account} --scopes=https://www.googleapis.com/auth/cloud-platform --create-disk=auto-delete=yes,boot=yes,device-name={vm_name},image=projects/debian-cloud/global/images/family/debian-13,mode=rw,size=200,type=projects/{project_id}/zones/{zone}/diskTypes/hyperdisk-balanced --no-shielded-secure-boot
(never combine
--network-interface
with top-level
--subnet
or
--no-address
; omit
--shielded-vtpm
)
CLI/REST only—unsupported by Compute Engine MCP
create_instance
.
Warn about dedicated whole-host costs/quota, mandatory
hyperdisk-balanced
(
pd-*
and Windows unsupported), mandatory
debian-13
(
debian-12
unsupported on
C3-metal
,
C4-metal
, and
X4
), mandatory
nic-type=IDPF
(
GVNIC
/
VIRTIO_NET
unsupported), and no live migration.

下表每一行都汇总了五种标准 VM 模板对应的完整
gcloud compute instances create
flags(包含
{vm_name}
、
--project={project_id}
和
--zone={zone}
)以及 8-field Compute Engine MCP
create_instance
schema。需要完整的多行示例或更多模板上下文时,请查阅 Technical Reference Templates;执行任何实时
gcloud
、REST API 或 MCP 命令前,始终阅读 Usage Attribution:
模板完整的
gcloud compute instances create {vm_name} --project={project_id} --zone={zone}
Flags
MCP
create_instance
路由与 Schema
必需警告
1. Golden Path 通用型(生产环境)
--machine-type=e2-standard-2 --network-tier=PREMIUM --subnet={subnet} --no-address --maintenance-policy=MIGRATE --metadata=enable-oslogin=TRUE --service-account={custom_service_account} --scopes=https://www.googleapis.com/auth/cloud-platform --create-disk=auto-delete=yes,boot=yes,device-name={vm_name},image=projects/debian-cloud/global/images/family/debian-12,mode=rw,size=30,type=projects/{project_id}/zones/{zone}/diskTypes/pd-balanced --shielded-secure-boot --shielded-vtpm --shielded-integrity-monitoring --reservation-affinity=any
7-field JSON(
project
、
zone
、
name
、
"machineType": "e2-standard-2"
、
"imageProject": "debian-cloud"
、
"imageFamily": "debian-12"
、
"maintenancePolicy": "MIGRATE"
)仅用于 default-VPC 原型开发;安全加固部署(
--no-address
、自定义 subnet/SA)必须路由至
gcloud
。
推荐使用 Cloud NAT 提供出站访问,并使用 IAP TCP forwarding(
35.235.240.0/20
、
roles/iap.tunnelResourceAccessor
)提供 SSH/RDP;绝不使用默认的 Compute Engine service account;省略
--quiet
。
2. 开发者 Dev/Test VM(成本优化 Spot)
--machine-type=e2-medium --subnet={subnet} --no-address --metadata=enable-oslogin=TRUE --service-account={custom_service_account} --scopes=https://www.googleapis.com/auth/cloud-platform --provisioning-model=SPOT --instance-termination-action=DELETE --maintenance-policy=TERMINATE --no-restart-on-failure --create-disk=auto-delete=yes,boot=yes,device-name={vm_name},image=projects/debian-cloud/global/images/family/debian-12,mode=rw,size=20,type=projects/{project_id}/zones/{zone}/diskTypes/pd-standard --shielded-secure-boot --shielded-vtpm --shielded-integrity-monitoring
仅限 CLI/REST——Compute Engine MCP
create_instance
不支持 Spot scheduling(
--provisioning-model=SPOT
、
--instance-termination-action
)、
--no-address
或自定义 subnet/service account。
警告 Spot VM 可能随时被抢占(仅适用于无状态工作负载);在
--instance-termination-action
上使用
DELETE
或
STOP
(绝不要使用
TERMINATE
);拆除命令中省略
--quiet
。
3. 高性能通用型与计算密集型第 3 代 (
c3-standard-4
/
n2-standard-4
)
:
--machine-type=c3-standard-4 --subnet={subnet} --no-address --metadata=enable-oslogin=TRUE --service-account={custom_service_account} --scopes=https://www.googleapis.com/auth/cloud-platform --create-disk=auto-delete=yes,boot=yes,device-name={vm_name},image=projects/debian-cloud/global/images/family/debian-12,mode=rw,size=100,type=projects/{project_id}/zones/{zone}/diskTypes/pd-ssd --maintenance-policy=MIGRATE --shielded-secure-boot --shielded-vtpm --shielded-integrity-monitoring
(对于第 4 代
c4-standard-4
/
n4-standard-4
,将
--subnet
/
--no-address
替换为
--network-interface=subnet={subnet},no-address,nic-type=GVNIC
,使用
debian-13
和
hyperdisk-balanced
)
仅支持 default-VPC 的第 3 代原型开发(
"machineType": "c3-standard-4"
);自定义磁盘、第 4 代 Hyperdisk 和私有 subnet 部署必须路由至
gcloud
。
警告
pd-ssd
/Hyperdisk 存储会持续计费、第 4 代必须使用 Hyperdisk(
C4
/
N4
/
C4A
会拒绝
pd-*
),并准确说明 Day-0 可变性:修改磁盘大小/类型时,使用 snapshot 加上
detach-disk
/
attach-disk --boot
交换;已停止的 VM 可通过
gcloud compute instances set-name
重命名,并通过
gcloud compute instances network-interfaces update
更新 subnet;更改 zone、CPU 架构或 Encrypted-Memory VM 则需要重建 VM。
4. GPU Workstation(ML Inference)
--machine-type=g2-standard-4 --accelerator=type=nvidia-l4,count=1 --subnet={subnet} --no-address --metadata=enable-oslogin=TRUE --service-account={custom_service_account} --scopes=https://www.googleapis.com/auth/cloud-platform --maintenance-policy=TERMINATE --create-disk=auto-delete=yes,boot=yes,device-name={vm_name},image=projects/deeplearning-platform-release/global/images/family/common-cu129-ubuntu-2404-nvidia-580,mode=rw,size=100,type=projects/{project_id}/zones/{zone}/diskTypes/pd-balanced --shielded-secure-boot --shielded-vtpm --shielded-integrity-monitoring
8-field JSON(
"project": "{project_id}"
、
"zone": "{zone}"
、
"name": "{vm_name}"
、
"machineType": "g2-standard-4"
、
"imageProject": "deeplearning-platform-release"
、
"imageFamily": "common-cu129-ubuntu-2404-nvidia-580"
、
"guestAccelerators": [{"acceleratorType": "nvidia-l4", "acceleratorCount": 1}]
、
"maintenancePolicy": "TERMINATE"
)仅用于 default-VPC 原型开发;安全加固部署必须路由至
gcloud
。
警告 GPU 每小时成本较高、需要验证区域 GPU 配额,并且 GPU VM 不支持 live migration(必须使用
--maintenance-policy=TERMINATE
;绝不要设置为
MIGRATE
)。
5. 裸金属实例 (
-metal
)
--machine-type=c3-standard-192-metal --network-interface=subnet={subnet},no-address,nic-type=IDPF --maintenance-policy=TERMINATE --metadata=enable-oslogin=TRUE --service-account={custom_service_account} --scopes=https://www.googleapis.com/auth/cloud-platform --create-disk=auto-delete=yes,boot=yes,device-name={vm_name},image=projects/debian-cloud/global/images/family/debian-13,mode=rw,size=200,type=projects/{project_id}/zones/{zone}/diskTypes/hyperdisk-balanced --no-shielded-secure-boot
(绝不能同时使用
--network-interface
和顶层
--subnet
或
--no-address
;省略
--shielded-vtpm
)
仅限 CLI/REST——Compute Engine MCP
create_instance
不支持裸金属实例。
警告独占整主机的成本/配额、强制使用
hyperdisk-balanced
(不支持
pd-*
和 Windows)、强制使用
debian-13
(
C3-metal
、
C4-metal
和
X4
不支持
debian-12
)、强制使用
nic-type=IDPF
(
-metal
不支持
GVNIC
/
VIRTIO_NET
),并且不支持 live migration。

Instructions & Guardrails

说明与护栏

  • EARLY EXECUTION FORK & MCP BOUNDARY: Never pass unsupported REST fields (
    instance
    ,
    disks
    ,
    networkInterfaces
    ,
    serviceAccounts
    ,
    shieldedInstanceConfig
    ,
    scheduling
    ) or prefixed machine URIs (
    zones/{zone}/machineTypes/...
    ) to MCP
    create_instance
    , and always route hardened (
    --no-address
    , custom subnet, custom SA, Shielded VM, OS Login), Spot, custom-disk, 4th-gen, and
    -metal
    creations to
    gcloud compute instances create
    .
  • FAST CONVERSATIONAL INTAKE (NO SHELL COMMANDS ON MISSING INPUTS): When any mandatory input (Project ID, VM name, region/zone, or public vs. private networking) is missing from the user's prompt, ask for all missing inputs directly in your first reply (explaining regional latency benefits and recommending private networking) without running
    gcloud config list
    ,
    gcloud --version
    , or any shell discovery commands first
    .
  • PUBLIC IP REMEDIATION CHECKLIST: Whenever a user requests a public IP or direct internet SSH exposure:
    1. Warn clearly about public internet scanners and SSH/RDP brute-force risks.
    2. Recommend both Identity-Aware Proxy (IAP) TCP forwarding (
      35.235.240.0/20
      ,
      roles/iap.tunnelResourceAccessor
      ) for SSH/RDP and Cloud NAT for outbound internet access with
      --no-address
      .
    3. Include
      --metadata=enable-oslogin=TRUE
      and all three Shielded VM flags (
      --shielded-secure-boot
      ,
      --shielded-vtpm
      ,
      --shielded-integrity-monitoring
      ) on virtualized VMs.
    4. Recommend a custom, least-privilege service account instead of the default Compute Engine service account.
  • ACCURATE DAY-0 MUTABILITY WARNINGS: Explain accurately that:
    • Disks: Persistent Disks and Hyperdisks cannot shrink in-place, and changing disk type requires creating a new disk from a snapshot and swapping it on a stopped VM (
      detach-disk
      /
      attach-disk --boot
      ) without recreating the VM instance.
    • Networking & Renaming: Stopped (
      TERMINATED
      ) standalone IPv4 VMs can migrate VPC/subnet in-place (
      gcloud compute instances network-interfaces update
      ; only NIC count
      nic1+
      is fixed at creation) and can be renamed in-place via
      gcloud compute instances set-name
      with
      --new-name
      and
      --zone
      (see Rename a VM and Update instance properties).
    • True VM Recreation: Properties requiring full VM recreation are zone, CPU architecture (
      x86_64
      vs.
      ARM64
      ), and Encrypted-Memory VM (AMD SEV-SNP or Intel TDX) enablement.
  • 4TH-GEN & BARE METAL HARDWARE CONSTRAINTS: Never pair
    pd-*
    disks with 4th-generation (
    C4
    ,
    N4
    ,
    C4A
    ,
    C4D
    ,
    M4
    ,
    X4
    ,
    A4
    , which require
    hyperdisk-balanced
    and
    nic-type=GVNIC
    ;
    N4
    supports
    hyperdisk-balanced
    and
    hyperdisk-throughput
    , not
    hyperdisk-extreme
    ) or bare metal (
    -metal
    ) instances. Whenever recommending or generating a bare metal (
    -metal
    ) configuration (
    C3-metal
    ,
    C4-metal
    ), always explicitly state in your reply that: (1)
    pd-*
    disks are unsupported (
    hyperdisk-balanced
    is mandatory), (2)
    debian-13
    is required because
    debian-12
    is unsupported on
    C3-metal
    ,
    C4-metal
    , and
    X4
    , (3)
    --network-interface=subnet={subnet},no-address,nic-type=IDPF
    is required without conflicting top-level
    --subnet
    or
    --no-address
    flags (because
    GVNIC
    and
    VIRTIO_NET
    are unsupported on
    -metal
    ), and (4)
    --maintenance-policy=TERMINATE
    ,
    --metadata=enable-oslogin=TRUE
    , and
    --no-shielded-secure-boot
    (omitting
    --shielded-vtpm
    ) are required.
  • MANDATORY GPU & SPECIALIZED HARDWARE WARNINGS: Whenever recommending or generating a GPU (
    G2
    ,
    A3
    ,
    A4
    ), bare metal (
    -metal
    ), or high-performance VM configuration (including in
    "Do not execute"
    or MCP JSON comparisons), always explicitly include in your reply: (1) a warning about high GPU or dedicated-host hourly compute costs, (2) a reminder to verify regional GPU/CPU quota in the target project, and (3) that GPU and bare metal instances do not support live migration (
    --maintenance-policy=TERMINATE
    is mandatory).
  • HANDLE
    ZONE_RESOURCE_POOL_EXHAUSTED
    : Explain that zonal capacity errors are physical hardware shortages (not fixable via quota increases) and guide users to alternate zones, alternate machine series, or reservations per Troubleshoot resource availability errors.
  • FREE TIER ELIGIBILITY & BILLING ACCOUNT REQUIREMENT: Whenever a user asks about Google Cloud Free Tier eligibility for Compute Engine, always explicitly state all four requirements in your reply: (1) only one non-preemptible
    e2-micro
    instance per month is covered (
    e2-small
    and larger are billed), (2) only in
    us-west1
    ,
    us-central1
    , or
    us-east1
    , (3) up to 30 GB of
    pd-standard
    Standard Persistent Disk (
    pd-balanced
    and
    pd-ssd
    are billed), and (4) an active billing account is still required on the Google Cloud project even for Free Tier usage.
  • ALWAYS INCLUDE SAFE TEARDOWN COMMANDS: Always provide
    gcloud compute instances delete {vm_name} --zone={zone} --delete-disks=all
    (omitting
    --quiet
    on all copy-pasteable manual
    create
    and
    delete
    commands) so users can prevent orphaned compute and disk charges safely.
  • MODE-AWARE CONFIRMATION: Require explicit user confirmation before executing provisioning in Automated Execution mode; in Manual /
    "Do not execute"
    mode, prompt the user to review
    {snake_case}
    placeholders and flags before running the command themselves rather than offering to execute it.
  • 早期执行分支与 MCP 边界:绝不能向 MCP
    create_instance
    传递不支持的 REST fields(
    instance
    、
    disks
    、
    networkInterfaces
    、
    serviceAccounts
    、
    shieldedInstanceConfig
    、
    scheduling
    )或带前缀的 machine URIs(
    zones/{zone}/machineTypes/...
    );所有安全加固型(
    --no-address
    、自定义 subnet、自定义 SA、Shielded VM、OS Login)、Spot、自定义磁盘、第 4 代和
    -metal
    创建请求都必须路由至
    gcloud compute instances create
    。
  • 快速对话收集(输入缺失时不运行 Shell 命令):当用户提示中缺少任何必需输入(Project ID、VM name、region/zone、公网或私网网络)时,首次回复中直接询问所有缺失输入(解释区域延迟优势并推荐私有网络),不要先运行
    gcloud config list
    、
    gcloud --version
    或任何 shell discovery 命令。
  • 公网 IP 修复检查清单:当用户请求公网 IP 或直接暴露互联网 SSH 时:
    1. 明确警告公共互联网扫描器以及 SSH/RDP brute-force 风险。
    2. 同时推荐 Identity-Aware Proxy (IAP) TCP forwarding(
      35.235.240.0/20
      、
      roles/iap.tunnelResourceAccessor
      )用于 SSH/RDP,以及 Cloud NAT 结合
      --no-address
      提供互联网出站访问。
    3. 在虚拟化 VM 上包含
      --metadata=enable-oslogin=TRUE
      和全部三个 Shielded VM flags(
      --shielded-secure-boot
      、
      --shielded-vtpm
      、
      --shielded-integrity-monitoring
      )。
    4. 推荐使用自定义的最小权限 service account,而不是默认的 Compute Engine service account。
  • 准确的 Day-0 可变性警告:准确说明:
    • 磁盘:Persistent Disks 和 Hyperdisks 无法原地缩小;更改磁盘类型时,需要通过 snapshot 创建新磁盘,然后在已停止的 VM 上交换磁盘(
      detach-disk
      /
      attach-disk --boot
      ),无需重建 VM 实例。
    • 网络与重命名:已停止(
      TERMINATED
      )的独立 IPv4 VM 可以原地迁移 VPC/subnet(
      gcloud compute instances network-interfaces update
      ;仅 NIC 数量
      nic1+
      在创建时固定),也可以通过
      gcloud compute instances set-name
      配合
      --new-name
      和
      --zone
      原地重命名(参见 Rename a VM 和 Update instance properties)。
    • 真正需要重建 VM 的情况:需要完整重建 VM 的属性包括
      zone
      、CPU 架构(
      x86_64
      与
      ARM64
      )以及 Encrypted-Memory VM(AMD SEV-SNP 或 Intel TDX)启用状态。
  • 第 4 代与裸金属硬件约束:绝不能将
    pd-*
    磁盘与第 4 代(
    C4
    、
    N4
    、
    C4A
    、
    C4D
    、
    M4
    、
    X4
    、
    A4
    ,这些系列要求使用
    hyperdisk-balanced
    和
    nic-type=GVNIC
    ;
    N4
    支持
    hyperdisk-balanced
    和
    hyperdisk-throughput
    ,但不支持
    hyperdisk-extreme
    )或裸金属 (
    -metal
    ) 实例搭配。每次推荐或生成裸金属 (
    -metal
    ) 配置(
    C3-metal
    、
    C4-metal
    )时,始终必须在回复中明确说明:(1) 不支持
    pd-*
    磁盘(强制使用
    hyperdisk-balanced
    );(2) 必须使用
    debian-13
    ,因为
    C3-metal
    、
    C4-metal
    和
    X4
    不支持
    debian-12
    ;(3) 必须使用
    --network-interface=subnet={subnet},no-address,nic-type=IDPF
    ,且不得与冲突的顶层
    --subnet
    或
    --no-address
    flags 同时使用(因为
    -metal
    不支持
    GVNIC
    和
    VIRTIO_NET
    );(4) 必须使用
    --maintenance-policy=TERMINATE
    、
    --metadata=enable-oslogin=TRUE
    和
    --no-shielded-secure-boot
    ,并省略
    --shielded-vtpm
    。
  • GPU 与专用硬件强制警告:每次推荐或生成 GPU (
    G2
    、
    A3
    、
    A4
    )、裸金属 (
    -metal
    ) 或高性能 VM 配置(包括在
    "Do not execute"
    模式或 MCP JSON 对比中)时,始终必须在回复中明确包含:(1) 关于 GPU 或专属宿主机每小时计算成本较高的警告;(2) 提醒用户验证目标项目中的区域 GPU/CPU 配额;(3) GPU 和裸金属实例不支持 live migration(必须使用
    --maintenance-policy=TERMINATE
    )。
  • 处理
    ZONE_RESOURCE_POOL_EXHAUSTED
    :说明 zone 容量错误是物理硬件供应不足,无法通过提高配额解决;根据 排查资源可用性错误,指导用户改用其他 zone、其他 machine series 或 reservations。
  • Free Tier 资格与 Billing Account 要求:每当用户询问 Compute Engine 的 Google Cloud Free Tier 资格时,始终明确说明全部四项要求:(1) 每月仅涵盖一台非抢占式
    e2-micro
    实例(
    e2-small
    及更大规格会计费);(2) 仅限
    us-west1
    、
    us-central1
    或
    us-east1
    ;(3) 最多 30 GB
    pd-standard
    Standard Persistent Disk(
    pd-balanced
    和
    pd-ssd
    会计费);(4) 即使使用 Free Tier,Google Cloud 项目仍必须关联有效 billing account。
  • 始终包含安全的拆除命令:始终提供
    gcloud compute instances delete {vm_name} --zone={zone} --delete-disks=all
    ,并在所有可复制粘贴的手动
    create
    和
    delete
    命令中省略
    --quiet
    ,帮助用户避免产生孤立的计算和磁盘费用。
  • 区分模式的确认机制:在 Automated Execution 模式中执行置备前必须获得用户明确确认;在 Manual /
    "Do not execute"
    模式中,应提示用户检查
    {snake_case}
    占位符和 flags,然后自行运行命令,而不是主动提出代为执行。