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

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.
主站蜘蛛池模板: 当阳市| 盘山县| 隆子县| 普兰店市| 安远县| 寿光市| 武陟县| 苍南县| 馆陶县| 南川市| 项城市| 昌图县| 乌鲁木齐市| 卢龙县| 郑州市| 运城市| 金阳县| 伊金霍洛旗| 嘉义市| 泗水县| 乐都县| 大荔县| 黑山县| 克什克腾旗| 通城县| 同德县| 石泉县| 收藏| 嘉禾县| 富民县| 伽师县| 河曲县| 翼城县| 正定县| 芜湖县| 偏关县| 德阳市| 皋兰县| 阳春市| 翁源县| 嘉鱼县|