How to Setup Google Cloud CLI/SDK – Beginner Guide
- Last Updated On: June 11, 2017
- By: devopscube
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.
tar -xvf google-cloud-sdk*
Step 3: Install the sdk using the following command.
./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
gcloud init
2. Accept the google login option for logging in to your google cloud account.
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.
gcloud auth list
2. List the sdk configuration.
gcloud config list
3. List all the local gcloud configurations and files
gcloud info
4. To list all the gcloud commands, use the following command.
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.
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.
gcloud compute instances create devopscube-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.
gcloud compute ssh (instance-name)
For example,
gcloud compute ssh devopscube-demo-instance
Deleting the Instance
You can delete the created instance using the following command.
gcloud compute instances delete (instance name)
For example,
gcloud compute instances delete devopscube-demo-instance
devopscube
Other Interesting Blogs
List of 16 Linux Networking and Troubleshooting Commands for Beginners
Network configuration and troubleshooting are the essential part of Linux administration. Even for a developer who works with Linux Systems, knowledge about
How To Setup Ansible Dynamic Inventory For Google Cloud
The best way to manage and orchestrate VM instances in Google cloud using Ansible is through Dynamic inventory plugin. It is an
Docker Tutorial: How To Install and configure Docker on Ubuntu
Before installing docker on ubuntu, if you want to learn docker basics, head over to this article – what is docker? In this
How To Mount Extra Disks on Google Cloud VM Instance
By default, the new disks attached during the instance creation cannot be used directly. You need to format and mount it to
Cloud Based Docker Container Monitoring Using Datadog
2016 has been the year of Docker containers, as it has been the latest and the most advanced technology the IT industry