Day 2 - Compute Engine · VPC
VM · VPC · 방화벽 · SSH
목차
학습 목표
- VPC · 서브넷 · 리전 관계 설명
- gcloud로 VM 생성·SSH
- 방화벽 규칙으로 포트 허용
VPC 개요
- VPC: 글로벌 리소스, 서브넷은 리전 단위
- 기본 VPC로 빠른 실습 가능 → 이후 커스텀 VPC 권장
- AWS VPC와 비교하면 “서브넷이 존이 아니라 리전”인 점이 다름
gcloud compute networks list
gcloud compute networks subnets list --network=default
Compute Engine
# 이미지 패밀리 예: Debian
gcloud compute instances create demo-vm \
--zone=asia-northeast3-a \
--machine-type=e2-micro \
--image-family=debian-12 \
--image-project=debian-cloud \
--tags=http-server
gcloud compute instances list
gcloud compute ssh demo-vm --zone=asia-northeast3-a
종료·삭제 (비용 절감):
gcloud compute instances stop demo-vm --zone=asia-northeast3-a
gcloud compute instances delete demo-vm --zone=asia-northeast3-a
방화벽
# HTTP 허용 태그 기반 예
gcloud compute firewall-rules create allow-http \
--allow=tcp:80 \
--target-tags=http-server \
--source-ranges=0.0.0.0/0 \
--description="Allow HTTP"
실습 후 불필요한 규칙은 삭제하세요.
실습
- e2-micro VM 1대 생성
- SSH 접속 후
nginx또는 간단 HTTP 서버 - 방화벽 80 허용 후 브라우저 접속
- 리소스 삭제