Google Compute Engine (GCE)

Unlike Amazon or Azure, GCE offers no Marketplace for images. The following sections will show how to create and run a USP enabled GCE instance.

  1. Sign up for Google Cloud Platform

Go to https://cloud.google.com and use your Google account to sign up for Google Cloud Platform and complete the guided instructions.

  1. Create a Project

Next, go to the console at https://cloud.google.com/console and create a new Project. Make sure to select your new Project if you are not automatically directed to the Project.

Projects are a way of grouping together related users, services, and billing. You may opt to create multiple Projects and the remaining instructions will need to be completed for each Project.

  1. Enable the Google Compute Engine service

In your Project, either just click Compute Engine to the left, or go to the APIs & auth section and APIs link and enable the Google Compute Engine service.

  1. Create a Service Account

To set up authorization, navigate to APIs & auth section and then the Credentials link and click the CREATE NEW CLIENT ID button. Select Service Account and click the Create Client ID button. This will automatically download a .json file containing the auth settings.

You will need the project id and the json account file in the following section.

Creating a GCE image

Packer is easy to use and automates the creation of any type of machine images.

Packer uses a json template file consisting of builders, provisioners and other (optional) elements.

usp-packer.json contains the template to build an image and install USP in GCE.

The following snippet lists the builder for an Ubuntu 14 install in the European zone.

{
  "variables": {
    "account_file": "YOUR_ACCOUNT_FILE",
    "project_id": "YOUR_PROJECT_ID"
  },
  "builders":[{
    "type": "googlecompute",
    "account_file": "{{user `account_file`}}",
    "project_id": "{{user `project_id`}}",
    "source_image": "ubuntu-1404-trusty-v20141212",
    "zone": "europe-west1-c",
    "image_name": "usp-xyz-apache24-server-ubuntu-1404-amd64",
    "image_description": "",
    "machine_type": "n1-standard-1",
    "ssh_username": "root"
  }]
}

Make sure to replace YOUR_ACCOUNT_FILE and YOUR_PROJECT_ID with your actual account file and project id.

Adding the license key

Add the following line as the first line in the provisioner described below:

#!/bin/bash

"sudo sh -c 'echo "YOUR_KEY" > /etc/usp-license.key'"

Make sure to replace YOUR_KEY with your actual License Key.

Install USP and demo content

USP and demo content can be installed by using a provisioner as follows:

{
  "provisioners":[{
    "type": "shell",
    "execute_command":  "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'",
    "inline": [
      "sudo sh -c 'echo \"YOUR_KEY\" > /etc/usp-license.key'",
      "wget http://repository.unified-streaming.com/install-tears-of-steel.sh",
      "chmod +x install-tears-of-steel.sh",
      "sudo ./install-tears-of-steel.sh"
    ],
    "inline_shebang": "/bin/sh -x"
  }]
}

Configuration

To use the hostname of the instance (so it's ready after booting) you would need to replace the default hostname - which can be done as follows.

#!/bin/bash

hn=$(curl http://metadata.google.internal/computeMetadata/v1/instance/hostname -H "Metadata-Flavor: Google")
/bin/sed -i -e "s/features.unified-streaming.com/$hn/g" /var/www/tears-of-steel/features.json

This then needs to be run when the instance is starting up, so for instance as conf file in /etc/init.

Create image

To start a build of the image as do the following:

#!/bin/bash

packer build usp-build.json

When the build is finished you can go to your project in the console and start the image.

Using Google storage

Similar to Amazon S3 and Azure storage the GCE can be used together with Google storage.