本文档介绍了如何删除预留。如需了解如何删除未来预留请求,请改为参阅取消或删除未来预留请求。
删除预留以免您不再需要的预留资源继续产生费用。
限制
在删除预订之前,请考虑以下事项:
您只能在创建共享预留的项目中删除该预留。
只有当没有 Compute Engine 实例使用特定目标预留时,您才能将其删除。如果有任何实例使用了预配,请在删除预配之前执行以下操作之一:
您只能在未来预留的预留期结束后删除为未来预留自动创建的预留。
只有先通过替换预留将其与承诺解除关联,您才能删除附加到承诺的预留。
准备工作
-
如果您尚未设置身份验证,请进行设置。身份验证是通过其进行身份验证以访问 Google Cloud 服务和 API 的过程。如需从本地开发环境运行代码或示例,您可以通过选择以下选项之一向 Compute Engine 进行身份验证:
Select the tab for how you plan to use the samples on this page:
Console
When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.
gcloud
-
Install the Google Cloud CLI, then initialize it by running the following command:
gcloud init
- Set a default region and zone.
- Install the Google Cloud CLI.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
- Install the Google Cloud CLI.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
- Install the Google Cloud CLI.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
- Install the Google Cloud CLI.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
在 Google Cloud 控制台中,转到预留页面。
在按需预订标签页(默认)上,选择您要删除的预订。
点击
删除。请点击删除来确认操作。
RESERVATION_NAME
:预留的名称。ZONE
:预留所在的可用区。PROJECT_ID
:您在其中创建了预留的项目的 ID。ZONE
:预留所在的可用区。RESERVATION_NAME
:预留的名称。- 了解如何查看预留。
Go
如需在本地开发环境中使用本页面上的 Go 示例,请安装并初始化 gcloud CLI,然后使用您的用户凭据设置应用默认凭据。
如需了解详情,请参阅 Set up authentication for a local development environment。 如需了解详情,请参阅身份验证文档中的为本地开发环境设置 ADC。
Java
如需在本地开发环境中使用本页面上的 Java 示例,请安装并初始化 gcloud CLI,然后使用您的用户凭据设置应用默认凭据。
如需了解详情,请参阅 Set up authentication for a local development environment。 如需了解详情,请参阅身份验证文档中的为本地开发环境设置 ADC。
Node.js
如需在本地开发环境中使用本页面上的 Node.js 示例,请安装并初始化 gcloud CLI,然后使用您的用户凭据设置应用默认凭据。
如需了解详情,请参阅 Set up authentication for a local development environment。 如需了解详情,请参阅身份验证文档中的为本地开发环境设置 ADC。
Python
如需在本地开发环境中使用本页面上的 Python 示例,请安装并初始化 gcloud CLI,然后使用您的用户凭据设置应用默认凭据。
如需了解详情,请参阅 Set up authentication for a local development environment。 如需了解详情,请参阅身份验证文档中的为本地开发环境设置 ADC。
REST
如需在本地开发环境中使用本页面上的 REST API 示例,请使用您提供给 gcloud CLI 的凭据。
Install the Google Cloud CLI, then initialize it by running the following command:
gcloud init
如需了解详情,请参阅 Google Cloud 身份验证文档中的使用 REST 时进行身份验证。
所需的角色
如需获得删除预留所需的权限,请让您的管理员向您授予项目的 Compute Admin (
roles/compute.admin
) IAM 角色。 如需详细了解如何授予角色,请参阅管理对项目、文件夹和组织的访问权限。此预定义角色包含删除预订所需的
compute.reservations.delete
权限。删除预留
如果您删除了可供任何匹配计算实例自动使用的预留,则使用已删除预留的所有实例都将继续运行。您需要继续为这些实例付费。
您可以一次删除单个预订或多个预订。对于多个预订,请使用 Google Cloud 控制台。对于单个预订,请选择以下任一选项:
控制台
gcloud
如需删除预留,请使用
gcloud compute reservations delete
命令:gcloud compute reservations delete RESERVATION_NAME \ --zone=ZONE
替换以下内容:
Go
Java
Node.js
Python
REST
如需删除预留,请向
reservation.delete
方法发出DELETE
请求:DELETE https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/reservations/RESERVATION_NAME
替换以下内容:
后续步骤
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-03-27。
-