HostOnNet Blog

Google Cloud

Looking for Linux Server Admin or WordPress Expert? We can help.

gcloud is command line tool that is used to provision and manage Google Cloud Platform services. You can download and install it from

https://cloud.google.com/sdk/gcloud/

You can also access it by clicking “Cloud Shell” button on Google Cloud Console top right bar.

See All logged Accounts

gcloud auth list

To Login, run

gcloud auth login

Example

boby@hon-pc-01:~ $ gcloud auth login [email protected]
WARNING: Failed to start a local webserver listening on any port between 8085 and 8186. Please check your firewall settings or locally running programs that may be blocking or using those ports.
WARNING: Defaulting to URL copy/paste mode.
Go to the following link in your browser:

    https://accounts.google.com/o/oauth2/auth?redirect_uri=REMOVED-LONG-URL


Enter verification code: 4/EZIloBlkmgb5t0Bp5WbXy9USBWwndgPFrWfvdXepfVs
WARNING: `gcloud auth login` no longer writes application default credentials.
If you need to use ADC, see:
  gcloud auth application-default --help

You are now logged in as [[email protected]].
Your current project is [None].  You can change this setting by running:
  $ gcloud config set project PROJECT_ID
boby@hon-pc-01:~ $ 


<strong>List all available projects</strong>


boby@hon-pc-01:~ $ gcloud projects list
PROJECT_ID              NAME                    PROJECT_NUMBER
charming-sonar-166306   Not Used                189392009441
cp100-166620            cp100                   768724212491
forum-bestgamenews-com  forum-bestgamenews-com  112973453979
kingashoes-166409       KingaShoesCom           562450418582
lean-166506             Lean                    894293603533
webhostingneeds         WebHostingNeeds         362523391303
boby@hon-pc-01:~ $ 

Set current project

gcloud config set project PROJECT_ID

Example

boby@hon-pc-01:~ $ gcloud config set project cp100-166620
Updated property [core/project].
boby@hon-pc-01:~ $ 

See your current project

gcloud config list project

Example

boby@hon-pc-01:~ $ gcloud config list project
[core]
project = cp100-166620

Your active configuration is: [default]
boby@hon-pc-01:~ $ 

Set region/zone

List of regions and zone available at https://cloud.google.com/compute/docs/regions-zones/regions-zones

gcloud config set compute/zone europe-west1-c
gcloud config set compute/region europe-west1

Create VM

Creating a Google Compute instance via gcloud command line.

root@hon-vpn:~# gcloud compute instances create hon-web-server --zone asia-east1-a
Created [https://www.googleapis.com/compute/v1/projects/hon-gcp-89355f51d664f6b5/zones/asia-east1-a/instances/hon-web-server].
NAME            ZONE          MACHINE_TYPE   PREEMPTIBLE  INTERNAL_IP  EXTERNAL_IP     STATUS
hon-web-server  asia-east1-a  n1-standard-1               10.140.0.3   104.199.192.91  RUNNING
root@hon-vpn:~# 

Now lets login to the gcloud instance we created.

gcloud compute ssh SERVER-NAME

List all Running Compute instances

gcloud compute instances list

List all Persistent Disks

gcloud compute disks list

Posted in Cloud

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.