Wednesday 16 December 2015

Google Cloud Platform Overview

https://cloud.google.com/

Documentation:
https://cloud.google.com/docs/
https://cloud.google.com/compute/docs/zones?hl=en
https://cloud.google.com/sdk/gcloud/
https://cloud.google.com/compute/docs/gcloud-compute/

Tutorials:

https://cloud.google.com/docs/tutorials

Console:
https://console.developers.google.com/

Free Trial ($300/60days):

https://cloud.google.com/free-trial/

Startup $100,000 free credit:
https://cloud.google.com/developers/startups/

Getting Started:

https://www.youtube.com/user/googlecloudplatform/videos

Pricing:





























Standard machine types

Machine typeVirtual CPUsMemoryGCEU1Lowest price2(USD) per hour with full sustained usageTypical price3(USD) per hourFull price4(USD) per hour without sustained usePreemptible price5(USD) per hour
n1-standard-113.75GB2.75$0.035$0.038$0.050$0.015
n1-standard-227.5GB5.50$0.070$0.076$0.100$0.030
n1-standard-4415GB11$0.140$0.152$0.200$0.060
n1-standard-8830GB22$0.280$0.304$0.400$0.120
n1-standard-161660GB44$0.560$0.608$0.800$0.240
n1-standard-32632120GB88$1.120$1.216$1.600$0.480
Custom machine type
If your ideal machine shape is in between two predefined types, using a custom machine type could save you as much as 40%. Read more about Custom Machine Types.

Shared-core machine types

Machine typeVirtual CPUsMemoryGCEU1Lowest price2(USD) per hour with full sustained usageTypical price3(USD) per hourFull price4(USD) per hour without sustained usePreemptible price5(USD) per hour
f1-micro10.60GBShared
CPU
$0.0056$0.006$0.008$0.005
g1-small11.70GB1.38$0.019$0.021$0.027$0.010

High-memory machine types

Machine typeVirtual CPUsMemoryGCEU1Lowest price2(USD) per hour with full sustained usageTypical price3(USD) per hourFull price4(USD) per hour without sustained usePreemptible price5(USD) per hour
n1-highmem-2213GB5.50$0.088$0.096$0.126$0.035
n1-highmem-4426GB11$0.176$0.192$0.252$0.070
n1-highmem-8852GB22$0.352$0.384$0.504$0.140
n1-highmem-1616104GB44$0.704$0.768$1.008$0.280
n1-highmem-32632208GB88$1.408$1.536$2.016$0.560
Custom machine type
If your ideal machine shape is in between two predefined types, using a custom machine type could save you as much as 40%. Read more about Custom Machine Types.

High-CPU machine types

Machine typeVirtual CPUsMemoryGCEU1Lowest price2(USD) per hour with full sustained usageTypical price3(USD) per hourFull price4(USD) per hour without sustained usePreemptible price5(USD) per hour
n1-highcpu-221.80GB5.50$0.053$0.058$0.076$0.020
n1-highcpu-443.60GB11$0.106$0.116$0.152$0.040
n1-highcpu-887.20GB22$0.212$0.232$0.304$0.080
n1-highcpu-161614.40GB44$0.424$0.464$0.608$0.160
n1-highcpu-3263228.80GB88$0.848$0.928$1.216$0.320
Custom machine type
If your ideal machine shape is in between two predefined types, using a custom machine type could save you as much as 40%. Read more about Custom Machine Type.
Custom machine types




























ItemPrice (USD) per hourPreemptible price (USD) per hour
vCPU$0.03492 / vCPU$0.01002 / vCPU
Memory$0.00468 / GB$0.00156 / GB
Sustained use discounts
Usage Level (% of month)% at which incremental is chargedExample incremental rate (USD/hour) for an n1-standard-1 instance
0%-25%100% of base rate$0.050
25%-50%80% of base rate$0.040
50%-75%60% of base rate$0.030
75%-100%40% of base rate$0.020
Comparison AWS and Google Cloud Platform:.
Service CategoryServiceAWSGoogle Cloud Platform
ComputeIaaSAmazon Elastic Compute CloudGoogle Compute Engine
PaaSAWS Elastic BeanstalkGoogle App Engine
ContainersAmazon Elastic Compute Cloud Container ServiceGoogle Container Engine
NetworkLoad BalancerElastic Load BalancerGoogle Cloud Load Balancing
PeeringDirect ConnectGoogle Cloud Interconnect
DNSAmazon Route 53Google Cloud DNS
StorageObject StorageAmazon Simple Storage ServiceGoogle Cloud Storage
Block StorageAmazon Elastic Block StoreGoogle Compute Engine Persistent Disks
Cold StorageAmazon GlacierGoogle Cloud Storage Nearline
File StorageAmazon Elastic File SystemZFS / Avere
DatabaseRDBMSAmazon Relational Database ServiceGoogle Cloud SQL
NoSQL: Key-valueAmazon DynamoDBGoogle Cloud Bigtable
NoSQL: IndexedAmazon SimpleDBGoogle Cloud Datastore
Big Data & AnalyticsBatch Data ProcessingAmazon Elastic Map ReduceGoogle Cloud DataprocGoogle Cloud Dataflow
Stream Data ProcessingAmazon KinesisGoogle Cloud Dataflow
Stream Data IngestAmazon KinesisGoogle Cloud Pub/Sub
AnalyticsAmazon RedshiftGoogle BigQuery
Application ServicesMessagingAmazon Simple Notification ServiceGoogle Cloud Pub/Sub
Management ServicesMonitoringAmazon CloudWatchStackdriver Monitoring
DeploymentAWS CloudFormationGoogle Cloud Deployment Manager
Google support costs:

