Show Menu
Cheatography

GCP gcloud commands Cheat Sheet (DRAFT) by

List of GCP Commands

This is a draft cheat sheet. It is a work in progress and is not finished yet.

GCP Basic

Check version & settings
gcloud version, gcloud info, gcloud components list
Init profile
gcloud init
List all zones
gcloud compute zones list
 

Buckets

List all buckets and files
gsutil ls, gsutil ls -lh gs://<­buc­ket­-na­me>
Download file
gsutil cp gs://<­buc­ket­-na­me>­/<d­ir-­pat­h>/­pac­kag­e-1.1.tgz .
Upload file
gsutil cp <fi­len­ame> gs://<­buc­ket­-na­me>­/<d­ire­cto­ry>/
Cat file
gsutil cat gs://<­buc­ket­-na­me>­/<f­ile­pat­h>/
Delete file
gsutil rm gs://<­buc­ket­-na­me>­/<f­ile­pat­h>
Move file
gsutil mv <sr­c-f­ile­pat­h> gs://<­buc­ket­-na­me>­/<d­ire­cto­ry>­/<d­est­-fi­lep­ath>
Copy Folder
gsutil cp -r ./conf gs://<­buc­ket­-na­me>/
Show disk usage
gsutil du -h gs://<­buc­ket­-na­me/­<di­rec­tor­y>
Create bucket
gsutil mb gs://<­buc­ket­-na­me>
Commands to interact with GCP storage bcukets and objects

Bucket Security

Make all files readable
gsutil -m acl set -R -a public­-read gs://<­buc­ket­-na­me>/
Config auth
gsutil config -a
Grant bucket access
gsutil iam ch user:t­est­@gm­ail.co­m:o­bje­ctC­rea­tor­,ob­jec­tViewer gs://<­buc­ket­-na­me>/
Remove bucket access
gsutil iam ch -d user:t­est­@gm­ail.co­m:o­bje­ctC­rea­tor­,ob­jec­tViewer gs://<­buc­ket­-na­me>/
 

GCP Project

List projects
gcloud config list project
Show project info
gcloud compute projec­t-info describe
Switch project
gcloud config set project <pr­oje­ct-­id>
Commands for intera­cting with GCP projects

GKE

Display list of creden­tailed accounts
gcloud auth list
Set active account
gcloud config set account <AC­COU­NT>
Set kubectl context
gcloud container clusters get-cr­ede­ntials <cl­ust­er-­nam­e>
Change region
gcloud config set comput­e/r­egion us-west
Change zone
gcloud config set comput­e/zone us-west1-b
List all container clusters
gcloud container clusters list
Commands for intera­cting with Google Kubernetes Engine