Skip to content

Instantly share code, notes, and snippets.

@gelopfalcon
Last active October 31, 2022 15:58
Show Gist options
  • Save gelopfalcon/4482a63083067305438e0cb7fb7aa567 to your computer and use it in GitHub Desktop.
Save gelopfalcon/4482a63083067305438e0cb7fb7aa567 to your computer and use it in GitHub Desktop.
Google Cloud Platform - GCP gcloud, gsutil, etc.

1.1 Personalization

Make the Cloud SDK your own; personalize your configuration with properties.

Name Summary
gcloud config set Define a property (like compute/zone) for the current configuration.
gcloud config get-value: Fetch value of a Cloud SDK property.
gcloud config list Display all the properties for the current configuration.
gcloud config configurations create Create a new named configuration.
gcloud config configurations list Display a list of all available configurations.
gcloud config configurations activate Switch to an existing named configuration.

1.2 GCP Basic

Name Summary
Check version & settings gcloud version, gcloud info, gcloud components list
Init profile gcloud init
List all zones gcloud compute zones list
Upgrade local SDK gcloud components update, gcloud components update --version 219.0.1

1.3 GCP Project

Name Summary
List projects gcloud project list
Configuration gcloud config list, gcloud config list project
Show project info gcloud compute project-info describe
Switch project gcloud config set project

1.4 GKE

Name Summary
Auth login gcloud auth login
Display a list of credentialed accounts gcloud auth list
Set the active account gcloud config set account <Account>
Set kubectl context gcloud container clusters get-credentials <cluster-name>
Change zone gcloud config set compute/zone us-west1-b
Change region gcloud config set compute/region us-west
List all container clusters gcloud container clusters list

1.5 VM

Name Summary
List all instances gcloud compute instances list
Show instance info gcloud compute instances describe "instance-name" –project "project-name" –zone "zone"
Stop an instance gcloud compute instances stop instance-1
Start an instance gcloud compute instances start instance-1
Create an instance gcloud compute instances create vm1 --image image-1 --tags test --zone "<zone>" --machine-type f1-micro
SSH to instance gcloud compute ssh –project "<project-name>" –zone "<zone-name>" "<instance-name>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment