安装 Google Cloud CLI
程序
- 发出以下命令以下载 gcloud CLI。
wget https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-289.0.0-darwin-x86_64.tar.gz - 解压缩文件。
tar xvf google-cloud-sdk-289.0.0-darwin-x86_64.tar.gz - 运行安装。
./google-cloud-sdk/install.sh当系统提示您帮助改进 Google Cloud SDK 时,请输入 Y 以表示 "是"。
期望的输出类似于: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 │ │ └──────────────────┴──────────────────────────────────────────────────────┴──────────────────────────┴──────────┘ - 要安装或除去当前 SDK 版本 (289.0.0) 的组件,请运行以下命令:
gcloud components install COMPONENT_ID或者以下命令:
gcloud components remove COMPONENT_ID - 出现以下问题提示时:
输入 Y 表示是。Modify profile to update your $PATH and enable shell command completion? Do you want to continue (Y/n)? - Google Cloud SDK 安装程序会提示您更新 rc 文件以将 Google Cloud CLI 引入到您的环境中:
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]. - 发出以下命令:
gcloud --version期望的输出类似于:
Google Cloud SDK 289.0.0 bq 2.0.56 core 2020.04.10 gsutil 4.49 - 要开始配置 gcloud ,请输入以下命令:
gcloud init - 将显示以下输出,然后遍历配置:
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' - 出现提示时,请选择以下选项:
Pick configuration to use: [1] Re-initialize this configuration [default] with new settings [2] Create a new configuration输入 2 以创建新配置。
- 提示输入以下内容时:
Enter configuration name. Names start with a lowercase letter and contain only lowercase letters a-z, digits 0-9, and hyphens '-': - 输入配置名称。 此示例使用 gcpviswa2 作为配置名称。 期望的输出类似于:
Your current configuration has been set to: [gcpviswa2] - 缺省情况下, gcloud init 命令包含诊断并生成以下输出:
Network diagnostic detects and fixes local network connection issues. Checking network connection...done. Reachability Check passed. Network diagnostic passed (1/1 checks passed).将来,您可以通过执行gcloud init --skip-diagnostics 来跳过诊断。
- 出现以下 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:输入 1 以使用当前帐户。
期望的输出类似于:
You are logged in as: [MyUsername@ibm.com]. - 出现提示时,请选择以下选项:
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):输入 1 以使用当前云项目。
期望的输出类似于:
Your current project has been set to: [aesthetic-frame-155821]. - 出现以下问题提示时:
Do you want to configure a default Compute Region and Zone? (Y/n)?输入 y 以配置缺省区域和区域。
- 出现以下问题提示时:
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):输入对应于要设置的区域的数字。 对于此示例,输入 13 表示 us-west1-a。
期望的输出类似于: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]. - 最终预期输出类似于:
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