How to install Google Cloud Platform (GCP) SDK – gcloud CLI tool?
“The Cloud SDK is a set of tools for Cloud Platform. It contains gcloud, gsutil, and bq, which you can use to access Google Compute Engine, Google Cloud Storage, Google BigQuery, and other products and services from the command-line. You can run these tools interactively or in your automated scripts”.
Let’s start with downloading, installing and initializing this tool in an interactive manner, accept all default settings for all prompts.
Step 1. Download the Cloud SDK installer.
Alternatively, open a PowerShell terminal and run the following PowerShell commands.
(New-Object Net.WebClient).DownloadFile("https://dl.google.com/dl/cloudsdk/channels/rapid/GoogleCloudSDKInstaller.exe", "$env:Temp\GoogleCloudSDKInstaller.exe") & $env:Temp\GoogleCloudSDKInstaller.
Launch the installer and follow the prompts. The installer is signed by Google LLC.
Cloud SDK requires Python. Supported versions are 3.5 to 3.8, and 2.7.9 or higher.
The installer will install all necessary dependencies, including the needed Python version. While Cloud SDK currently uses Python 3 by default, you can use an existing Python installation if necessary by unchecking the option to ‘Install Bundled Python’.
Step 2. Start Google Cloud SDK Shell
After the installation has completed, start the command prompt and do remember to “Run as Administrator”. It will help in installing components if needed.
Step 3: Initialize the Cloud SDK
- Run the following at a command prompt:
Go with the installation as it tries to log into your Google Cloud account and set the project.
If the above installation steps go well, check its version:
gcloud compute regions list
Only the core components of the gcloud SDK are installed during initial installation. For any additional component to interact with GCP, you have to install the additional component. For instance, to install the component for interactive with Google Kubernetes Engine(GKE) you have to install kubectl:
gcloud components install kubectl
Many features of GCP are available in Beta only, for that you have to install the beta component:
gcloud components install beta
Stay up to date with:
gcloud components update
You can find the troubleshooting tips on https://cloud.google.com/sdk/docs/quickstart.
The instructions used in this post were tested on Windows 10.