This tutorial explains how to create a Linux virtual machine instance in Compute Engine using the Google Cloud Platform Console.
Google Cloud Platform organizes resources into projects. This allows you to collect all the related resources for a single application in one place.
Open the menu on the left side of the console.
Then, select the Compute Engine section.
Click the Create instance button.
-
Select a name and zone for this instance.
-
In the Firewall selector, select Allow HTTP traffic. This opens port 80 (HTTP) to access the app.
-
Click the Create button to create the instance.
Note: Once the instance is created your billing account will start being charged according to the GCE pricing. You will remove the instance later to avoid extra charges.
While the instance is being created take your time to explore the VM instances page.
- At the bottom you can see the list of your VMs
- At the top you can see a control panel allowing
you to
- Create a new VM instance or an instance group
- Start, stop, reset and delete instances
When the VM instance is created, you'll run a web server on the virtual machine.
The SSH buttons in the table will open up an SSH session to your instance in a separate window.
For this tutorial you will connect using Cloud Shell. Cloud Shell is a built-in command line tool for the console.
Open Cloud Shell by clicking icon in the navigation bar at the top of the console.
The instance creation needs to finish before the tutorial can proceed. The activity can be tracked by clicking the notification menu from the navigation bar at the top.
Enter the following command to SSH into the VM. If this is your first time using SSH from Cloud Shell, you will need to create a private key. Enter the zone and name of the instance you created.
gcloud compute --project "{{project-id}}" ssh --zone <vm-zone> <vm-name>
Create a simple index.html file with the following command:
echo "<h1>Hello World!</h1>" > index.html
Then, enter this command to run a simple Python webserver:
sudo python -m SimpleHTTPServer 80
Visit your webserver at the IP address listed in the External IP column.
To remove your instance, select the checkbox next to your instance name and click the Delete button.
You're done!
Here's what you can do next:
-
Find Google Cloud Platform samples on GitHub.
-
Learn how to set up Load Balancing.
-
Learn how to transfer files to your Virtual Machine.
-
Learn how to run containers.