What is gcloud ?

GCloud is a command line tool available from google that we can use to access google cloud services either using scripts or from command line and run other automations.

How can you access gcloud ?

GCloud is part of the Google Cloud SDK. You have to download and install the SDK on your system and initialize it before you can use gcloud.

Quickstart from Google Command Shell :

First of all open your cloud console and start Google Command Shell by clicking on the top right icon in the toolbar
Capture-d--cran-2018-12-16---04.42.16-1

Let's start with help command

$ gcloud -h

Capture-d--cran-2018-12-16---04.50.53

# To view information about your Cloud SDK installation and the active SDK configuration:

$ gcloud info

Capture-d--cran-2018-12-16---04.57.29

Quickstart from macOS command-line :

This page shows how to install the Google Cloud SDK, initialize it, and run core gcloud commands from the command-line.

First, make sure that Python 2.7 is installed on your system:

$ python -V

Capture-d-e-cran-2018-12-16-a--05.06.45

Download the 64-bit package archive file from :

https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-228.0.0-darwin-x86_64.tar.gz

Extract the archive to your home directory  :

	$ /Users/rcherara/
	$ cp /Users/rcherara/Downloads/google-cloud-sdk-228.0.0-darwin-x86_64.tar /Users/rcherara/
	$ tar -zxvf google-cloud-sdk-228.0.0-darwin-x86_64.tar
	$ rm google-cloud-sdk-228.0.0-darwin-x86_64.tar
	$ ./google-cloud-sdk/install.sh
	

Restart your terminal for the changes to take effect.

Optional : To install or remove components at your  SDK , run:  
$ gcloud components install COMPONENT_ID
$ gcloud components remove COMPONENT_ID

Capture-d-e-cran-2018-12-16-a--05.33.26

Capture-d-e-cran-2018-12-16-a--05.34.43

Capture-d-e-cran-2018-12-16-a--05.47.53

Capture-d-e-cran-2018-12-16-a--05.44.24

To update your SDK installation to the latest version, run:

$ gcloud components update

Initialize the SDK

Use the gcloud init command to  authorizing the SDK tools to access Google Cloud Platform using your user account credentials and setting up the default SDK configuration.

$ gcloud init
# Select a Cloud Platform project or create one

Capture-d-e-cran-2018-12-16-a--05.53.20

# the command  launching a web browser to be authenticated with the Google Cloud SDK

Capture-d-e-cran-2018-12-16-a--05.51.59

Capture-d-e-cran-2018-12-16-a--05.52.14