Difference between revisions of "Google Cloud Platform"

From Christoph's Personal Wiki
Jump to: navigation, search
(Command Line Interface (CLI))
(Command Line Interface (CLI))
Line 242: Line 242:
 
* To update your SDK installation to the latest version [228.0.0], run:
 
* To update your SDK installation to the latest version [228.0.0], run:
 
  $ gcloud components update
 
  $ gcloud components update
 +
 +
* Initialize gcloud:
 +
$ gcloud init
 +
 +
* Get current gcloud configuration:
 +
$ gcloud config list
 +
<pre>
 +
[compute]
 +
region = us-west1
 +
zone = us-west1-a
 +
[core]
 +
account = someone@somewhere.com
 +
disable_usage_reporting = True
 +
project = my-project-223521
 +
 +
Your active configuration is: [default]
 +
</pre>
  
 
; Create a GKE cluster
 
; Create a GKE cluster
  
 
* Create the Kubernetes cluster:
 
* Create the Kubernetes cluster:
  $ gcloud beta container --project "gcp-k8s-227521" clusters create "xtof-gcp-k8s" \
+
  $ gcloud beta container --project "gcp-k8s-223521" clusters create "xtof-gcp-k8s" \
 
     --zone "us-west1-a" \
 
     --zone "us-west1-a" \
 
     --username "admin" \
 
     --username "admin" \
Line 255: Line 272:
 
     --disk-size "100" \
 
     --disk-size "100" \
 
     --scopes \
 
     --scopes \
       "https://www.googleapis.com/auth/devstorage.read_only",
+
       "<nowiki>https://www.googleapis.com/auth/devstorage.read_only</nowiki>",
       "https://www.googleapis.com/auth/logging.write",
+
       "<nowiki>https://www.googleapis.com/auth/logging.write</nowiki>",
       "https://www.googleapis.com/auth/monitoring",
+
       "<nowiki>https://www.googleapis.com/auth/monitoring</nowiki>",
       "https://www.googleapis.com/auth/servicecontrol",
+
       "<nowiki>https://www.googleapis.com/auth/servicecontrol</nowiki>",
       "https://www.googleapis.com/auth/service.management.readonly",
+
       "<nowiki>https://www.googleapis.com/auth/service.management.readonly</nowiki>",
       "https://www.googleapis.com/auth/trace.append" \
+
       "<nowiki>https://www.googleapis.com/auth/trace.append</nowiki>" \
 
     --num-nodes "3" \
 
     --num-nodes "3" \
 
     --enable-stackdriver-kubernetes \
 
     --enable-stackdriver-kubernetes \
 
     --no-enable-ip-alias \
 
     --no-enable-ip-alias \
     --network "projects/gcp-k8s-227521/global/networks/default" \
+
     --network "projects/gcp-k8s-223521/global/networks/default" \
     --subnetwork "projects/gcp-k8s-227521/regions/us-west1/subnetworks/default" \
+
     --subnetwork "projects/gcp-k8s-223521/regions/us-west1/subnetworks/default" \
 
     --addons HorizontalPodAutoscaling,HttpLoadBalancing,KubernetesDashboard,Istio \
 
     --addons HorizontalPodAutoscaling,HttpLoadBalancing,KubernetesDashboard,Istio \
 
     --istio-config auth=NONE \
 
     --istio-config auth=NONE \
Line 272: Line 289:
  
 
* Get the Kubernetes credentials:
 
* Get the Kubernetes credentials:
  $ gcloud container clusters get-credentials xtof-gcp-k8s --zone us-west1-a --project gcp-k8s-227521
+
  $ gcloud container clusters get-credentials xtof-gcp-k8s --zone us-west1-a --project gcp-k8s-223521
  
 
* Delete the cluster:
 
* Delete the cluster:
  $ gcloud container clusters delete --project "gcp-k8s-227521" "xtof-gcp-k8s" --zone "us-west1-a"
+
  $ gcloud container clusters delete --project "gcp-k8s-223521" "xtof-gcp-k8s" --zone "us-west1-a"
  
 
==See also==
 
==See also==

Revision as of 22:52, 3 January 2019

Google Cloud Platform (GCP) is a cloud computing service by Google that offers hosting on the same supporting infrastructure that Google uses internally for end-user products like Gmail, Google Search, Maps, and YouTube.

Elements

  • Google Compute Engine – IaaS service providing virtual machines similar to Amazon EC2.
  • Google App Engine – PaaS service for directly hosting applications similar to AWS Elastic Beanstalk.
  • BigTable – IaaS service providing map reduce services. Similar to Hadoop.
  • BigQuery – IaaS service providing Columnar database. Similar to Amazon Redshift.
  • Google Cloud Functions – Currently in alpha testing FaaS service allowing functions to be triggered by events without developer resource management similar to Amazon Lambda or IBM OpenWhisk.

GCP vs. AWS

