Installing the Google Cloud CLI
Procedure
-
Issue the following command to download gcloud CLI.
wget https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-289.0.0-darwin-x86_64.tar.gz
- Extract the file.
tar xvf google-cloud-sdk-289.0.0-darwin-x86_64.tar.gz
- Run the installation.
./google-cloud-sdk/install.sh
When prompted to help improve the Google Cloud SDK, enter Y for yes.
The expected output is similar to:Your current Cloud SDK version is: 289.0.0 The latest available version is: 363.0.0 ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ Components │ ├──────────────────┬──────────────────────────────────────────────────────┬──────────────────────────┬──────────┤ │ Status │ Name │ ID │ Size │ ├──────────────────┼──────────────────────────────────────────────────────┼──────────────────────────┼──────────┤ │ Update Available │ BigQuery Command Line Tool │ bq │ < 1 MiB │ │ Update Available │ Cloud SDK Core Libraries │ core │ 20.9 MiB │ │ Update Available │ Cloud Storage Command Line Tool │ gsutil │ 8.1 MiB │ │ Not Installed │ App Engine Go Extensions │ app-engine-go │ 4.8 MiB │ │ Not Installed │ Appctl │ appctl │ 18.5 MiB │ │ Not Installed │ Cloud Bigtable Command Line Tool │ cbt │ 7.6 MiB │ │ Not Installed │ Cloud Bigtable Emulator │ bigtable │ 6.6 MiB │ │ Not Installed │ Cloud Datalab Command Line Tool │ datalab │ < 1 MiB │ │ Not Installed │ Cloud Datastore Emulator │ cloud-datastore-emulator │ 18.4 MiB │ │ Not Installed │ Cloud Firestore Emulator │ cloud-firestore-emulator │ 40.4 MiB │ │ Not Installed │ Cloud Pub/Sub Emulator │ pubsub-emulator │ 60.7 MiB │ │ Not Installed │ Cloud SQL Proxy │ cloud_sql_proxy │ 7.4 MiB │ │ Not Installed │ Emulator Reverse Proxy │ emulator-reverse-proxy │ 14.5 MiB │ │ Not Installed │ Google Cloud Build Local Builder │ cloud-build-local │ 6.2 MiB │ │ Not Installed │ Google Container Registry's Docker credential helper │ docker-credential-gcr │ 2.2 MiB │ │ Not Installed │ Kustomize │ kustomize │ 7.6 MiB │ │ Not Installed │ Minikube │ minikube │ 26.6 MiB │ │ Not Installed │ Nomos CLI │ nomos │ 24.4 MiB │ │ Not Installed │ On-Demand Scanning API extraction helper │ local-extract │ 12.5 MiB │ │ Not Installed │ Skaffold │ skaffold │ 20.1 MiB │ │ Not Installed │ anthos-auth │ anthos-auth │ 18.0 MiB │ │ Not Installed │ config-connector │ config-connector │ 46.9 MiB │ │ Not Installed │ gcloud Alpha Commands │ alpha │ < 1 MiB │ │ Not Installed │ gcloud Beta Commands │ beta │ < 1 MiB │ │ Not Installed │ gcloud app Java Extensions │ app-engine-java │ 52.7 MiB │ │ Not Installed │ gcloud app PHP Extensions │ app-engine-php │ 21.9 MiB │ │ Not Installed │ gcloud app Python Extensions │ app-engine-python │ 7.8 MiB │ │ Not Installed │ gcloud app Python Extensions (Extra Libraries) │ app-engine-python-extras │ 26.4 MiB │ │ Not Installed │ kpt │ kpt │ 12.8 MiB │ │ Not Installed │ kubectl │ kubectl │ < 1 MiB │ │ Not Installed │ kubectl-oidc │ kubectl-oidc │ 18.0 MiB │ │ Not Installed │ pkg │ pkg │ │ └──────────────────┴──────────────────────────────────────────────────────┴──────────────────────────┴──────────┘
- To install or remove components at the current SDK version (289.0.0), run the following
command:
gcloud components install COMPONENT_ID
Or the following command:
gcloud components remove COMPONENT_ID
- When prompted with the following
question:
Enter Y for yes.Modify profile to update your $PATH and enable shell command completion? Do you want to continue (Y/n)?
- The Google Cloud SDK installer prompts you to update an rc file to bring the Google Cloud
CLI to your environment:
Enter a path to an rc file to update, or leave blank to use [/Users/myUsername/.zshrc]: Backing up [/Users/myUsername/.zshrc] to [/Users/myUsername/.zshrc.backup].
- Issue the following command:
gcloud --version
The expected output is similar to:
Google Cloud SDK 289.0.0 bq 2.0.56 core 2020.04.10 gsutil 4.49
- To begin the configuration of gcloud, enter the following
command:
gcloud init
- You are presented with the following output and then walked through the
configuration:
Welcome! This command will take you through the configuration of gcloud. Settings from your current configuration [default] are: core: account: MyUsername@ibm.com disable_usage_reporting: 'False'
- When prompted with the following choice:
Pick configuration to use: [1] Re-initialize this configuration [default] with new settings [2] Create a new configuration
Enter 2 to create a new configuration.
- When prompted with the following input:
Enter configuration name. Names start with a lowercase letter and contain only lowercase letters a-z, digits 0-9, and hyphens '-':
- Enter a configuration name. This example uses gcpviswa2 as the configuration name. The
expected output is similar to:
Your current configuration has been set to: [gcpviswa2]
- By default, the gcloud init command includes diagnostics and generates this output:
Network diagnostic detects and fixes local network connection issues. Checking network connection...done. Reachability Check passed. Network diagnostic passed (1/1 checks passed).
In the future, you can skip diagnostics by issuing gcloud init --skip-diagnostics.
- When prompted with the following tchoice:
Choose the account you would like to use to perform operations for this configuration: [1] MyUsername@ibm.com [2] Log in with a new account Please enter your numeric choice:
Enter 1 to use the current account.
The expected output is similar to:
You are logged in as: [MyUsername@ibm.com].
- When prompted with the following choice:
Pick cloud project to use: [1] aesthetic-frame-155821 [2] Create a new project Please enter numeric choice or text value (must exactly match list item):
Enter 1 to use the current cloud project.
The expected output is similar to:
Your current project has been set to: [aesthetic-frame-155821].
- When prompted with the following question:
Do you want to configure a default Compute Region and Zone? (Y/n)?
Enter y to configure a default region and zone.
- When prompted with the following question:
Which Google Compute Engine zone would you like to use as project default? If you do not specify a zone via a command line flag while working with Compute Engine resources, the default is assumed. [1] us-east1-b [2] us-east1-c [3] us-east1-d [4] us-east4-c [5] us-east4-b [6] us-east4-a [7] us-central1-c [8] us-central1-a [9] us-central1-f [10] us-central1-b [11] us-west1-b [12] us-west1-c [13] us-west1-a [14] europe-west4-a [15] europe-west4-b [16] europe-west4-c [17] europe-west1-b [18] europe-west1-d [19] europe-west1-c [20] europe-west3-c [21] europe-west3-a [22] europe-west3-b [23] europe-west2-c [24] europe-west2-b [25] europe-west2-a [26] asia-east1-b [27] asia-east1-a [28] asia-east1-c [29] asia-southeast1-b [30] asia-southeast1-a [31] asia-southeast1-c [32] asia-northeast1-b [33] asia-northeast1-c [34] asia-northeast1-a [35] asia-south1-c [36] asia-south1-b [37] asia-south1-a [38] australia-southeast1-b [39] australia-southeast1-c [40] australia-southeast1-a [41] southamerica-east1-b [42] southamerica-east1-c [43] southamerica-east1-a [44] asia-east2-a [45] asia-east2-b [46] asia-east2-c [47] asia-northeast2-a [48] asia-northeast2-b [49] asia-northeast2-c [50] asia-northeast3-a Did not print [36] options. Too many options [86]. Enter "list" at prompt to print choices fully. Please enter numeric choice or text value (must exactly match list item):
Enter the number that corresponds to the region that you want to set. For this example, enter 13 for us-west1-a.
The expected output is similar to:Your project default Compute Engine zone has been set to [us-west1-a]. You can change it by running [gcloud config set compute/zone NAME]. Your project default Compute Engine region has been set to [us-west1]. You can change it by running [gcloud config set compute/region NAME].
- The final expected output is similar to:
Created a default boto configuration file at [/Users/myUsername/.boto]. See this file and [https://cloud.google.com/storage/docs/gsutil/commands/config] for more information about configuring Google Cloud Storage. Your Google Cloud SDK is configured and ready to use! * Commands that require authentication will use MyUsername@ibm.com by default * Commands will reference project `aesthetic-frame-155821` by default * Compute Engine commands will use region `us-west1` by default * Compute Engine commands will use zone `us-west1-a` by default Run `gcloud help config` to learn how to change individual settings This gcloud configuration is called [gcpviswa2]. You can create additional configurations if you work with multiple accounts and/or projects. Run `gcloud topic configurations` to learn more. Some things to try next: * Run `gcloud --help` to see the Cloud Platform services you can interact with. And run `gcloud help COMMAND` to get help on any gcloud command. * Run `gcloud topic --help` to learn about advanced features of the SDK like arg files and output formatting