本文件說明如何查看預訂或未來預訂要求。如要進一步瞭解不同類型的預留,請參閱「佈建類型」。
查看預訂或未來預訂要求時,您可以執行下列操作:
查看預訂設定。這項審查可協助您驗證預訂的詳細資料,確保預訂項目符合您的需求,並規劃容量。
決定可消耗的例項數量。這項檢查可協助您判斷有多少個 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
-
After installing the Google Cloud CLI, initialize it by running the following command:
gcloud init
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
- Set a default region and zone.
Go
To use the Go samples on this page in a local development environment, install and initialize the gcloud CLI, and then set up Application Default Credentials with your user credentials.
- Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
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.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
For more information, see Set up authentication for a local development environment.
Java
To use the Java samples on this page in a local development environment, install and initialize the gcloud CLI, and then set up Application Default Credentials with your user credentials.
- Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
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.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
For more information, see Set up authentication for a local development environment.
Node.js
To use the Node.js samples on this page in a local development environment, install and initialize the gcloud CLI, and then set up Application Default Credentials with your user credentials.
- Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
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.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
For more information, see Set up authentication for a local development environment.
Python
To use the Python samples on this page in a local development environment, install and initialize the gcloud CLI, and then set up Application Default Credentials with your user credentials.
- Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
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.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
For more information, see Set up authentication for a local development environment.
REST
To use the REST API samples on this page in a local development environment, you use the credentials you provide to the gcloud CLI.
After installing the Google Cloud CLI, initialize it by running the following command:
gcloud init
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
For more information, see Authenticate for using REST in the Google Cloud authentication documentation.
-
必要的角色
如要取得查看預留項目或未來預留項目要求所需的權限,請要求管理員為您授予專案的 Compute Admin (roles/compute.admin
) IAM 角色。如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和機構的存取權」。
這個預先定義的角色包含查看預訂或未來預訂要求所需的權限。如要查看確切的必要權限,請展開「必要權限」部分:
所需權限
如要查看預留項目或未來預留項目要求,您必須具備下列權限:
-
如要查看保留項目清單:
compute.reservations.list
專案 -
如要查看未來預留項目要求清單,請在專案中執行
compute.futureReservations.list
。 -
如要查看保留項目的詳細資料:
compute.reservations.get
專案上的 -
如要查看未來預留項目要求的詳細資料,請按照下列步驟操作:
compute.futureReservations.get
在專案中
查看預訂設定
下列各節將說明如何查看預訂或未來預訂要求的設定。
查看預留項目
如要查看一或多個預訂的設定,請使用本節所述的下列其中一種方法:
如要查看專案中所有保留項目的總覽,請查看保留項目清單。
如要查看單一預訂的完整詳細資料,請查看預訂詳細資料。
如要查看預留記錄中的 deleteAtTime
和 reservationSharingPolicy
欄位 (預覽),請使用 Google Cloud CLI 查看預留記錄的詳細資料,或使用 REST API 查看預留記錄。如果您不需要這些欄位,請選取下列任一選項來查看預訂:
主控台
在 Google Cloud 控制台,前往「Reservations」(預留項目) 頁面。
在「On-demand reservations」分頁 (預設) 中,表格會列出每個預留項目,每個表格欄會說明一項資源。
選用:在「On-demand reservations」表格中,執行下列任一操作或同時完成兩者:
如要顯示預訂的保證數量,請按一下 「資料欄顯示選項...」,選取「保證數量」核取方塊,然後按一下「確定」。
如要縮小保留訂單清單範圍,請在
「Filter」(篩選器) 欄位中,選取要用來篩選保留訂單的屬性。
如要查看預訂詳細資料,請在「名稱」欄中按一下預訂名稱。系統會開啟提供預訂詳細資料的頁面。
gcloud
如要查看保留項目清單,請使用
gcloud compute reservations list
指令:gcloud compute reservations list
輸出結果會與下列範例相似:
NAME: r-01 IN_USE_COUNT: 0 COUNT: 5 ZONE: us-central1-a SHARE_TYPE: LOCAL NAME: r-02 IN_USE_COUNT: 3 COUNT: 10 ZONE: us-central1-f SHARE_TYPE: LOCAL
您可以選擇使用篩選運算式精進預訂清單,方法是加入
--filter
旗標:gcloud compute reservations list \ --filter="FILTER_EXPRESSION"
將
FILTER_EXPRESSION
替換為篩選運算式。如要查看預訂的詳細資料,請使用
gcloud compute reservations describe
指令:gcloud compute reservations describe RESERVATION_NAME \ --zone=ZONE
更改下列內容:
RESERVATION_NAME
:現有預訂的名稱。ZONE
:預訂項目所在區域。
輸出結果會與下列範例相似:
creationTimestamp: '2024-10-11T03:25:23.192-07:00' id: '4488228526648280060' kind: compute#reservation name: r-01 selfLink: https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-a/reservations/r-01 shareSettings: shareType: LOCAL specificReservation: assuredCount: '50' count: '50' inUseCount: '25' instanceProperties: machineType: n2-standard-2 specificReservationRequired: false status: READY zone: https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-a
Go
如要查看預訂清單,請使用下列程式碼範例:
如要查看預訂的詳細資料,請使用下列程式碼範例:
Java
如要查看預訂清單,請使用下列程式碼範例:
如要查看預訂的詳細資料,請使用下列程式碼範例:
Node.js
如要查看預訂清單,請使用下列程式碼範例:
如要查看預訂的詳細資料,請使用下列程式碼範例:
Python
如要查看預訂清單,請使用下列程式碼範例:
如要查看預訂的詳細資料,請使用下列程式碼範例:
REST
如要查看保留項目清單,請對
reservations.list
方法發出GET
要求:GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/reservations
更改下列內容:
PROJECT_ID
:您建立預訂項目的專案 ID。ZONE
:預訂項目所在的可用區。
輸出結果會與下列範例相似:
{ "kind": "compute#reservation", "id": "4100668622331754141", "creationTimestamp": "2019-09-27T08:21:14.707-07:00", "selfLink": "https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-a/reservations/reservation-05", "zone": "https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-a", "name": "reservation-05", "specificReservation": { "instanceProperties": { "machineType": "n1-standard-2" }, "count": "100", "inUseCount": "0", "assuredCount": "100" }, "specificReservationRequired": false, "status": "READY", "shareSettings": { "shareType": "LOCAL" } }, { "kind": "compute#reservation", "id": "2533514314332214789", "creationTimestamp": "2019-09-27T08:21:14.707-07:00", "selfLink": "https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-a/reservations/reservation-04", "zone": "https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-a", "name": "reservation-04", "specificReservation": { "instanceProperties": { "machineType": "n1-standard-2", "guestAccelerators": [ { "acceleratorType": "nvidia-tesla-t4", "acceleratorCount": 1 } ], "localSsds": [ { "diskSizeGb": "375", "interface": "SCSI" } ] }, "count": "50", "inUseCount": "25", "assuredCount": "50" }, "specificReservationRequired": false, "status": "READY", "shareSettings": { "shareType": "LOCAL" } }
您可以選擇使用篩選運算式來精細篩選預訂清單,方法是加入
filter
查詢參數:GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/reservations?filter=FILTER_EXPRESSION
將
FILTER_EXPRESSION
替換為使用網址編碼值的篩選器運算式。如要查看預訂的詳細資料,請對
reservations.get
方法發出GET
要求。GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/reservations/RESERVATION_NAME
更改下列內容:
PROJECT_ID
:您建立預訂項目的專案 ID。ZONE
:預訂項目所在區域。RESERVATION_NAME
:現有預訂的名稱。
輸出結果會與下列範例相似:
{ "kind": "compute#reservation", "id": "4488228526648280060", "creationTimestamp": "2024-10-11T03:25:23.192-07:00", "selfLink": "https://www.googleapis.com/compute/v1/projects/davide-experimental/zones/us-central1-a/reservations/r-01", "zone": "https://www.googleapis.com/compute/v1/projects/davide-experimental/zones/us-central1-a", "name": "r-01", "specificReservation": { "instanceProperties": { "machineType": "n2-standard-2" }, "count": "50", "inUseCount": "25", "assuredCount": "50" }, "specificReservationRequired": false, "status": "READY", "shareSettings": { "shareType": "LOCAL" } }
查看未來預留要求
如要查看一或多個日後預訂要求的設定,請使用本節所述的下列任一方法:
如要查看專案中所有未來預留要求的概覽,請查看要求清單。
如要查看單一未來預留要求的完整詳細資料,請查看要求的詳細資料。
如要查看未來的預留項目要求,請選取下列任一選項:
主控台
在 Google Cloud 控制台,前往「Reservations」(預留項目) 頁面。
點按「Future reservations」(未來預留項目) 分頁標籤。
表格會列出每個未來預訂要求,每個表格欄會說明一項資源。
選用:如要縮小要求清單範圍,請在
「Filter」欄位中,選取要用來篩選要求的屬性。如要查看要求的詳細資料,請在「名稱」欄中,按一下要求的名稱。系統會開啟一個頁面,其中列出未來預留要求的詳細資料。
gcloud
如要查看未來預留項目要求清單,請使用
gcloud beta compute future-reservations list
指令:gcloud beta compute future-reservations list
輸出結果會與下列範例相似:
NAME: fr-04 TOTAL_COUNT: 100 START_TIME: 2025-07-20T07:00:00Z END_TIME: 2025-08-05T07:00:00Z PROCUREMENT_STATUS: FULFILLED ZONE: us-east1-a NAME: fr-05 TOTAL_COUNT: 10 START_TIME: 2025-07-20T07:00:00Z END_TIME: 2025-12-01T00:00:00Z PROCUREMENT_STATUS: PENDING_APPROVAL ZONE: us-west1-c
如要使用篩選運算式細分未來預留項目要求清單,可以選擇加入
--filter
標記:gcloud beta compute future-reservations list \ --filter="FILTER_EXPRESSION"
將
FILTER_EXPRESSION
替換為篩選運算式。如要查看未來預留項目要求的詳細資料,請使用
gcloud beta compute future-reservations describe
指令:gcloud beta compute future-reservations describe FUTURE_RESERVATION_NAME \ --zone=ZONE
更改下列內容:
FUTURE_RESERVATION_NAME
:現有未來預訂要求的名稱。ZONE
:未來預訂要求所在的區域。
輸出結果會與下列範例相似:
autoCreatedReservationsDeleteTime: '2025-05-02T01:00:00Z' creationTimestamp: '2025-03-23T10:08:31.613-07:00' id: '5212276518668495076' kind: compute#futureReservation name: fr-01 planningStatus: SUBMITTED selfLink: https://www.googleapis.com/compute/beta/projects/example-project/zones/us-central1-a/futureReservations/fr-01 selfLinkWithId: https://www.googleapis.com/compute/beta/projects/example-project/zones/us-central1-a/futureReservations/5212276518668495076 shareSettings: shareType: LOCAL specificSkuProperties: instanceProperties: machineType: n1-standard-64 totalCount: '800' status: existingMatchingUsageInfo: count: '3' timestamp: '2025-03-30T01:00:00Z' lockTime: '2025-03-30T17:09:59.297799Z' procurementStatus: APPROVED timeWindow: endTime: '2025-05-02T01:00:00Z' startTime: '2025-04-30T17:30:00Z' zone: https://www.googleapis.com/compute/beta/projects/example-project/zones/us-central1-a
REST
如要查看未來預留要求清單,請向 beta
futureReservations.list
方法提出GET
要求:GET https://compute.googleapis.com/compute/beta/projects/PROJECT_ID/zones/ZONE/futureReservations
更改下列內容:
PROJECT_ID
:您建立未來預訂要求的專案 ID。ZONE
:您未來的預訂要求所在區域。
輸出結果會與下列範例相似:
{ "id": "projects/my-project/zones/us-east1-a/futureReservations", "items": [ { "id": "743865190848184978", "creationTimestamp": "2025-03-23T18:16:45.274-07:00", "selfLink": "https://www.googleapis.com/compute/beta/projects/my-project/zones/us-east1-a/futureReservations/fr-base", "selfLinkWithId": "https://www.googleapis.com/compute/beta/projects/my-project/zones/us-east1-a/futureReservations/743865190848184978", "zone": "https://www.googleapis.com/compute/beta/projects/my-project/zones/us-east1-a", "name": "fr-base", "specificSkuProperties": { "instanceProperties": { "machineType": "n1-standard-1" }, "totalCount": "100" }, "planningStatus": "SUBMITTED", "timeWindow": { "endTime": "2025-05-02T01:00:00Z", "startTime": "2025-04-30T17:30:00Z" }, "status": { "procurementStatus": "FULFILLED", "lockTime": "2025-03-30T07:00:00Z", "existingMatchingUsageInfo": { "count": "3", "timestamp": "2025-03-30T01:00:00Z" } }, "kind": "compute#futureReservation" }, ... ], "selfLink": "https://www.googleapis.com/compute/beta/projects/my-project/zones/us-east1-a/futureReservations", "etag": "AnzKY34l-cvvV-JnniESJ0dtQvQ=/hvc4jaHpxFAZmOt1FVtKNgzZu-M=", "kind": "compute#futureReservationsListResponse" }
您可以視需要使用篩選運算式,進一步篩選未來預留項目要求清單,方法是加入
filter
查詢參數:GET https://compute.googleapis.com/compute/beta/projects/PROJECT_ID/aggregated/futureReservations?filter=FILTER_EXPRESSION
將
FILTER_EXPRESSION
替換為使用網址編碼值的篩選器運算式。如要查看未來預留要求的詳細資料,請向 beta
futureReservations.get
方法提出GET
要求:GET https://compute.googleapis.com/compute/beta/projects/PROJECT_ID/zones/ZONE/futureReservations/FUTURE_RESERVATION_NAME
更改下列內容:
PROJECT_ID
:您建立未來預訂要求的專案 ID。ZONE
:未來預訂要求所在的區域。FUTURE_RESERVATION_NAME
:現有未來預訂要求的名稱。
輸出結果會與下列內容相似:
{ "autoCreatedReservationsDeleteTime": "2025-05-02T01:00:00Z", "creationTimestamp": "2025-03-23T10:08:31.613-07:00", "id": "5212276518668495076", "kind": "compute#futureReservation", "name": "fr-01", "planningStatus": "SUBMITTED", "selfLink": "https://www.googleapis.com/compute/beta/projects/example-project/zones/us-central1-a/futureReservations/fr-01", "selfLinkWithId": "https://www.googleapis.com/compute/beta/projects/example-project/zones/us-central1-a/futureReservations/5212276518668495076", "shareSettings": { "shareType": "LOCAL" }, "specificSkuProperties": { "instanceProperties": { "machineType": "n1-standard-64" }, "totalCount": "800" }, "status": { "lockTime": "2025-03-30T17:09:59.297799Z", "procurementStatus": "APPROVED", "existingMatchingUsageInfo": { "count": "3", "timestamp": "2025-03-30T01:00:00Z" } }, "timeWindow": { "endTime": "2025-05-02T01:00:00Z", "startTime": "2025-04-30T17:30:00Z" }, "zone": "https://www.googleapis.com/compute/beta/projects/example-project/zones/us-central1-a" }
判斷可消耗的例項數量
如要判斷可用盡預留容量的運算執行個體數量,請執行下列任一操作:
如要查看可消耗保留項目的執行個體數量上限,請參閱「保留項目中的可消耗執行個體」。
如要查看 Compute Engine 在未來預留要求開始時間時,預計為該要求保留的執行個體數量,請參閱「未來預留要求中的可用執行個體」。
保留項目中的可用例項
查看預訂詳細資料時,您可以查看有多少個運算單元正在使用預訂,以及有多少個運算單元可以使用預訂,方法是檢查下列欄位:
保證數量 (
assuredCount
):在保留區域內實際保留的執行個體數量。這個數字包含為專案保留的執行個體,以及共用預訂的任何專案。總數 (
count
):預留作業系統中指定的預留執行個體數量。這個數字應與保證數量相符。使用中的機器 (
inUseCount
):專案中正在執行的執行個體數量,或共用預留空間的專案。
舉例來說,如果保證數量 (assuredCount
) 和總數量 (count
) 都為 50,且使用保留項目的執行個體數量 (inUseCount
) 為 25,則在保留項目完全用盡之前,還能有 25 個執行個體使用保留項目。
未來預留要求中的可用執行個體
您可以決定 Compute Engine 在未來預留要求開始時間建立的運算執行個體數量。如為草稿、待核准或已核准的申請,您可以透過下列方式判斷此數字:
查看專案中執行中的執行個體和未使用的保留項目數量,以及要求共用到的任何專案是否符合要求的屬性。
將符合要求的執行中執行個體和未使用的預留空間數量從總數中減去。
您可以一次為單一或多個要求決定可用例項數量。如果是多項要求,請使用 Google Cloud 控制台或 REST API。如要處理單一要求,請選取下列任一選項:
主控台
在 Google Cloud 控制台,前往「Reservations」(預留項目) 頁面。
點按「Future reservations」(未來預留項目) 分頁標籤。
表格會列出每個未來預訂要求,每個表格欄會描述一項資源。
如要判斷 Compute Engine 在要求開始時間時,打算為該要求保留的執行個體數量,請將「總數量」欄的相符數量欄減去。
「相符項目數量」欄會顯示下列其中一個警告:
比對計數為零:在您的專案或您要求共用的任何專案中,都沒有相符的執行中執行個體或未使用的預訂。
符合數量等於總數量:Compute Engine 不會在要求的開始時間為您的要求保留任何執行個體。
如果您修改要求,或是建立符合要求的新執行個體或預訂,Compute Engine 會在 30 分鐘內更新比對計數資料欄。
選用:如要查看要求中「相符數量」欄的上次更新時間,請執行下列操作:
在「名稱」欄中,按一下要求的名稱。系統會開啟一個頁面,提供未來預留要求的詳細資料。
在「資源詳細資料」部分,勾選「上次評估相符用量的時間」欄位。
gcloud
如要查看未來預留項目要求的詳細資料,請使用
gcloud beta compute future-reservations describe
指令:gcloud beta compute future-reservations describe FUTURE_RESERVATION_NAME \ --zone=ZONE
更改下列內容:
FUTURE_RESERVATION_NAME
:現有未來預訂要求的名稱。ZONE
:未來預訂要求所在的區域。
在輸出內容中,找出
count
和totalCount
欄位:... specificSkuProperties: ... totalCount: '100' status: existingMatchingUsageInfo: count: '50' timestamp: '2025-03-30T01:00:00Z' ... procurementStatus: DRAFTING ...
從
totalCount
減去count
的值。舉例來說,如果count
為 50,而totalCount
為 100,則 Compute Engine 會在要求開始時間自動建立 50 個執行個體的預留項目。如果您修改要求,或是建立符合要求的新執行個體或預訂,Compute Engine 會在 30 分鐘內更新
existingMatchingUsageInfo
欄位。如要確認這個欄位上次更新的時間,請檢查existingMatchingUsageInfo.timestamp
的值。
REST
如要查看未來預留項目要求清單,請對 beta
futureReservations.list
方法發出GET
要求。在要求網址中加入filter
查詢參數,並指定只顯示name
、specificSkuProperties
和status
欄位:GET https://compute.googleapis.com/compute/beta/projects/PROJECT_ID/zones/ZONE/futureReservations?fields=items.name,items.specificSkuProperties,items.status
更改下列內容:
PROJECT_ID
:您建立未來預訂要求的專案 ID。ZONE
:未來預訂要求所在的區域。
在輸出內容中,找出每個草稿、待核准或已核准要求的
count
和totalCount
欄位:{ "items": [ { "specificSkuProperties": { ... totalCount: "100" }, "name": "fr-01", "status": { "procurementStatus": "APPROVED", ... existingMatchingUsageInfo: { count: "50", "timestamp": "2025-01-22T07:54:26.295Z" } } }, { "specificSkuProperties": { ... totalCount: "20" }, "name": "fr-02", "status": { "procurementStatus": "DRAFTING", ... existingMatchingUsageInfo: { "count": "2", "timestamp": "2025-01-22T07:54:26.295Z" } } } ] }
針對每項要求,從
totalCount
中減去count
的值。舉例來說,如果count
為 50,而totalCount
為 100,則 Compute Engine 會在要求開始時間自動建立 50 個執行個體的預留項目。如果您修改要求,或是建立符合要求的新執行個體或預訂,Compute Engine 會在 30 分鐘內更新
existingMatchingUsageInfo
欄位。如要確認這個欄位上次更新的時間,請檢查existingMatchingUsageInfo.timestamp
的值。
後續步驟
瞭解如何將預留項目加入承諾使用合約。
瞭解如何使用保留項目。
瞭解如何修改預訂。
瞭解如何刪除預訂。