Note: All of the following are as of February 2017.

  • Compute
    • Compute Engine vs. EC2
    • App Engine vs. Elastic Beanstalk
    • Container Engine vs. EC2
    • Container Registry vs. ECR
    • Cloud Functions vs. Lambda
  • Identity & Security
    • Cloud IAM vs. IAM
    • Cloud Resource Manager vs. n/a
    • Cloud Security Scanner vs. Inspector
    • Cloud Platform Security vs. n/a
  • Networking
    • Cloud Virtual Network vs. VPC
    • Cloud Load Balancing vs. ELB
    • Cloud CDN vs. CloudFront
    • Cloud Interconnect vs. Direct Connect
    • Cloud DNS vs. Route53
  • Storage and Databases
    • Cloud Storage vs. S3
    • Cloud Bigtable vs. DynamoDB
    • Cloud Datastore vs. SimpleDB
    • Cloud SQL vs. RDS
    • Persistent Disk vs. EBS
  • Big Data
    • BigQuery vs. Redshift
    • Cloud Dataflow vs. EMR
    • Cloud Dataproc vs. EMR
    • Cloud Datalab vs. n/a
    • Cloud Pub/Sub vs. Kinesis
    • Genomics vs. n/a
  • Machine Learning
    • Cloud Machine Learning vs. Machine Learning
    • Vision API vs. Rekognition
    • Speech API vs. Polly
    • Natural Language API vs. Lex
    • Translation API vs. n/a
    • Jobs API vs. n/a
  • Compute Services (GCP vs. AWS):
    • Infrastructure as a Service (IaaS): Compute Engine vs. EC2
    • Platform as a Service (PaaS): App Engine vs. Elastic Beanstalk
    • Containers as a Service: Container Engine vs. EC2
Compute IaaS comparison
Feature Amazon EC2 Compute Engine
Virtual machines Instances Instances
Machine images Amazon Machine Image (AMI) Image
Temporary virtual machines Spot instances Preemptible VMs
Firewall Security groups Compute Engine firewall rules
Automatic instance scaling Auto Scaling Compute Engine autoscaler
Local attached disk Ephemeral disk Local SSD
VM import Supported formats: RAW, OVA, VMDK, VHD Supported formats: AMI, RAW, VirtualBox
Deployment locality Zonal Zonal


Networking services comparison
Networking Load Balancing CDN On-premises connection DNS
AWS VPC ELB CloudFront Direct Connect Route53
GCP Cloud VirtualNetwork1 Cloud LoadBalancing2 Cloud CDN Cloud InterConnect Cloud DNS

1GCP allows for 802.1q tagging (aka VLAN taggin). AWS does not.
2GCP allows for cross-region load balancing. AWS does not.


Storage services comparison
Object Block Cold File
AWS S3 EBS1 Glacier EFS
GCP Cloud Storage Compute Engine Persistent Disks2 Cloud Storage Nearline ZFS/Avere


1An EBS volume can be attached to only one EC2 instance at a time. Can attach up to 40 disk volumes to a Linux instance. Available in only one region by default.
2GCP Persistent Disks in read-only mode can be attached to multiple instances simultaneously. Can attach up to 128 disk volumes. Snapshots are global and can be used in any region without additional operations or charges.


Database services comparison
RDMS NoSQL (key-value) NoSQL (indexed)
AWS RDS DynamoDB DynamoDB
GCP Cloud SQL1 Cloud Bigtable2 Cloud Datastore


1MySQL only.
2100 MB maximum item size. Does not support secondary indexes.


Big Data services comparison
Streaming data ingestion Streaming data processing Batch data processing Analytics
AWS Kinesis Kinesis EMR Redshift
GCP Cloud Pub/Sub Cloud Dataflow Cloud Dataflow / Cloud Dataproc BigQuery


Cloud Pub/Sub 
GCPs offering for data streaming and message queue. It allows for secure communication between applications and can also serve as a de-coupling method (a good way to scale).
Dataflow 
GCPs managed service offering for batch and streaming data processing. Apache Beam under-the-hood.
Dataproc 
GCPs offering for data processing using Apache Hadoop and Apache Spark. It is a massively parallel data processing and transformation engine.
Supported services: MapReduce, Apache Hive, Apache Pig, Apache Spark, Spark SQL, PySpark, and support for parallel jobs with YARN.
BigQuery 
GCPs offering for a fully managed, massive data warehousing and analytics engine, allowing for data analytics using SQL.
Application services comparison
Messaging
AWS SNS
GCP Cloud Pub/Sub


Cloud Pub/Sub (publisher/subscriber)
Management services comparison
Monitoring Deployment
AWS CloudWatch CloudFormation
GCP Stackdriver Deployment Manager


Command Line Interface (CLI)

The Google Cloud SDK is a set of tools that you can use to manage resources and applications hosted on the Google Cloud Platform (GCP). These include the gcloud, gsutil, and bq command line tools. The gcloud command-line tool is downloaded along with the Cloud SDK.

┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                  Components                                                 │
├───────────────┬──────────────────────────────────────────────────────┬──────────────────────────┬───────────┤
│     Status    │                         Name                         │            ID            │    Size   │
├───────────────┼──────────────────────────────────────────────────────┼──────────────────────────┼───────────┤
│ Not Installed │ App Engine Go Extensions                             │ app-engine-go            │  56.6 MiB │
│ Not Installed │ Cloud Bigtable Command Line Tool                     │ cbt                      │   6.4 MiB │
│ Not Installed │ Cloud Bigtable Emulator                              │ bigtable                 │   5.6 MiB │
│ Not Installed │ Cloud Datalab Command Line Tool                      │ datalab                  │   < 1 MiB │
│ Not Installed │ Cloud Datastore Emulator                             │ cloud-datastore-emulator │  17.7 MiB │
│ Not Installed │ Cloud Datastore Emulator (Legacy)                    │ gcd-emulator             │  38.1 MiB │
│ Not Installed │ Cloud Firestore Emulator                             │ cloud-firestore-emulator │  27.5 MiB │
│ Not Installed │ Cloud Pub/Sub Emulator                               │ pubsub-emulator          │  33.4 MiB │
│ Not Installed │ Cloud SQL Proxy                                      │ cloud_sql_proxy          │   3.8 MiB │
│ Not Installed │ Emulator Reverse Proxy                               │ emulator-reverse-proxy   │  14.5 MiB │
│ Not Installed │ Google Cloud Build Local Builder                     │ cloud-build-local        │   6.0 MiB │
│ Not Installed │ Google Container Registry's Docker credential helper │ docker-credential-gcr    │   1.8 MiB │
│ Not Installed │ gcloud Alpha Commands                                │ alpha                    │   < 1 MiB │
│ Not Installed │ gcloud Beta Commands                                 │ beta                     │   < 1 MiB │
│ Not Installed │ gcloud app Java Extensions                           │ app-engine-java          │ 107.5 MiB │
│ Not Installed │ gcloud app PHP Extensions                            │ app-engine-php           │           │
│ Not Installed │ gcloud app Python Extensions                         │ app-engine-python        │   6.2 MiB │
│ Not Installed │ gcloud app Python Extensions (Extra Libraries)       │ app-engine-python-extras │  28.5 MiB │
│ Not Installed │ kubectl                                              │ kubectl                  │   < 1 MiB │
│ Installed     │ BigQuery Command Line Tool                           │ bq                       │   < 1 MiB │
│ Installed     │ Cloud SDK Core Libraries                             │ core                     │   9.1 MiB │
│ Installed     │ Cloud Storage Command Line Tool                      │ gsutil                   │   3.5 MiB │
└───────────────┴──────────────────────────────────────────────────────┴──────────────────────────┴───────────┘
  • To install or remove components at your current SDK version [228.0.0], run:
$ gcloud components install COMPONENT_ID
$ gcloud components remove COMPONENT_ID
  • To update your SDK installation to the latest version [228.0.0], run:
$ gcloud components update
  • Initialize gcloud:
$ gcloud init
  • Get current gcloud configuration:
$ gcloud config list
[compute]
region = us-west1
zone = us-west1-a
[core]
account = someone@somewhere.com
disable_usage_reporting = True
project = my-project-223521

Your active configuration is: [default]
Create a GKE cluster
  • Create the Kubernetes cluster:
$ gcloud beta container --project "gcp-k8s-223521" clusters create "xtof-gcp-k8s" \
   --zone "us-west1-a" \
   --username "admin" \
   --cluster-version "1.11.5-gke.5" \
   --machine-type "n1-standard-1" \
   --image-type "COS" \
   --disk-type "pd-standard" \
   --disk-size "100" \
   --scopes \
     "https://www.googleapis.com/auth/devstorage.read_only",
     "https://www.googleapis.com/auth/logging.write",
     "https://www.googleapis.com/auth/monitoring",
     "https://www.googleapis.com/auth/servicecontrol",
     "https://www.googleapis.com/auth/service.management.readonly",
     "https://www.googleapis.com/auth/trace.append" \
   --num-nodes "3" \
   --enable-stackdriver-kubernetes \
   --no-enable-ip-alias \
   --network "projects/gcp-k8s-223521/global/networks/default" \
   --subnetwork "projects/gcp-k8s-223521/regions/us-west1/subnetworks/default" \
   --addons HorizontalPodAutoscaling,HttpLoadBalancing,KubernetesDashboard,Istio \
   --istio-config auth=NONE \
   --enable-autoupgrade \
   --enable-autorepair
  • Get the Kubernetes credentials:
$ gcloud container clusters get-credentials xtof-gcp-k8s --zone us-west1-a --project gcp-k8s-223521
  • Delete the cluster:
$ gcloud container clusters delete --project "gcp-k8s-223521" "xtof-gcp-k8s" --zone "us-west1-a"

See also

External links