What is gcloud cli ?
Well if you want to interact with your google cloud platform using your terminal then your are at the right place. In this article ill let you know how to setup gcloud CLI to interact with GCP.
To do this you need to setup the google cloud SDK on your workstation. A gcloud CLI helps to access the GCP with your terminal using the commands. With the gcloud CLI you can create compute machines , create Kubernetes clusters and access all the services of google cloud platform.
Steps to install the gcloud cli.
1 – Download and unzip the package
To achieve the first step you need to use the below command
After the package is downloaded head over to the downloads directory and untar or unzip the package.
tar -xvf google-cloud-sdk-342.0.0-linux-x86_64.tar.gz
With the above command the package will be easily unzipped.
2 – Installing the SDK .
Next run the script from the google-cloud-sdk folder that will install gcloud. To install it run the below script from the folder.
The above command will install all the utils from your package including the cli.
NOTE – In any case if it fails then use the universal command to install the cli
sudo snap install google-cloud-cli --classic
Next comes the configuration part with your google cloud platform
3 – Configuration with google cloud with your project.
Now the below commands will configure the cli in your system to use the google cloud platform.
gcloud init --console-only
After you run this command it will ask your basic info of your account and will initialize your cli to use your gcloud platfrom.
The output of the above will be as below.
So the above image shows the basic config it will ask for . Once completed you are done with configuration and ready to use.
Next to use the gcloud type the below command and there will be plenty of option to use.
- To validate your account the below command will help
gcloud auth list
- For switching between accounts use the below command
gcloud config set account <account id>
- To get any help with gcloud command use the below command
The output is like below