Plan

GCE 101
New stuff
Cool features
Pretty picture demo time!

GCE 101

IaaS: VMs, Networks, Storage
 
Google DNA:
Scale, Speed, Secure, Global
Expertise & experience

New and Cool

Open for everyone!

f1-micro

0.6 GB RAM, burstable CPU
1.9¢ per hour

g1-small

1.7 GB RAM, fixed CPU
5.4¢ per hour

Per Minute Pricing

10 minute minimum

Persistent Disk

10TB volumes
Root on PD
Hot attach/detach

Advanced Routing

Gateways, VPN

Early Access Program

Loadbalancing
Monitoring

Cloud Datastore

My pipe dream is for Google to combine Compute Engine’s flexible virtual machines with App Engine’s ridiculously impressive datastore.
— Ben Kamens, Khan Academy

Cool Features

Instance Metadata

Simple 'variables' for VMs

Key/value pairs
Set via API
Exposed in Guest via HTTP
Optional project wide

Instance Metadata

me@workstation$ gcutil addinstance metadata-example \
  --metadata=role:master --metadata_from_file=config:config.txt
me@workstation$ gcutil ssh metadata-example
[...snip...]
me@metadata-example$ MDS=http://metadata/computeMetadata/v1beta1/instance
me@metadata-example$ curl ${MDS}/attributes/role
master
me@metadata-example$ curl ${MDS}/attributes/config
[...file content...]

Recursive Metadata

me@metadata-example$ curl -s http://metadata/computeMetadata/v1beta1/?recursive=true \
  | python -m json.tool
{
    "instance": {
        "attributes": {
            "role": "master"
            "config": "[...snip...]"
        },
        "description": "",
        "disks": [
            [...snip...]
        ],
        "hostname": "metadata-example.c.my-project.internal",
        [...snip...]
    },
    "project": {
        "attributes": {
            "sshKeys": "[...snip...]"
        },
        "numericProjectId": 1234,
        "projectId": "my-project"
    }
}

Start Up Scripts

Simple Bootstrapping

Builds on Metadata
Equivalent to rc.local
Examples:
Install packages, download code,
Bootstrap chef or puppet

Start Up Scripts

me@workstation$ cat startup.sh
#! /bin/bash
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
sudo rpm -Uvh epel-release-6*.rpm
yum install -y npm
npm install socket.io socket.io-client express request

ROLE=$(curl http://metadata/computeMetadata/v1beta1/instance/attributes/role)
gsutil cp gs://my-app/roles/$ROLE role.sh
./role.sh
me@workstation$ gcutil addinstance start-me-up \
--metadata_from_file=startup-script:startup.sh \
--service_account_scopes=storage-rw
me@workstation$ gcutil ssh start-me-up
[...snip...]
me@start-me-up$ cat /var/log/startupscript.log

Startup Scripts + Custom Images

  • Try and avoid custom images if you can
  • Script image build
Useful pattern for custom images, scratch boot and PD boot:
$! /bin/bash
IMAGE_VERSION=2
IMAGE_MARK=/var/myapp.image.$IMAGE_VERSION
if [ ! -e $IMAGE_MARK ];
then
  [... runs one time ...]
fi
[... runs every boot ...]

Service Accounts

Frictionless Access to Google APIs

Synthetic identity for code
Examples:
Download from Cloud Storage
App data in Cloud Datastore
Compute API itself

Service Accounts

Google Compute Engine calling Google Cloud Storage

me@workstation$ gcutil addinstance sa-example \
  --service_account_scopes=storage-rw
me@workstation$ gcutil ssh sa-example
[snip]
me@sa-example$ gsutil mb gs://unique-bucket-name
Creating gs://unique-bucket-name/...
No configuration or passwords required!

Much more!

Internal DNS
Ephemeral to static IP promotion
Attach R/O disk to many VMs
APIs everywhere

Demo Time

<Thank You!>