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

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.
主站蜘蛛池模板: 宣恩县| 洞头县| 西和县| 太和县| 红桥区| 温泉县| 东方市| 土默特左旗| 石家庄市| 泸水县| 溧阳市| 泾川县| 磐安县| 洛扎县| 泗洪县| 自贡市| 泽州县| 义马市| 和田县| 寿阳县| 林甸县| 随州市| 西林县| 安岳县| 达孜县| 永胜县| 东莞市| 都江堰市| 噶尔县| 九龙城区| 连山| 察隅县| 南部县| 那曲县| 南安市| 邯郸县| 伊吾县| 疏勒县| 垫江县| 襄汾县| 长宁县|