This tutorial will guide you through steps for setting up google cloud SDK on your workstation.
Note: This tutorial will work only on MAC and Linux systems
Step 1: Select the download appropriate sdk package from https://cloud.google.com/sdk/
Step 2: Untar the sdk package.
1
|
tar –xvf google–cloud–sdk*
|
Step 3: Install the sdk using the following command.
1
|
./google–cloud–sdk/install.sh
|
Step 3: Follow through the installation instruction and select the required options.
Configuring Google Cloud SDK
Follow the steps given below for configuring the google cloud sdk.
1. Initialize the sdk using the following commands. Y
1
|
gcloud init
|
2. Accept the google login option for logging in to your google cloud account.
1
|
To continue, you must log in. Would you like to log in (Y/n)? Y
|
3. From the browser login to your google cloud account and grant permissions to access google cloud resources.
4. At the command prompt, you will be prompted with options for initial configurations which are self explanatory.
Testing The CLI Setup
Now lets run some basic gcloud cli commands to verify the installation.
1. List the credential account.
1
|
gcloud auth list
|
2. List the sdk configuration.
1
|
gcloud config list
|
3. List all the local gcloud configurations and files
1
|
gcloud info
|
4. To list all the gcloud commands, use the following command.
1
|
gcloud help
|
Create An Instance Using CLI
To start with, we will create a instance using the CLI.
1. Get the list of images using the following command.
1
|
gcloud compute images list
|
2. The following command will create a f1 micro Centos instance. You can refer this official documentation for more information on the flags.
1
2
3
|
gcloud compute instances create sysaix–demo–instance \
—image centos–7–v20170523 \
—image–project centos–cloud —set–machine–type f1–micro —zone us–central1–a
|
Connecting Instance Via Ssh
To connect the instance via ssh, just execute the following command. The gcloud command will automatically create the ssh key in your ~/.ssh folder if it doesn’t exist and connects to your instance.
1
|
gcloud compute ssh (instance–name)
|
For example,
1
|
gcloud compute ssh sysaix–demo–instance
|
Deleting The Instance
You can delete the created instance using the following command.
1
|
gcloud compute instances delete (instance name)
|
For example,
1
|
gcloud compute instances delete sysaix–demo–instance
|
[…] Prerequisites: To follow this tutorial, you should have a Google Cloud account and google cloud SDK installed on your system. If you don’t have google cloud SDK installed, you can follow this tutorial for the setup –> Google cloud SDK setup […]