Google Cloud SDK のアップデートとかコンポーネント追加・削除・復元などの制御

備忘録的に、まとめておきます。

gcloudのバージョン

$ gcloud --version
Google Cloud SDK 96.0.0

gcloudのアップデート

$ sudo gcloud components update

Your current Cloud SDK version is: 92.0.0
You will be upgraded to version: 96.0.0

┌───────────────────────────────────────────────────┐
│         These components will be updated.         │
├────────────────────────────┬────────────┬─────────┤
│            Name            │  Version   │   Size  │
├────────────────────────────┼────────────┼─────────┤
│ BigQuery Command Line Tool │     2.0.18 │ < 1 MiB │
│ Cloud SDK Core Libraries   │ 2016.02.05 │ 3.7 MiB │
└────────────────────────────┴────────────┴─────────┘
┌─────────────────────────────────────────────────────────────────────┐
│                 These components will be installed.                 │
├──────────────────────────────────────────────┬────────────┬─────────┤
│                     Name                     │  Version   │   Size  │
├──────────────────────────────────────────────┼────────────┼─────────┤
│ Cloud SDK Core Libraries (Platform Specific) │ 2016.02.05 │ < 1 MiB │
└──────────────────────────────────────────────┴────────────┴─────────┘

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

こんな感じで "gcloud components update" を実行する。

Do you want to continue (Y/n)?  Y

問題なければ "Y" をタイプ。

・・・・・省略・・・・・

Performing post processing steps...done.

Update done!

To revert your SDK to the previously installed version, you may run:
  $ gcloud components update --version [92.0.0]

こんな感じで "Update done!" と出ていればOK。
revert したくなったらこれを実行しろ、的なアドバイス付き。

利用できるコンポーネントの一覧

$ gcloud components list

Your current Cloud SDK version is: 96.0.0
The latest available version is: 96.0.0

┌──────────────────────────────────────────────────────────────────────────────────────────┐
│                                        Components                                        │
├───────────────┬──────────────────────────────────────┬───────────────────────┬───────────┤
│     Status    │                 Name                 │           ID          │    Size   │
├───────────────┼──────────────────────────────────────┼───────────────────────┼───────────┤
│ Not Installed │ Cloud Datastore Emulator             │ gcd-emulator          │  38.1 MiB │
│ Not Installed │ Cloud Pub/Sub Emulator               │ pubsub-emulator       │  10.1 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       │ 101.4 MiB │
│ Not Installed │ gcloud app PHP Extensions (Mac OS X) │ app-engine-php-darwin │  21.9 MiB │
│ Not Installed │ gcloud app Python Extensions         │ app-engine-python     │   7.2 MiB │
│ Not Installed │ kubectl                              │ kubectl               │           │
│ Installed     │ BigQuery Command Line Tool           │ bq                    │   < 1 MiB │
│ Installed     │ Cloud SDK Core Libraries             │ core                  │   3.7 MiB │
│ Installed     │ Cloud Storage Command Line Tool      │ gsutil                │   2.6 MiB │
│ Installed     │ Default set of gcloud commands       │ gcloud                │           │
└───────────────┴──────────────────────────────────────┴───────────────────────┴───────────┘


To install or remove components at your current SDK version [96.0.0], run:
  $ gcloud components install COMPONENT_ID
  $ gcloud components remove COMPONENT_ID

To update your SDK installation to the latest version [96.0.0], run:
  $ gcloud components update

コンポーネントリストは "gcloud components list" で確認する。
インストールされているものと、まだインストールされていないものが可視化されている。

コンポーネントの追加・削除

リスト時のアウトプットに記載もされているが以下のような感じ。
私は、まだ Beta コマンド扱いのサブネットワークまわりの制御をしたかったので、以下を実行した。

$ sudo gcloud components install beta
┌─────────────────────────────────────────────┐
│     These components will be installed.     │
├──────────────────────┬────────────┬─────────┤
│         Name         │  Version   │   Size  │
├──────────────────────┼────────────┼─────────┤
│ gcloud Beta Commands │ 2016.01.12 │ < 1 MiB │
└──────────────────────┴────────────┴─────────┘

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

Do you want to continue (Y/n)?  Y

・・・・・省略・・・・・

Update done!

さっきと同じように問題なければ "Y" をタイプして、 "Update done!" が出れば完了。
"gcloud components list" を再度実行すれば、リストの一覧にも "Installed" のステータスで表記されていると思います。


コンポーネントの削除は、同じ要領で "gcloud components remove" を実行する感じ。

コンポーネントの復元

何かしらのアップデートを加えた後に、元の状態に戻したくなった場合は、 "gcloud components restore" が使える。

$ sudo gcloud components restore
Your Cloud SDK installation will be restored to its previous state.

Do you want to continue (Y/n)?  Y

Restoring backup...

Performing post processing steps...done.
Restoration done!

こんな感じで、直前にコンポーネントに関してアップデートしたアクションに対して、バックアップから以前の状態にリストアすることもできるみたいです。


それでは!=͟͟͞͞(๑•̀=͟͟͞͞(๑•̀д•́=͟͟͞͞(๑•̀д•́๑)=͟͟͞͞(๑•̀д•́