IAM
-
Member-
Google account (for end users)
-
service account(for apps and VMs)-
Create a
Service Accountgcloud iam service-accounts create <SERVICE_ACCOUNT_NAME> --display-name '<DISPLAY_NAME>' -
Service accountsare equivalent toAWS IAM Roles.
-
-
Format
user|group|serviceAccount:<EMAIL_ADDRESS>domain:<DOMAIN>
-
-
-
Basic roles (opens in a new tab)
- Owner
- Editor
- Viewer
-
Predefined roles (opens in a new tab)
-
Listing
predefined rolesgcloud iam roles list
-
-
Custom roles (opens in a new tab)
-
Custom rolesenable you to enforce theprinciple of least privilege, ensuring that the user and service accounts in yourorganizationhave only the permissions essential to performing their intended functions. -
Custom rolescan only be used to grant permissions in policies for the sameprojectororganizationthat owns therolesorresourcesunder them. You cannot grantcustom rolesfrom oneprojectororganizationon aresourceowned by a differentprojectororganization. -
To create a
custom role, a caller must have theiam.roles.createpermission. By default, theownerof aprojector anorganizationhas thispermissionand can create and managecustom roles. -
Listing the
custom roleson project levelgcloud iam roles list --project <PROJECT_ID> -
Updating a
custom roleusing aYAMLfile- Output
rolemetadata inYAMLformat bygcloud iam roles describe <ROLE_NAME> - Edit the outputted
YAMLfile and change the content as desired - Update the role by
gcloud iam roles update <ROLE_ID> --project <PROJECT_ID> --file <YAML-file>
- Output
-
Disabling a
custom roleWhen a
roleis disabled, any policy bindings related to theroleareinactivated, meaning that thepermissionsin the role will not be granted, even if you grant theroleto auser.gcloud iam roles update viewer --project <PROJECT_ID> --stage DISABLED
-
-
If a
roleis beingphased out, change itsrole.stageproperty toDEPRECATED, and set thedeprecation_messageto let users know what alternative roles should be used or where to get more information.
-
-
-
Viewing the available
permissionsfor aresourcegcloud iam list-testable-permissions //cloudresourcemanager.googleapis.com/projects/<PROJECT_ID> -
Getting the
rolemetadata, includingpermissionsparticularlygcloud iam roles describe <ROLE_NAME> -
Viewing the grantable
rolesonresourcesgcloud iam list-grantable-roles //cloudresourcemanager.googleapis.com/projects/<PROJECT_ID>
-
-
Permissions(opens in a new tab)- Permission form:
<service>.<resource>.<verb> Permissionsusually, but not always, correspond1:1withRESTmethods.
- Permission form:
-
Policy Binding-
A
policy bindingis useful only if you add it to aresource. -
Add a policy binding to a resource
gcloud <RESOURCE_TYPE> add-iam-policy-binding <RESOURCE_NAME> --member=<MEMBER> --role=roles/<ROLE_NAME>
-
Config
-
CLI
-
get the current
project IDgcloud config get-value project
-
change the current
projectgcloud config set project <project-ID>
-
get the list of all
projectsgcloud projects listgcloud config list project
-
list available Regions and Zones
gcloud compute regions listgcloud compute zones list
-
list all properties and settings
gcloud config list --all
-
Storage
| Product | Simple Description | Ideal for | Not Ideal for | R/W Latency | Typical Size | Storage Type |
|---|---|---|---|---|---|---|
| Cloud Storage | Binary/object store | Large or rarely accessed unstructured data | Structured data, building fast apps | Medium (100s of ms) | Any | Object |
| Datastore | Scalable store for structured serve | GAE apps, structured pure-serve use cases | Relational or analytic data | Medium (10s of ms) | < 200 TB | Document |
| Bigtable | High-volume, low-latency database | "Flat" heavy read/write, or analytical data | High structure or transactional data | Low (ms) | 2 TB - 10 PB | Key-Value |
| Cloud SQL | Well-understood VM-based RDBMS | Web frameworks, exisitng applications | Scaling, analytics, heavy writes | Low (ms) | < 10 TB | Relational |
| Spanner | Relational DB service | Low-latency transactional systems | Analytic data | Low (ms) | Any | Relational |
| BigQuery | Auto-scaling analytic data warehouse | Interactive analysis of static datasets | Building fast apps | High(s) | Any | Columnar |
App Engine
-
ServicesServicesonApp Engineprovide a way to split your application into smaller, more manageable pieces. Similar tomicroservices,App Engineservicesact as independent components of computing. -
Delete
applicationThere's no direct way to delete the
applicationonApp Engine. There are 2 alternatives:- Disable the
applicationinApp Enginesettings - Delete the whole
project
- Disable the
-
Java
-
Java 11 runtime (opens in a new tab)
- Doesn't include any web framework, therefore not limited to
Java Servlet. - Uses
JARinstead ofWAR - Doesn't support
App Engine Java SDK
- Doesn't include any web framework, therefore not limited to
-
Load Balancing
Cloud Storage
-
Copy all contents under a folder including all subfolders recursively
gsutil cp -r <SOURCE_URL> <TARGET_URL>
Cloud Build
-
Create a
Dockerrepository inArtifact Registrygcloud artifacts repositories create <repo-name> --repository-format=docker --location=us-central1 --description="<description>" -
List all repos created in the current project
gcloud artifacts repositories list -
Build and push an image to the repo
gcloud builds submit --tag gcr.io/$GOOGLE_CLOUD_PROJECT/lab-report-service -
Configuration (opens in a new tab)
cloudbuild.yaml
-
Cloud builders (opens in a new tab)
Cloud buildersarecontainer imageswith common languages and tools installed in them.
-
CLI
-
deploy
--sourcemust be specified if different from last time
-
Cloud Function
-
Traits
- Not for serving highly concurrent workloads
- No support for
traffic splittingorrevision rollback - One
HTTPendpoint only - One container exclusively to handle a single request
-
Types
- HTTP functions
- Event-driven functions
- Background functions
- CloudEvent functions
-
Runtimes
-
Nodejs
- Entry point file
index.jsfunction.js
- Entry point file
-
Python
- Entry point file
main.py
- Entry point file
-
-
Use cases
Use Case Description Data Processing / ETLListen and respond to Cloud Storageevents such as when a file is created, changed, or removed. Process images, perform video transcoding, validate and transform data, and invoke any service on the Internet from yourCloud Function.Webhooks Via a simple HTTPtrigger, respond to events originating from 3rd party systems likeGitHub,Slack,Stripe, or from anywhere that can sendHTTPrequests.Lightweight APIsCompose applications from lightweight, loosely coupled bits of logic that are quick to build and that scale instantly. Your functions can be event-driven or invoked directly over HTTP/S.Mobile Backend Use Google's mobile platform for app developers,Firebase, and write your mobile backend inCloud Functions. Listen and respond to events fromFirebase Analytics,Realtime Database,Authentication, andStorage.IoTImagine tens or hundreds of thousands of devices streaming data into Cloud Pub/Sub, thereby launchingCloud Functionsto process, transform and store data.Cloud Functionslets you do in a way that's completely serverless. -
CLI
-
Check the function logs
gcloud functions logs read <function-name>
-
Cloud Run
-
The container can be invoked on an
HTTPSendpoint. -
Automatic scaling
-
Cloud Runwill throttle theCPUof containers that are not handling requests. -
Cloud Runtreats each deployment as a newRevisionwhich will first be brought online, then have traffic redirected to it. -
By default the latest
revisionwill be assigned100%of the inbound traffic for a service. -
Deployment platform
- Managed
Cloud Run Cloud RunonGKE
- Managed
-
List running services
gcloud run services list -
Obtain details about a given service in
YAMLformatgcloud run services describe <SERVICE-NAME> --format=yaml -
Obtain details about a given service with a
JSONpathgcloud run services describe <SERVICE-NAME> --format="value(status.address.url)" -
Deploy a container (opens in a new tab)
gcloud run deploy <CONTAINER_NAME> --image=gcr.io/<IMAGE>:<TAG>
GKE
-
List clusters
gcloud container clusters list -
Generate
kubeconfigfor a specifiedclustergcloud container clusters get-credentials <CLUSTER_NAME> --zone <ZONE> -
Cluster administration
-
Cluster resizing (opens in a new tab)
-
Increasing
- Existing Pods are not moved onto the new instances.
-
Decreasing
- The Pods that are scheduled on the instances being removed are killed.
- Pods managed by a replication controller are rescheduled by the controller onto the remaining instances
- Pods not managed by a replication controller are not restarted
- Instances are picked for removal at random.
-
-
Container Registry
-
HOSTNAMEis 1 of 4 locations:gcr.io,us.gcr.io,eu.gcr.io, orasia.gcr.io -
These locations correspond to the
multi-regionsforCloud Storagestoragebuckets. When you push animageto aregistrywith a newhostname,Container Registrycreates a storagebucketin the specifiedmulti-region. Thisbucketis the underlying storage for theregistry. Within aproject, allregistrieswith the samehostnameshare one storagebucket. -
Tag the
local imagewith theregistry name, so it can be pushed to theregistrydocker tag <SOURCE_IMAGE> <HOSTNAME>/<PROJECT-ID>/<IMAGE> -
Push the
tagged imagetoContainer Registrydocker push <HOSTNAME>/<PROJECT-ID>/<IMAGE>:<TAG> -
View the
imageyou pushedgcloud container images list-tags <HOSTNAME>/<PROJECT-ID>/<IMAGE>
Cloud Shell
-
Cloud Shellprovisions5 GBof free persistent disk storage mounted as your$HOMEdirectory on theVMinstance. This storage is on a per-user basis and is available acrossprojects. -
If you do not access
Cloud Shellregularly, the$HOMEdirectory persistent storage may be recycled. You will receive an email notification before this occurs. Starting aCloud Shellsession will prevent its removal. -
Accessing
Cloud Shellfrom the command line (opens in a new tab)-
Establishing an interactive
SSHsession withCloud Shellfrom local machinegcloud cloud-shell ssh -
Copy a file from
Cloud Shellto local machine (working directory of the terminal):gcloud cloud-shell scp cloudshell:~/data.txt localhost:data.txt
-
SDK
-
SDK components (opens in a new tab)
-
List SDK components
gcloud components list
-
Resources
- Google Cloud Platform blog (opens in a new tab)
- GCP - customers and case studies (opens in a new tab)
- GCP - CLI Reference (opens in a new tab)
- gcloud supplementary help (opens in a new tab)
Big Data
- GCP big data product list (opens in a new tab)
- BigQuery standard SQL guide (opens in a new tab)
- Migrating On-Premises Hadoop Infrastructure to Google Cloud (opens in a new tab)
- Cloud Blog - Databases (opens in a new tab)
- Cloud Blog - Dataproc (opens in a new tab)
- Get started with Google-provided templates (opens in a new tab)
- Connecting BigQuery and Google Sheets to help with hefty data analysis (opens in a new tab)
- Scheduling queries (opens in a new tab)
- Creating a k-means clustering model (opens in a new tab)