Building Google Cloud Platform Solutions
上QQ阅读APP看书,第一时间看更新

Installing the Google Cloud SDK

The Google Cloud SDK comes preinstalled in the Cloud Shell, but there are oftentimes when having the SDK installed locally will provide a better developer experience. To install the Cloud SDK, visit https://cloud.google.com/sdk and follow the instructions for your operating system.

Previously, Google offered separate SDKs for each of the supported languages on App Engine. Google has consolidated many of these SDKs into the core Google Cloud SDK, making them available as components. For example, Java support for App Engine is available as gcloud app Java Extensions, and it can be installed by running gcloud components install app-engine-java. Although some of these standalone SDKs are still available for download, it is recommended that users install App Engine language support SDKs as components.

The Google Cloud SDK installs the following tools by default:

  • gcloud: A command-line interface for managing cloud resources
  • bq: Commands for interacting with Google BigQuery
  • gsutil: Tools for Google Cloud Storage

On Windows, the Google Cloud SDK is installed via an installation wizard. The Google Cloud SDK requires a local installation of Python 2.7.9 or higher to function. The installation wizard can optionally install this for you. By default, the installer will bundle Google's command-line tools for PowerShell with your application. This makes the Google Cloud SDK command-line tools available in your PowerShell environment, with full support for traditional PowerShell operations and cmdlets. Cloud Tools for PowerShell can also be installed from within PowerShell by running Install-Module GoogleCloud.

For Mac and Linux users, the Google Cloud SDK is available in the tar.gz format. Simply download and extract the SDK on your local machine. After doing so, you can run the included install script, install.sh. This will check that a compatible version of Python is installed and add the Google Cloud SDK commands to your system path, as well as Bash and zsh completions. Alternatively, you can add Google Cloud SDK commands and completions by sourcing the path and completion files directly in your shell config file. For bash, this would look something like this:

export GOOGLE_CLOUD_HOME=/path/to/your/sdk
source $GOOGLE_CLOUD_HOME/path.bash.inc
source $GOOGLE_CLOUD_HOME/completion.bash.inc

In addition to installing a distribution of the Google Cloud SDK, Google makes the SDK available in the form of Docker images. This can be useful for ephemeral environments, such as task runners and build servers. The SDK image is available on Docker Hub as google/cloud-sdk (https://hub.docker.com/r/google/cloud-sdk).