GCP SDK Update

Here’s how to update your Google Cloud Platform SDK (Software Development Kit) which is aka the CLI for interacting with Google’s API.

Get Current Version

gcloud version

Get the Components List

gcloud components list

Update

gcloud components update

GCloud Interactive Shell

If you already have Google SDK installed, you can activate GCloud Interactive Shell, which is still in beta by the way, by typing the following command from the Google SDK terminal.

gcloud beta interactive

The interactive shell environment has auto-completion. It shows you who’s logged in and which project you are currently set in. To exit the interactive shell, just Press F9 to quit.

Install GCP SDK

Here’s how to install Google Cloud Platform SDK on the following.

Centos, Fedora and Redhat

# Setup Repo
sudo tee -a /etc/yum.repos.d/google-cloud-sdk.repo << EOF
[google-cloud-sdk]
name=Google Cloud SDK
baseurl=https://packages.cloud.google.com/yum/repos/cloud-sdk-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg
       https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
EOF
# Install
yum install google-cloud-sdk

For Debian, Ubuntu, Mint

# Create an environment variable for the correct distribution
export CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)"
# Add the Cloud SDK distribution URI as a package source
echo "deb http://packages.cloud.google.com/apt $CLOUD_SDK_REPO main" \
  | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
# Import the Google Cloud Platform public key
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg \
  | sudo apt-key add -
# Update the package list and install the Cloud SDK
sudo apt-get update && sudo apt-get install google-cloud-sdk

Google SDK Update

How to upgrade Google SDK on Redhat, Fedora and Centos Linux.

gcloud components update

If you are having trouble running that command because the GCloud component manager is disabled, you can try the following commands which will achieve the same result as above.

sudo yum makecache && sudo yum update \
kubectl \
google-cloud-sdk \
google-cloud-sdk-app-engine-grpc \
google-cloud-sdk-pubsub-emulator \
google-cloud-sdk-app-engine-go \
google-cloud-sdk-cloud-build-local \
google-cloud-sdk-datastore-emulator \
google-cloud-sdk-app-engine-python \
google-cloud-sdk-cbt \
google-cloud-sdk-bigtable-emulator \
google-cloud-sdk-datalab \
google-cloud-sdk-app-engine-java

GCP List Snapshots

Here are several examples how to display GCP snapshots using Google SDK (CLI – command line interface).

# list snapshots
gcloud compute snapshots list --project my-project --filter="name~'my-server-boot'"
# limit 10
gcloud compute snapshots list --project my-project --filter="name~'my-server-boot'" --limit 10
# reverse order
gcloud compute snapshots list --project my-project --filter="name~'my-server-boot'" --limit 10 --sort-by="~name"
# display uri
gcloud compute snapshots list --project my-project --filter="name~'my-server-boot'" --limit 10 --sort-by="~name" --uri