How to guides:
https://cloud.google.com/compute/docs/how-to

Cloud Deployment Manager:
https://cloud.google.com/deployment-manager/docs/

Install google-cloud-sdk:.
https://cloud.google.com/sdk/downloads
- Download
- Extract
./google-cloud-sdk/install.sh
- Initialise SDK ./google-cloud-sdk/bin/gcloud init



gcloud config configurations list            # List configurations
gcloud config list                           # List active config
gcloud config list --configuration conf1     # List config    
gcloud config init                           # Initialise config
gcloud config configurations activate conf1  # Activate config to conf1

gcloud auth list 

gcloud auth login

for p in `gcloud beta projects list | grep -v PROJECT_ID | awk ' { print $1 } ' `; do 

echo "Project: $p"
gcloud config set project $p
gcloud compute instances list
echo "==============================================================="
done

echo "ACCOUNT ID            ACCOUNT NAME                                OPEN PROJECT_ID                                         BILLING_ENABLED" 
for act in `gcloud alpha billing accounts list | awk ' { print $1 } ' | grep -v ID`; do
    a=`gcloud alpha billing accounts list | grep $act`
    echo $a | grep True > /dev/null
    x=$?
    if [ $x -eq 1 ]
    then
        echo $a
    else
        gcloud alpha billing accounts projects list $act 2>/dev/null | awk ' { printf("%-50s %s\n",$1,$3) } ' | sed "1,\$s/^/$a /" | grep -v PROJECT_ID
    fi
done

gcloud auth login "ACCOUNT" 

$ gcloud auth list 
gcloud config set account "ACCOUNT"
gcloud compute instances list --project projectname

gcloud config set project my-project
gcloud compute instances create box1 --image coreos --zone europe-west1-c
gcloud compute instances list
gcloud compute instances list --format=json | jq '.[] | "\(.id)#\(.name)#\(.machinetype)#\(.status)#\(.zone)#\(.creationTimestamp)#\(.networkInterfaces[0].network)#\(.networkInterfaces[0].networkIP)#\(.metadata.items)"' | tr ',' ';' | tr '#' ',' | sed -e '1,$s/\"//g' -e '1,$s/\\//g'
for p in `gcloud beta projects list | grep -v PROJECT_ID | awk ' { print $1 } ' `; do echo "Project: $p"; gcloud config set project $p; gcloud compute instances list; echo "==========================================================================================================================================================="; done > allinstances.out 2>&1

gcloud compute ssh <VM-name>

gcloud compute images list
gcloud compute zones list
gcloud compute firewall-rules list
gcloud compute firewall-rules delete default-allow-rdp
gcloud compute firewall-rules create allow-http --description --allow tcp:80
# See config
gcloud config list
# Change default zone
gcloud config set compute/zone us-central1-a
# Copy a file
gcloud compute copy-files some/file.txt cloud-machine-name:~/
# Forward a port with ssh
gcloud compute ssh client-machine-name -- -L 8080:localhost:8080
echo $DEVSHELL_PROJECT_ID

=============================================================

Command reference.
=============================================================
gcloud config set compute/region <region> 
echo $DEVSHELL_PROJECT_ID
mkdir ~/cpo200
echo CPO200_REGION=<region> >> ~/cpo200/config
gcloud compute zones list
echo CPO200_ZONE=<zone> >> ~/cpo200/config
source ~/cpo200/config
echo $CPO200_REGION
gcloud compute instances create guestbook-test --zone $CPO200_ZONE
gcloud compute instances create build-test --zone $CPO200_ZONE --project <build-project-id>
gcloud config list
gsutil ls -p <build-project-id>
gsutil ls -p <guestbook-project-id>
gcloud compute instances delete guestbook-test --zone $CPO200_ZONE
gcloud compute instances delete build-test --zone $CPO200_ZONE --project <build-project-id>
cd cpo200
gcloud source repos clone guestbook-container
cd guestbook-container
git pull https://github.com/GoogleCloudPlatformTraining/cpo200-guestbook-container
git push origin master

