Note: A lot of what I am compiling here will be snippets from all over the web, so please note there may be content which is copied, with the intention of one continuous post, rather then having to go searching multiple pages.
Setup your Google Container Engine Account
The first part of this process is making sure you have activated the Google Container Engine API on your google developer account.
- If you have a developer account, go to developer.google.com and sign in with your usual google user account. Once you have signed in you will need to create a new project, and once the project is created you can activate the container engine by clicking on the "Compute" option and then select "Container Engine" and select the "Container Registry" link. This will start the process of enabling the container engine api. It will ask you for your details and require your credit card details. I imagine this to be a means of making sure you don't just use the system for "illegal" purposes, seeing as you have a 60 day free trial period.
- If you don't have a developer account yet, go straight to the container engine page https://cloud.google.com/container-engine/ and sign in and sign up and follow all the processes (similar to the step above) to get yourself signed in.

Install the Google Cloud SDK
This process is getting your system setup for communicating with your google account api. You can install the Cloud API on a windows machine, but there are some tools that we are going to use that aren't supported on the windows platform, so you need to use Linux or Mac. I am sticking to a Mac oriented approach, but Im sure that most of the commands will work in Linux. (instructions and info can be found here)
- Open up a terminal.
- Install the gcloud application:
curl https://sdk.cloud.google.com | bash
- Restart the shell
exec -l $SHELL
- Authenticate the installation with your google cloud platform account using:
gcloud auth login
- This will open up the browser and ask you to sign in with your google user name and password. Once this is complete, the gcloud app is authenticates and has access to your google account.
Create Your Instance
Once you have finished configuring and installing your environment, you can proceed with creating your first instance. You can think of an instance as the equivalent to a virtual machine which we are going to configure as a docker host.
After you set up your project and billing, go to the VM instances section in the Developers Console.
- Click Create instance to see the available options for your new instance.
- Set the Name of your instance to my-first-instance.
- Under Boot disk, click Change and select a Debian boot disk image if it is not already specified by default. Compute Engine has several other operating systems for you to choose from, but use Debian for this example.
- Enable the Allow HTTP traffic option so that this instance can serve web content over http port 80.
- Click Create to create your instance. The page automatically refreshes after the instance starts.
After the instance starts up, it is listed on the VM instances page with a green status icon.
Connecting to your Instance
Its now time to connect to the instance you just created.
- Go to the VM instances page in the Google Developers Console.
- Click the name of your virtual machine. In this case, my-first-instance.
- On the top of the instance’s page, click SSH. A terminal opens in a new browser window and automatically connects to your instance.
Install Apache HTTP Server
Now that you have an instance, you will probably want to get it to do something. Here is the process of installing an Apache server onto the instance so that you can serve webpages.
From the terminal window, you can control the instance like any standard Linux server. Install the apache2 package and host a web page. Instead of using the terminal window from your browser, lets setup the terminal on your pc to link to your instance:
- Open up the terminal and type the following command:
gcloud config set project "google-cloud-project-id"
This makes sure that the gcloud sdk is always configured for your project. This is not important if you have multiple projects. - Connect to the instance you just created:
gcloud compute ssh --zone "us-central1-f" "my-first-instance"
or if you want to specify which project your instance is ingcloud compute --project "google-cloud-project-id" ssh --zone "us-central1-f" "my-first-instance"
- Install Apache HTTP Server with the following command:
sudo apt-get update && sudo apt-get install apache2
- Create a new home page. The Apache web server has a default web page that we can overwrite with the following command:
echo '<!doctype html><html><body><h1>Hello World!</h1></body></html>' | sudo tee /var/www/index.html
- Test that your instance is serving traffic on its external IP. Go to the VM instances page in the Google Developers Console. Click the external IP for my-first-instance under the EXTERNAL IP column. Your browser automatically opens to the IP in a new window. If your webserver is working, the web page prints Hello World!
Delete the instance
When you are finished using your instance, you can delete it and the associated root persistent disk. Deleting an instance stops the virtual machine and removes it from the project.
To delete a virtual machine instance:
- Go to the VM instances page in the Google Developers Console.
- Click the name of a virtual machine. In this case, my-first-instance.
- On the top of the instance’s page, click Delete.
Next steps
After you are comfortable using the Google Developers Console to manage instances, see Instances to learn how to manage instances with the gcloud command line tool and the API.
For more information about Linux instances, see Linux Operating Systems.
No comments:
Post a Comment