GCP Command line cheat sheet
GCP Command line cheat sheet
https://medium.com/@tams67680/google-cloud-platform-command-line-cheat-sheet-ae3fe5fde436
Here are the list of commands which i would like to share with you all as a
reference guide for CLI activities and for GCP Associate Cloud Engineer
Certification Exam.
I tried my best to list down the most frequently used commands while
interacting with GCP Services using CloudShell, In this post i concentrated
mostly on specific set of services like
4. Data Life Cycle Services like Cloud DataProc and Cloud Pub/Sub
1
2.To list all credentialed accounts and identify the current active account
gcloud auth list
2
10.To list down the service accounts
gcloud iam service-accounts list
3
19.To list down the projects
gcloud projects list
4
28.To bind an IAM policy to a specific user
gcloud projects add-iam-policy-binding project_id — member
user:[email protected] — role roles/editor
Billing
1.To list billing accounts
gcloud beta billing
Compute Service
1.To create a disk
gcloud compute disks create
5
5.To create a network in custom mode
gcloud compute networks create ace-exam-vpc1 — subnet-mode=custom
6
4.Listing down the Kubernetes pods
kubectl get pods
7.Creating a cluster
gcloud container clusters create example-cluster
9.Auto-scaling
gcloud container clusters update standard-cluster-1 — enable-autoscaling
— min-nodes 1 — max-nodes 5 — zone us-central1-a — node -pool default-
pool
7
12. Auto scaling the deployments
kubectl autoscale deployment nginx-1 — max 10 — min 1 — cpu-percent 80
8
App engine
1.Deploying the application on to app engine
gcloud app deploy app.yml
Cloud Function
1.To deploy a function with all the specifications
gcloud functions deploy cloud_storage_function_quant \
— runtime python37 \
— trigger-resource gcp-ace-quant-test-bucket \
— trigger-event google.storage.object.finalize
Components
1.List down the components
gcloud components list
9
3.Install the components
gcloud components install <component-name>
CloudSQL
1.Create an SQL database
gcloud sql databases create
3.Create a backup
gcloud sql backups create — async — instance ace-exam-mysql
Cloud PubSub
1.Topic creation
gcloud pubsub topics create [TOPIC-NAME]
2.Subscribtion create
gcloud pubsub subscriptions create [SUBSCRIPTION-NAME] — topic
[TOPIC-NAME]
10
3.Publish a message to specific topic
gcloud pubsub topics publish topic1 — message “Quantiphi-AI/ML”
Dataproc
1.Creating a cluster
gcloud dataproc clusters create cluster-bc3d — zone us-west2-a
BigQuery
1.Listing down the jobs
bq ls -j -a project
Datastore
1.Creating indexes in Datastore
gcloud datastore create-indexes
11
CloudStorage
1.Lists all your buckets
gsutil ls
3.Bucket creation
gsutil mb gs://quanti-bucket
5.Files
copies the local filename into the bucket
gsutil cp <filename> gs://<bucket_name>/
12
9.Changing the storage class
gsutil rewrite -s [STORAGE_CLASS] gs://[PATH_TO_OBJECT]
11.Assigning roles
gsutil iam ch user : <user_email>:<role1,role2> gs://<BUCKET>
13.Enabling versioning
gsutil versioning set on gs://bucket
13
Inconvenience regretted for any typo and much appreciated for providing
feedback specific to the content of this document.
Sarath Tamminana
14