Google Cloud Platform

Regions and Zones 1

Region Zones Location
asia-east1 a, b, c Changhua County, Taiwan
asia-east2 a, b, c Hong Kong
asia-northeast1 a, b, c Tokyo, Japan
asia-northeast2 a, b, c Osaka, Japan
asia-south1 a, b, c Mumbai, India
asia-southeast1 a, b, c Jurong West, Singapore
australia-southeast1 a, b, c Sydney, Australia
europe-north1 a, b, c Hamina, Finland
europe-west1 b, c, d St. Ghislain, Belgium
europe-west2 a, b, c London, England, UK
europe-west3 a, b, c Frankfurt, Germany
europe-west4 a, b, c Eemshaven, Netherlands
europe-west6 a, b, c Zürich, Switzerland
northamerica-northeast1 a, b, c Montréal, Québec, Canada
southamerica-east1 a, b, c Osasco (São Paulo), Brazil
us-central1 a, b, c, f Council Bluffs, Iowa, USA
us-east1 b, c, d Moncks Corner, South Carolina, USA
us-east4 a, b, c Ashburn, Northern Virginia, USA
us-west1 a, b, c The Dalles, Oregon, USA
us-west2 a, b, c Los Angeles, California, USA

Setting a default compute zone

gcloud config set compute/zone us-central1-a

Set the default region:

gcloud config set compute/region us-central1

gsutil command line

-[ ] TODO

VM instances


gcloud compute instances create --help


gcloud compute instances create gcelab2 --machine-type n1-standard-2 --zone us-central1-c


gcloud compute instances list

SSH access

gcloud compute ssh gcelab2 --zone us-central1-c


Create a startup script to be used by every virtual machine instance.

cat << EOF >
#! /bin/bash
apt-get update
apt-get install -y nginx
service nginx start
sed -i -- 's/nginx/Google Cloud Platform - '"\$HOSTNAME"'/' /var/www/html/index.nginx-debian.html

Create template

gcloud compute instance-templates create nginx-template \

Target pool

gcloud compute target-pools create nginx-pool

Instance group

gcloud compute instance-groups managed create nginx-group \
         --base-instance-name nginx \
         --size 2 \
         --template nginx-template \
         --target-pool nginx-pool

Firewall rules


gcloud compute firewall-rules create www-firewall --allow tcp:80
gcloud compute forwarding-rules create nginx-lb \
         --region us-central1 \
         --ports=80 \
         --target-pool nginx-pool

List rules

gcloud compute forwarding-rules list


Kubernetes Engine cluster

Create cluster

gcloud container clusters create [CLUSTER-NAME]
# like
gcloud container clusters create cluster1

List cluster

gcloud container clusters list

Get authentication credentials for the cluster

gcloud container clusters get-credentials [CLUSTER-NAME]
# like
gcloud container clusters get-credentials cluster1

Deploy application

kubectl run hello-server --port 8080
Expose your application to external traffic
kubectl expose deployment hello-server --type="LoadBalancer"
After deploy - get service detail
kubectl get service hello-server
Distroy cluster
gcloud container clusters delete cluster1


check version
kubectl version
run instance
kubectl run nginx --image=nginx:1.10.0
get pots
kubectl get pods
expose deployment

kubectl expose deployment nginx --port 80 --type LoadBalancer
get services
kubectl get services
scale deployment
kubectl scale deployment nginx --replicas 3

App engine


gcloud app deploy ./index.yaml ./app.yaml




gcloud compute networks list
gcloud compute networks subnets list --sort-by=NETWORK


gcloud compute networks create privatenet --subnet-mode=custom

firlistewall rules

gcloud compute firewall-rules list --sort-by=NETWORK

Deployment Manager and Stackdriver

yaml file

  - name: my-vm
    type: compute.v1.instance
      zone: us-central1-a
      machineType: zones/ZONE/machineTypes/n1-standard-1
        - key: startup-script
          value: "apt-get update"
      - deviceName: boot
        type: PERSISTENT
        boot: true
        autoDelete: true
      - network:
        - name: External NAT
          type: ONE_TO_ONE_NAT

create deployment

gcloud deployment-manager deployments create my-first-depl --config mydeploy.yaml

update deployment

gcloud deployment-manager deployments update my-first-depl --config mydeploy.yaml