source ~/cpo200/config
gcloud compute networks list
gcloud compute networks subnets list
gcloud compute firewall-rules list
gcloud compute routes list
gcloud compute networks create jenkins-net --mode custom
gcloud compute networks describe jenkins-net
gcloud compute networks subnets create build-subnet --network jenkins-net --region $CPO200_REGION --range 192.168.5.0/24
gcloud compute firewall-rules create jenkins-net-allow-ssh --allow tcp:22 --network jenkins-net --target-tags ssh --source-ranges 0.0.0.0/0
gcloud compute firewall-rules create jenkins-net-allow-internal --allow tcp:1-65535,udp:1-65535,icmp --network jenkins-net --source-ranges 192.168.5.0/24
gcloud compute firewall-rules create jenkins-net-allow-http --allow tcp:80 --network jenkins-net --source-ranges 0.0.0.0/0 --target-tags http
gcloud compute instances create test-01 --subnet build-subnet --zone $CPO200_ZONE --tags ssh,http
gcloud compute instances create test-02 --subnet build-subnet --zone $CPO200_ZONE
ping -c 3 <test-02-external-ip-address>
ping -c 3 test-02
sudo python -m SimpleHTTPServer 80
gcloud compute instances delete test-01 test-02 --zone $CPO200_ZONE

source ~/cpo200/config
gcloud compute images list --regexp .*debian.*
gcloud compute instances create java-foundation --subnet build-subnet --zone $CPO200_ZONE --tags ssh --image debian-8-jessie-v20160629 --image-project debian-cloud --machine-type g1-small
sudo apt-get -qq update
java -version
sudo apt-get install -y -qq openjdk-7-jre
java -version
sudo apt-get install -y -qq git
gcloud compute instances stop java-foundation --zone $CPO200_ZONE
gcloud compute instances describe java-foundation --zone $CPO200_ZONE --format yaml | grep status
gcloud compute instances delete java-foundation --keep-disks boot --zone $CPO200_ZONE
gcloud compute images create debian-openjdk-java7-jre --source-disk java-foundation --source-disk-zone $CPO200_ZONE
gcloud compute images describe debian-openjdk-java7-jre --format yaml
gcloud compute instances create java-foundation-test --subnet build-subnet --zone $CPO200_ZONE --tags ssh --image debian-openjdk-java7-jre
java -version
gcloud compute disks list --zone $CPO200_ZONE
gcloud compute instances delete java-foundation-test --zone $CPO200_ZONE
gcloud compute disks list --zone $CPO200_ZONE
gcloud compute disks delete java-foundation --zone $CPO200_ZONE


REST APIs:
Get authentication token:
curl "http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token" -H "Metadata-Flavor: Google"
Use cURL to for REST APIs with token:
curl -X GET -H "Authorization: Bearer TOKEN" -H "Content-Type: application/json" https://www.googleapis.com/compute/v1/projects/dept-ia-dev/zones/asia-east1-b/instances
curl --silent -X GET -H "Authorization: Bearer TOKEN" -H "Content-Type: application/json" https://cloudbilling.googleapis.com/v1/billingAccounts



echo $DEVSHELL_PROJECT_ID
Google Cloud Networking:

IAM and Organisation Node:

Update 23/3/2016: Looks like arriving in Australia 2017 - Opening 12 new data centres:
http://www.techweekeurope.co.uk/cloud/cloud-management/google-cloud-expansion-12-new-data-centres-188443


Google’s Compute Zones may be isolated, but they’re surprisingly close together
One of the key architectural decisions of AWS is that you deploy across multiple zones in a region, but for complete redundancy, it’s a good idea to deploy across multiple regions. There have been instances where entire AWS regions have suffered outages, even though each zone is supposed to be isolated. Amazon acknowledges as much: “Although rare, failures can occur that affect the availability of instances that are in the same location.”
Compare that to Google: “Each region is completely isolated from other regions, and each zone is completely independent of other zones. If a zone or a region suffers a failure, other zones and regions won’t be affected.”
London to europe-west1-aLondon to europe-west1-beurope-west1-a to europe-west1-b
20ms18ms0.032ms
The ping RTTs reveal that even though the ping times between west1-a and west1-b are slightly different, the internal latency is so low that it must be within the same geographical region. Light can only travel 9.5km in this short time, and given this is the round trip, the actual distance is at most half that. But if Google’s availability statement is correct, the west1-a and west1-b zones cannot be within the same physical facility. So Google must have separate data centers within Ireland, no more than a few kilometers apart.

No comments:

Post a Comment