官术网_书友最值得收藏!

Creating and configuring a GCE instance

After creating the start up script, follow these steps:

  1. With the start up script ready, we can create an instance using the gcloud command:
$ gcloud compute instances create mysite-instance \
--image-family=debian-8 \
--image-project=debian-cloud \
--machine-type=g1-small \
--scopes userinfo-email,cloud-platform \
--metadata-from-file startup-script=./startup-script.sh \
--zone us-east1-c \
--tags mysite-server 
  1. You can check the progress of the instance creation using the following command:
$ gcloud compute instances get-serial-port-output \
mysite-instance --zone us-east1-c
  1. Create a firewall rule to allow access to port 3000 to the instance:
$ gcloud compute firewall-rules create default-allow-http-3000 \
--allow tcp:3000 \
--source-ranges 0.0.0.0/0 \
--target-tags mysite-server \
--description "Allow port 3000 access to mysite-server" 

   The following screenshot shows the details of the firewall rule:

The tags on the firewall rule and the create instance commands should match.
  1. Get the public IP of the instance from the Google Cloud Console or by using the following command:
$ gcloud compute instances list
  1. Navigate to http://<public IP of the instance>:3000 to see the application running.
主站蜘蛛池模板: 定安县| 北宁市| 定南县| 河北区| 兴城市| 松原市| 平湖市| 滨州市| 灌云县| 汪清县| 竹北市| 铁岭县| 香河县| 萝北县| 乌鲁木齐县| 循化| 诸暨市| 临洮县| 惠州市| 大宁县| 上犹县| 屏山县| 大冶市| 霍山县| 保山市| 涡阳县| 仁化县| 梨树县| 阳江市| 镇原县| 和龙市| 宝应县| 依兰县| 北海市| 区。| 信阳市| 东山县| 义马市| 龙山县| 山东省| 公安县|