Skip to content

Commit 9d211b4

Browse files
committed
[setup] Add port forwarding instructions on GCE VM
1 parent 5b7c7c0 commit 9d211b4

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

setup/gcp-instructions.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,22 @@
88
VM_NAME=<your-vm-name>
99
PROJECT_ID=<your-project-id>
1010
SERVICE_ACCOUNT=<your-service-account>
11-
12-
gcloud compute instances create ${VM_NAME} --project=${PROJECT_ID} --zone=us-west1-a --machine-type=n1-standard-1 --network-interface=network-tier=STANDARD,stack-type=IPV4_ONLY,subnet=default --maintenance-policy=MIGRATE --provisioning-model=STANDARD --service-account=${SERVICE_ACCOUNT} --scopes=https://www.googleapis.com/auth/devstorage.read_only,https://www.googleapis.com/auth/logging.write,https://www.googleapis.com/auth/monitoring.write,https://www.googleapis.com/auth/service.management.readonly,https://www.googleapis.com/auth/servicecontrol,https://www.googleapis.com/auth/trace.append --create-disk=auto-delete=yes,boot=yes,device-name=maverick-gcp-dev-vm3,image=projects/ubuntu-os-cloud/global/images/ubuntu-2204-jammy-v20250128,mode=rw,size=20,type=pd-standard --no-shielded-secure-boot --shielded-vtpm --shielded-integrity-monitoring --labels=goog-ec-src=vm_add-gcloud --reservation-affinity=any --enable-nested-virtualization
11+
ZONE=<your-zone>
12+
13+
gcloud compute instances create ${VM_NAME} --project=${PROJECT_ID} --zone=${ZONE} --machine-type=n1-standard-1 --network-interface=network-tier=STANDARD,stack-type=IPV4_ONLY,subnet=default --maintenance-policy=MIGRATE --provisioning-model=STANDARD --service-account=${SERVICE_ACCOUNT} --scopes=https://www.googleapis.com/auth/devstorage.read_only,https://www.googleapis.com/auth/logging.write,https://www.googleapis.com/auth/monitoring.write,https://www.googleapis.com/auth/service.management.readonly,https://www.googleapis.com/auth/servicecontrol,https://www.googleapis.com/auth/trace.append --create-disk=auto-delete=yes,boot=yes,device-name=maverick-gcp-dev-vm3,image=projects/ubuntu-os-cloud/global/images/ubuntu-2204-jammy-v20250128,mode=rw,size=20,type=pd-standard --no-shielded-secure-boot --shielded-vtpm --shielded-integrity-monitoring --labels=goog-ec-src=vm_add-gcloud --reservation-affinity=any --enable-nested-virtualization
14+
15+
NETWORK_TAG=allow-ingress-ports
16+
FIREWALL_RULE=allow-ingress-ports-rule
17+
gcloud compute instances add-tags ${VM_NAME} --tags=${NETWORK_TAG} --zone=${ZONE}
18+
gcloud compute firewall-rules create ${FIREWALL_RULE} \
19+
--direction=INGRESS \
20+
--priority=1000 \
21+
--network=default \
22+
--action=ALLOW \
23+
--rules=tcp:3000-5000,tcp:7000 \
24+
--source-ranges=0.0.0.0/0 \
25+
--target-tags=${NETWORK_TAG} \
26+
--description="Allow TCP ingress on ports 3000-5000 and 7000 for VMs with the ${NETWORK_TAG} tag"
1327
```
1428

1529
## Instructions to run on the GCE VM

0 commit comments

Comments
 (0)