GCP gcloud commands

  1. gcloud topic filters — it is a helper man page to know about how to use filters
  2. gcloud services list — available
  1. gcloud projects list → list all the project you have including project_Id, Name, project_number
  2. gcloud config list → list your configuration
  3. gcloud config set project medium-blog-demo → set the project to medium-blog-demo
  4. gcloud config get-value project → to get the project value from your configuaration
  1. gcloud init — interactive workflow to set common properties in a config
  2. gcloud config configurations list — list all configurations
  3. gcloud config configurations create newconfig → this is very similar to mkdir newdconfig command to create a container for new configurations.
  4. gcloud config configurations activate newconfig → this is very similar to cd newconfig to enter into/switch to the newconfig
  5. gcloud config list -> similar to ls to list all properties in a configuration
  6. gcloud — configuration=newconfig config list → to ls ~/newconfig
  7. gcloud config configurations describe newconfig → similar to ls ~/newconfig
  8. gcloud config set [account/project/region/zone] [webber-demo/webber-proj-demo, asiaeast-1, xx]
  1. gcloud compute instances list
  2. gcloud — project medium-blog-demo compute list
  3. gcloud compute instances create medium-demo-vm
  4. gcloud compute machine-types list → the output is quite long! You can find instance type information including NAME, ZONE, CPUS, MEMORY_GB, DEPRECATED
  5. gcloud compute instances create — machine-type=f1-micro medium-blog-demo-vm → create a vm with specified machine type f1-micro.
  6. gcloud compute ssh medium-blog-demo → this command will also execute ssh keygen to generate a key shown in below figure
# Check out the metadata
curl metadata.google.internal/computeMetadata/v1/
curl -H "Metadata-Flavor: Google" metadata.google.internal/computeMetadata/v1/
curl -H "Metadata-Flavor: Google" metadata.google.internal/computeMetadata/v1/project/
curl -H "Metadata-Flavor: Google" metadata.google.internal/computeMetadata/v1/project/project-id
curl -H "Metadata-Flavor: Google" metadata.google.internal/computeMetadata/v1/project/attributes/
curl -H "Metadata-Flavor: Google" metadata.google.internal/computeMetadata/v1/project/attributes/ssh-keys

# Look at some instance metadata
curl -H "Metadata-Flavor: Google" metadata.google.internal/computeMetadata/v1/instance/
curl -H "Metadata-Flavor: Google" metadata.google.internal/computeMetadata/v1/instance/name
curl -H "Metadata-Flavor: Google" metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/
curl -H "Metadata-Flavor: Google" metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/email

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Visualizing protein networks in Python

Valid 1/23 Today Only! Free shipping no minimum- With Code: monday

10 Basic Facts about Kubernetes that You Didn’t Know

Getting Started with AWS IPAM

Kubernetes Tutorial — A Comprehensive Guide The Orchestration Giant

How we created a cloud continuous integration service

Google Dialogflow CX Tips&Tricks #1

GCP- GCE instance group and autoscaling

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Webber H. Lin

Webber H. Lin

More from Medium

Getting started with Google Cloud Endpoints OpenAPI

Connecting Rapid Miner Studio to GCP Dataproc on GCE

Help! How do I undelete my deleted Google Cloud SQL instance?

Dash on GCP — Part 1