網頁

2023/2/9

Mac Homebrew 安裝 GCP gcloud CLI

在Mac以Homebrew安裝GCP gcloud CLI命令工具。


GCP的gcloud CLI是用來在命令列操作GCP資源的工具。

安裝環境:

  • MacBook Pro Apple M1 Pro
  • macOS Ventura 13.0.1
  • zsh 5.8.1 (x86_64-apple-darwin22.0)
  • Homebrew 3.6.20


安裝

在終端機輸入brew install --cask google-cloud-sdk以Homebrew安裝google-cloud-sdk,其中包含了gcloud CLI。

% brew install --cask google-cloud-sdk
==> Caveats
To add gcloud components to your PATH, add this to your profile:

  for bash users
    source "/opt/homebrew/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.bash.inc"

  for zsh users
    source "/opt/homebrew/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.zsh.inc"

  for fish users
    source "/opt/homebrew/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.fish.inc"

==> Downloading https://dl.google.com/dl/cloudsdk/release/google-cloud-sdk.tar.gz
######################################################################## 100.0%
Warning: No checksum defined for cask 'google-cloud-sdk', skipping verification.
==> Installing dependencies: gdbm, python@3.10
...
==> Installing gdbm
...
==> Installing python@3.10 dependency: openssl@1.1
...
==> Installing python@3.10
...
==> Installing Cask google-cloud-sdk
==> Running installer script 'google-cloud-sdk/install.sh'
Welcome to the Google Cloud CLI!
Beginning update. This process may take several minutes.


Your current Google Cloud CLI version is: 417.0.1
Installing components from version: 417.0.1

┌─────────────────────────────────────────────────────────────────────────────┐
│                     These components will be installed.                     │
├─────────────────────────────────────────────────────┬────────────┬──────────┤
│                         Name                        │  Version   │   Size   │
├─────────────────────────────────────────────────────┼────────────┼──────────┤
│ BigQuery Command Line Tool                          │     2.0.84 │  1.6 MiB │
│ BigQuery Command Line Tool (Platform Specific)      │     2.0.77 │  < 1 MiB │
│ Cloud Storage Command Line Tool                     │       5.19 │ 15.6 MiB │
│ Cloud Storage Command Line Tool (Platform Specific) │       5.13 │  < 1 MiB │
│ Google Cloud CLI Core Libraries (Platform Specific) │ 2022.09.20 │  < 1 MiB │
│ Google Cloud CRC32C Hash Tool                       │      1.0.0 │  1.1 MiB │
│ anthoscli                                           │     0.2.34 │ 66.3 MiB │
│ gcloud cli dependencies                             │ 2021.04.16 │  < 1 MiB │
└─────────────────────────────────────────────────────┴────────────┴──────────┘

For the latest full release notes, please visit:
  https://cloud.google.com/sdk/release_notes
...

Performing post processing steps...
...............................................done.

Update done!


This will install all the core command line tools necessary for working with
the Google Cloud Platform.

==> Source [/opt/homebrew/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.zsh.inc] in your profile to enable shell command completion for gcloud.
==> Source [/opt/homebrew/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.zsh.inc] in your profile to add the Google Cloud SDK command line tools to your $PATH.

For more information on how to get started, please visit:
  https://cloud.google.com/sdk/docs/quickstarts
...
🍺  google-cloud-sdk was successfully installed!

安裝完後設定PAHT路徑,本範例的shell為ZSH,所以在終端機輸入source "$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.zsh.inc"

% source "$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.zsh.inc"

輸入gcloud -v檢視版本資訊,這邊為417.0.1。

% gcloud -v
Google Cloud SDK 417.0.1
bq 2.0.84
core 2023.02.08
gcloud-crc32c 1.0.0
gsutil 5.19

安裝好後要做gcloud CLI初始化設定存取GCP權限。

沒有留言:

張貼留言