이 페이지에서는 예약 추천을 사용하여 유휴 상태의 주문형 예약을 식별 및 삭제하여 사용하지 않는 리소스에 대한 요금이 청구되지 않도록 하는 방법을 설명합니다.
- Compute Engine이 예약 추천을 생성하는 방법에 대한 자세한 내용은 유휴 상태 및 사용률이 낮은 예약의 감지 작동 방식을 참고하세요.
- 예약 추천자를 구성해서 수신되는 추천을 늘리거나 줄이는 방법에 대한 자세한 내용은 유휴 상태 예약 추천 구성 또는 사용률이 낮은 예약 추천 구성을 참고하세요.
시작하기 전에
- 제한사항을 검토하여 예약에서 유휴 상태 예약 추천을 지원하는지 확인합니다.
-
아직 인증을 설정하지 않았다면 설정합니다.
인증은 서비스 및 API에 액세스하기 위해 ID를 확인하는 프로세스입니다. Google Cloud
로컬 개발 환경에서 코드 또는 샘플을 실행하려면 다음 옵션 중 하나를 선택하여 Compute Engine에 인증하면 됩니다.
Select the tab for how you plan to use the samples on this page:
When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.
-
Install the Google Cloud CLI, then initialize it by running the following command:
gcloud init
- Set a default region and zone.
REST
로컬 개발 환경에서 이 페이지의 REST API 샘플을 사용하려면 gcloud CLI에 제공한 사용자 인증 정보를 사용합니다.
Install the Google Cloud CLI, then initialize it by running the following command:
gcloud init
자세한 내용은 Google Cloud 인증 문서의 REST 사용을 위한 인증을 참고하세요.
-
유휴 상태 예약 추천 보기
유휴 상태 예약에 대한 추천을 보려면 다음 옵션 중 하나를 사용하세요.
이 태스크에 필요한 권한
이 태스크를 수행하려면 다음과 같은 권한이 있어야 합니다.
- 프로젝트에 대한
recommender.computeIdleResourceRecommendations.list
권한
다음 방법 중 하나를 사용하여 이 작업을 완료합니다.
Google Cloud 콘솔에서 FinOps 허브로 이동합니다.
유휴 상태 예약에 관한 추천을 보려면 --recommender=google.compute.IdleResourceRecommender
플래그와 함께 gcloud recommender recommendations list
명령어를 사용합니다.
gcloud recommender recommendations list \ --location=ZONE \ --recommender=google.compute.IdleResourceRecommender \ --format=yaml \ --project=PROJECT_ID
다음을 바꿉니다.
ZONE
을 추천을 나열할 예약이 포함된 영역으로 바꿉니다.PROJECT_ID
를 프로젝트 ID로 바꿉니다.
예를 들면 다음과 같습니다.
gcloud recommender recommendations list \ --location=us-central1-c \ --recommender=google.compute.IdleResourceRecommender \ --format=yaml \ --project=my-project
해당 위치에 유휴 상태 예약이 없으면 응답은 비어 있습니다. 그렇지 않으면 응답에는 각 추천에 대한 다음 필드가 포함됩니다.
operationGroups
: 추천을 적용하기 위해 수행할 수 있는 작업 그룹description
: 추천 설명
---
associatedInsights:
- insight: projects/953727763714/locations/us-central1-f/insightTypes/google.compute.IdleResourceInsight/insights/ecf77776-4a2a-4e6e-aad2-b7f9c632e5f9
content:
operationGroups:
- operations:
- action: remove
path: /
resource: //compute.googleapis.com/projects/committed-use-discount-test/zones/us-central1-f/reservations/test-reservation
resourceType: compute.googleapis.com/Reservation
overview:
currentReservation:
machineType: n1-standard-1
reservationName: test-reservation
reservedMachineCount: '1'
zone: us-central1-f
description: Save cost by deleting the idle reservation test-reservation
etag: '"aff724ab8e40e1ef"'
lastRefreshTime: '2024-06-10T07:00:00Z'
name: projects/953727763714/locations/us-central1-f/recommenders/google.compute.IdleResourceRecommender/recommendations/56f8ac5d-8380-4cb8-a76f-bbc270fb4b8e
primaryImpact:
category: COST
costProjection:
cost:
currencyCode: USD
nanos: -199820000
units: '-1072'
costInLocalCurrency:
currencyCode: USD
nanos: -199820000
units: '-1072'
duration: 2592000s
priority: P2
recommenderSubtype: DELETE_RESERVATION
stateInfo:
state: ACTIVE
targetResources:
- //compute.googleapis.com/projects/committed-use-discount-test/zones/us-central1-f/reservations/test-reservation
gcloud 예시에서 Google Cloud CLI를 사용하여 추천을 사용하는 방법을 자세히 알아보세요.
유휴 상태 예약에 관한 추천을 보려면 recommendations.list
메서드에 대해 GET
요청을 실행하고 다음 추천 유형을 사용합니다.
- google.compute.IdleResourceRecommender
API 호출은 다음과 같습니다.
GET https://recommender.googleapis.com/v1/projects/PROJECT_ID /locations/ZONE /recommenders/google.compute.IdleResourceRecommender/recommendations
다음을 바꿉니다.
- PROJECT_ID
: 프로젝트의 ID.
ZONE
: 추천을 나열할 인스턴스가 포함된 영역.
다음 예시에서는 curl
및 관련 샘플 응답을 사용하여 요청을 보내는 방법을 보여줍니다.
PROJECT_ID=my-project ZONE=us-central1-c RECOMMENDER_ID=google.compute.IdleResourceRecommender curl -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "x-goog-user-project: $PROJECT_ID" \ https://recommender.googleapis.com/v1/projects/$PROJECT_ID/locations/$ZONE/recommenders/$RECOMMENDER_ID/recommendations
유휴 상태 예약 추천에 대한 JSON 응답의 예시
{
"associatedInsights": [
{
"insight": "projects/9531234763714/locations/us-central1-f/insightTypes/google.compute.IdleResourceInsight/insights/ecf77776-4a2a-4e6e-aad2-b7f9c632e5f9"
}
],
"content": {
"operationGroups": [
{
"operations": [
{
"action": "remove",
"path": "/",
"resource": "//compute.googleapis.com/projects/committed-use-discount-test/zones/us-central1-f/reservations/test-reservation",
"resourceType": "compute.googleapis.com/Reservation"
}
]
}
],
"overview": {
"currentReservation": {
"machineType": "n1-standard-1",
"reservationName": "test-reservation",
"reservedMachineCount": "1",
"zone": "us-central1-f"
}
}
},
"description": "Save cost by deleting the idle reservation test-reservation",
"etag": "\"8d5603cac8fa9342\"",
"lastRefreshTime": "2024-06-11T07:00:00Z",
"name": "projects/9531234763714/locations/us-central1-f/recommenders/google.compute.IdleResourceRecommender/recommendations/56f8ac5d-8380-4cb8-a76f-bbc270fb4b8e",
"primaryImpact": {
"category": "COST",
"costProjection": {
"cost": {
"currencyCode": "USD",
"nanos": -199820000,
"units": "-1072"
},
"costInLocalCurrency": {
"currencyCode": "USD",
"nanos": -199820000,
"units": "-1072"
},
"duration": "2592000s"
}
},
"priority": "P2",
"recommenderSubtype": "DELETE_RESERVATION",
"stateInfo": {
"state": "ACTIVE"
},
"targetResources": [
"//compute.googleapis.com/projects/committed-use-discount-test/zones/us-central1-f/reservations/test-reservation"
]
}
각 필드에 대한 자세한 내용은 Recommender API 참고 리소스를 참조하세요.
권장사항 응답 해석
gcloud CLI 또는 REST를 통해 수신하는 각 권장사항에는 순차적으로 수행하여 권장사항을 적용할 수 있는 작업으로 구성된 작업 그룹이 포함됩니다. 유휴 상태 예약의 경우 작업 그룹에 예약을 삭제하는 remove
작업이 포함됩니다.
{
"action": "remove",
"path": "/",
"resource": "//compute.googleapis.com/projects/committed-use-discount-test/zones/us-central1-f/reservations/test-reservation",
"resourceType": "compute.googleapis.com/Reservation"
}
유휴 예약 추천 적용
유휴 상태 예약 추천에 따라 예약 크기를 조정하거나 더 이상 필요하지 않은 경우 예약을 삭제합니다.
다음 단계
- Compute Engine 예약 작동 방식 자세히 알아보기
- 유휴 예약 권장사항을 구성하는 방법 알아보기
- 유휴 상태 예약 추천을 구성하는 방법 알아보기