Gcloud Command Reference

Gcloud Command Reference

Some trick configuration

To set the project property in the core section, run:

$ gcloud config set project myProject

To set the zone property in the compute section, run:

$ gcloud config set compute/zone us-central1-a

To disable prompting for scripting, run:

$ gcloud config set disable_prompts true

To set a proxy with the appropriate type, and specify the address and port on which to reach it, run:

$ gcloud config set proxy/type http
$ gcloud config set proxy/address 1.234.56.78
$ gcloud config set proxy/port 8080

Show your running instances

$ gcloud compute instances list
NAME ZONE MACHINE_TYPE PREEMPTIBLE INTERNAL_IP EXTERNAL_IP STATUS
test3-jump-001 us-central1-a f1-micro 10.200.1.2 200.200.200.17 RUNNING
test3-node-001 us-central1-a n1-standard-1 10.200.252.6 RUNNING
test3-node-002 us-central1-a n1-standard-1 10.200.252.2 RUNNING
test3-node-003 us-central1-a n1-standard-1 10.200.252.3 RUNNING
test3-node-004 us-central1-a n1-standard-1 10.200.252.4 RUNNING
test3-node-005 us-central1-a n1-standard-1 10.200.252.5 RUNNING

Working with Buckets

To set create a new bucket, run:

$ gsutil mb gs://mySuperNewBucket

To enable versioning on it, run:

$ gsutil versioning set on gs://mySuperNewBucket

To remove all files on the bucket

$ gsutil rm -r gs://mySuperNewBucket

To remove the bucket (needs to be empty)

$ gsutil rb gs://mySuperNewBucket

Listing zones 

To show all available zones for your account, run:

$ gcloud compute zones list
NAME REGION STATUS NEXT_MAINTENANCE TURNDOWN_DATE
us-east1-b us-east1 UP
us-east1-c us-east1 UP
us-east1-d us-east1 UP
us-east4-c us-east4 UP
us-east4-b us-east4 UP
us-east4-a us-east4 UP
us-central1-c us-central1 UP
us-central1-a us-central1 UP

Listing machine-types and show CPU memory sizes

You could filter per region including a filter on it, example:

$ gcloud compute machine-types list --filter="zone ~ ^us-central1-a"
NAME ZONE CPUS MEMORY_GB DEPRECATED
f1-micro us-central1-a 1 0.60
g1-small us-central1-a 1 1.70
n1-highcpu-16 us-central1-a 16 14.40
n1-highcpu-2 us-central1-a 2 1.80
n1-highcpu-32 us-central1-a 32 28.80
n1-highcpu-4 us-central1-a 4 3.60
n1-highcpu-64 us-central1-a 64 57.60
n1-highcpu-8 us-central1-a 8 7.20
n1-highcpu-96 us-central1-a 96 86.40
n1-highmem-16 us-central1-a 16 104.00
n1-highmem-2 us-central1-a 2 13.00
n1-highmem-32 us-central1-a 32 208.00
n1-highmem-4 us-central1-a 4 26.00
n1-highmem-64 us-central1-a 64 416.00
n1-highmem-8 us-central1-a 8 52.00
n1-highmem-96 us-central1-a 96 624.00
n1-standard-1 us-central1-a 1 3.75
n1-standard-16 us-central1-a 16 60.00
n1-standard-2 us-central1-a 2 7.50
n1-standard-32 us-central1-a 32 120.00
n1-standard-4 us-central1-a 4 15.00
n1-standard-64 us-central1-a 64 240.00
n1-standard-8 us-central1-a 8 30.00
n1-standard-96 us-central1-a 96 360.00

Connect to a compute instance using the gcloud credentials

To access one instance through your gcloud credentials, run:

$ gcloud compute --project "myCoolProjectName" ssh --zone "us-east1-b" "myCoolInstanceName"

Leave a Reply

Your email address will not be published. Required fields are marked *