Print
카테고리: [ Cloud Computing & MSA ]
조회수: 6261

1. 개요


2. 방법

생성은 gcloud compute instances create 명령어를 사용한다.


3. 생성 예제

$ gcloud compute instances create example-instance \
>       --machine-type=n1-standard-1 \
>       --image-project=ubuntu-os-cloud \
>       --image-family=ubuntu-1804-lts \
>       --zone=asia-northeast1-b
Created [https://www.googleapis.com/compute/v1/projects/xxx/zones/asia-northeast1-b/instances/example-instance].
NAME              ZONE               MACHINE_TYPE   PREEMPTIBLE  INTERNAL_IP  EXTERNAL_IP  STATUS
example-instance  asia-northeast1-b  n1-standard-1               10.146.0.2   34.84.93.94  RUNNING

4. 삭제 예제

$ gcloud compute instances delete example-instance
No zone specified. Using zone [asia-northeast1-b] for instance: [example-instance].
The following instances will be deleted. Any attached disks configured
 to be auto-deleted will be deleted unless they are attached to any
other instances or the `--keep-disks` flag is given and specifies them
 for keeping. Deleting a disk is irreversible and any data on the disk
 will be lost.
 - [example-instance] in [asia-northeast1-b]

Do you want to continue (Y/n)?  y

Deleted [https://www.googleapis.com/compute/v1/projects/xxx/zones/asia-northeast1-b/instances/example-instance].

5. 기타

5.1. 한국리전

2월 6일 현재 한국리전은 보이긴 하나 gcloud SDK로는 한국리전 지정 시 에러가 발생하여 위 예제는 일본 리전으로 생성함

$ gcloud compute instances create example-instance \
>       --machine-type=n1-standard-1 \
>       --image-project=ubuntu-os-cloud \
>       --image-family=ubuntu-1804-lts \
>       --zone=asia-northeast3-a
ERROR: (gcloud.compute.instances.create) Could not fetch resource:
 - Invalid value for field 'zone': 'asia-northeast3-a'. Unknown zone.