이 페이지에서는 인스턴스 템플릿을 가져오고 나열하고 삭제하는 방법을 설명합니다.
시작하기 전에
-
아직 인증을 설정하지 않았다면 설정합니다.
인증은 서비스 및 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.
- 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.
Go
로컬 개발 환경에서 이 페이지의 Go 샘플을 사용하려면 gcloud CLI를 설치 및 초기화한 다음 사용자 인증 정보로 애플리케이션 기본 사용자 인증 정보를 설정하세요.
자세한 내용은 다음을 참조하세요: Set up authentication for a local development environment.
Java
로컬 개발 환경에서 이 페이지의 Java 샘플을 사용하려면 gcloud CLI를 설치 및 초기화한 다음 사용자 인증 정보로 애플리케이션 기본 사용자 인증 정보를 설정하세요.
자세한 내용은 다음을 참조하세요: Set up authentication for a local development environment.
Node.js
로컬 개발 환경에서 이 페이지의 Node.js 샘플을 사용하려면 gcloud CLI를 설치 및 초기화한 다음 사용자 인증 정보로 애플리케이션 기본 사용자 인증 정보를 설정하세요.
자세한 내용은 다음을 참조하세요: Set up authentication for a local development environment.
Python
로컬 개발 환경에서 이 페이지의 Python 샘플을 사용하려면 gcloud CLI를 설치 및 초기화한 다음 사용자 인증 정보로 애플리케이션 기본 사용자 인증 정보를 설정하세요.
자세한 내용은 다음을 참조하세요: Set up authentication for a local development environment.
REST
로컬 개발 환경에서 이 페이지의 REST API 샘플을 사용하려면 gcloud CLI에 제공한 사용자 인증 정보를 사용합니다.
Install the Google Cloud CLI, then initialize it by running the following command:
gcloud init
자세한 내용은 Google Cloud 인증 문서의 REST 사용을 위한 인증을 참고하세요.
-
인스턴스 템플릿 정보 가져오기
- Google Cloud 콘솔에서 인스턴스 템플릿 페이지로 이동합니다.
- 인스턴스 템플릿 이름을 클릭하여 템플릿 세부정보를 확인합니다.
리전 또는 전역 인스턴스 템플릿에 대한 정보를 가져오려면 instance-templates describe command
를 사용합니다.
리전 인스턴스 템플릿의 경우 다음 명령어를 사용합니다.
gcloud compute instance-templates describeINSTANCE_TEMPLATE_NAME \ --region=REGION
전역 인스턴스 템플릿의 경우 다음 명령어를 사용합니다.
gcloud compute instance-templates describeINSTANCE_TEMPLATE_NAME
리전 인스턴스 템플릿에 대한 정보를 가져오려면 다음과 같이 regionInstanceTemplates.get
메서드를 사용합니다.
GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID /regions/REGION /instanceTemplates/INSTANCE_TEMPLATE_NAME
전역 인스턴스 템플릿에 대한 정보를 가져오려면 다음과 같이 instanceTemplates.get
을 사용합니다.
GET https://compute.googleapis.com/compute/v1/projects/[PROJECT_ID]/global/instanceTemplates/[INSTANCE_TEMPLATE]
인스턴스 템플릿 나열
인스턴스 템플릿 목록을 가져오려면 다음을 만듭니다.
인스턴스 템플릿 페이지에 프로젝트의 인스턴스 템플릿이 모두 나열됩니다.
모든 리전 인스턴스 템플릿 목록을 가져오려면 다음 명령어를 사용합니다.
gcloud compute instance-templates list \ --regions
특정 리전의 리전 인스턴스 템플릿 목록을 가져오려면 다음 명령어를 사용합니다.
gcloud compute instance-templates list \ --filter="region:(REGION )"
전역 인스턴스 템플릿 목록을 가져오려면 다음 명령어를 사용합니다.
gcloud compute instance-templates list \ --global
리전 및 전역을 포함하여 모든 인스턴스 템플릿 목록을 가져오려면 다음 명령어를 사용합니다.
gcloud compute instance-templates list
리전 인스턴스 템플릿 목록을 가져오려면 regionInstanceTemplates.list
요청을 실행합니다.
GET https://compute.googleapis.com/compute/v1/projects/PROJECT /regions/REGION /instanceTemplates
전역 인스턴스 템플릿 목록을 가져오려면 instanceTemplates.list
요청을 실행합니다.
GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID /global/instanceTemplates
인스턴스 템플릿 삭제
인스턴스 템플릿을 삭제하면 템플릿 목록에서 템플릿이 제거됩니다. 관리형 인스턴스 그룹에서 참조하는 인스턴스 템플릿은 삭제할 수 없습니다.
- Google Cloud 콘솔에서 인스턴스 템플릿 페이지로 이동합니다.
- 삭제할 인스턴스 템플릿을 선택합니다.
- 삭제를 클릭합니다.
Google Cloud CLI를 사용하여 다음을 실행합니다.
gcloud compute instance-templates deleteINSTANCE_TEMPLATE_NAME
리전 인스턴스 템플릿의 경우 INSTANCE_TEMPLATE_NAME에 템플릿의 전체 URL이 포함되어야 합니다. 예를 들면 https://www.googleapis.com/compute/v1/projects/example-project/regions/us-central1/instanceTemplates/example-regional-instance-template
입니다.
리전 인스턴스 템플릿을 삭제하려면 regionInstanceTemplates.delete
요청을 수행합니다.
DELETE https://compute.googleapis.com/compute/v1/projects/PROJECT_ID /regions/REGION /instanceTemplates/INSTANCE_TEMPLATE_NAME
전역 인스턴스 템플릿을 삭제하려면 instanceTemplates.delete
요청을 수행합니다.
DELETE https://compute.googleapis.com/compute/v1/projects/PROJECT_ID /global/instanceTemplates/INSTANCE_TEMPLATE_NAME
때로는 관리형 인스턴스 그룹의 VM이 그룹 내의 나머지 인스턴스와 동기화되지 않을 수 있으며, 이는 인스턴스에 사용되는 인스턴스 템플릿이 그룹 내의 나머지 인스턴스와 다른 경우입니다. 관리형 인스턴스 그룹의 한 이 그룹에 지정된 것과 다른 템플릿을 사용하는 경우 이 VM은 해당 템플릿이 삭제된 경우에도 계속해서 이 템플릿을 복구에 사용하려고 합니다. 새 인스턴스 템플릿 적용에 대한 자세한 내용은 MIG의 VM에 새 구성 적용을 참조하세요.