Le Quang Long

Working on GCP with gcloud command line

08 Aug 2017 Le Quang Long.

Contents

Install Google Cloud SDK

You can refer this link to read full instruction. I just note how to install Google Cloud SDK on MAC OS X.

  • Click to download Google Cloud SDK.
  • Extract the package to any location you want.(I put it at : /Users/lequanglong/google-cloud-sdk)
  • Access to the extracted folder, open the Terminal application on MAC OS X , copy the commands as below, paste to the Terminal then press Enter key on your keyboard:
    cd /Users/lequanglong/google-cloud-sdk
     ./install.sh
    

Or you can install Google Cloud SDK by copy the below command into Terminal:

curl https://dl.google.com/dl/cloudsdk/release/install_google_cloud_sdk.bash | bash

After the the installation is finished, you can check the gcloud command is working or not by type :

gcloud -v

I will return the version of Google Cloud SDK. This is my result : Google Cloud SDK 147.0.0

If you can not run the gcloud on any location, please check the bash_profile at

sudo vi ~/.bash_profile

this is my bash_profile file:

export PATH="/usr/local/mysql/bin:$PATH"
LUNCHY_DIR=$(dirname `gem which lunchy`)/../extras
   if [ -f $LUNCHY_DIR/lunchy-completion.bash ]; then
     . $LUNCHY_DIR/lunchy-completion.bash
   fi

# The next line updates PATH for the Google Cloud SDK.
if [ -f '/Users/lequanglong/google-cloud-sdk/path.bash.inc' ]; then source '/Users/lequanglong/google-cloud-sdk/path.bash.inc'; fi
export PATH=/Users/lequanglong/google-cloud-sdk/bin:$PATH
# The next line enables shell command completion for gcloud.
if [ -f '/Users/lequanglong/google-cloud-sdk/completion.bash.inc' ]; then source '/Users/lequanglong/google-cloud-sdk/completion.bash.inc'; fi
export PATH=/usr/local/mysql/bin:/Users/lequanglong/google-cloud-sdk/bin /usr/local/bin /usr/bin /bin /usr/sbin /sbin

Let’s play some commands with gcloud command.

  • Authentication with your account
    gcloud auth login
    

alt text
alt text


alt text

  • Show projects list
    gcloud projects list
    

    alt text

Working with Google App Engine with gcloud

Working with Google Compute Engine with gcloud

Working with Google Cloud SQL with gcloud