What is Google Cloud SDK? Google cloud sdk is a set of tools that enables you to manage your resources hosted on Google Cloud, just like AWS CLI for those who use AWS cloud. Good Cloud SDK presents a number of important command line tools such as gcloud, gsutil and bq that enable effective management of applications and other resources in Google cloud. In this guide, we are going to look at how to install and use Google Cloud SDK on Linux Mint 20 / Ubuntu 20.04.

Update System Packages

The first to always ensure is that you are running on the latest system packages. Update them as below and reboot

sudo apt-get update
sudo apt-get -y upgrade
sudo reboot

Check Python Version

Google Cloud SDK requires Python 2.7.9 or higher. Linux Mint 20 / Ubuntu 20.04 already comes with Python 3 installed. Confirm python version by running the below command:

$ python --version
3.8.10

If you do not have Python installed already, run the following command to install it

sudo apt-get install python3

Installing Google Cloud SDK on Linux Mint 20 / Ubuntu 20.04

We are going to look at various ways of installing Google SDK on Linux Mint 20 and Ubuntu 20.04. The first method of installation is by adding a Google SDK repository on our systems. The packages that will be installed include gcloud, gsutil, bq, gcloud alpha and gcloud beta. Other tools such as kubectl and App Engine extensions needed for deploying applications with gcloud command will have to be installed separately

Install Google Cloud SDK using Apt repository

Run the command below to add Google Cloud SDK repository to sources.list file

echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list

Installed required dependencies as below:

sudo apt-get install apt-transport-https ca-certificates gnupg

Next, we import Google cloud SDK public key

curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -

Finally, update and install Google Cloud SDK

sudo apt-get update
sudo apt-get install google-cloud-sdk

The tools that will be installed as part of Google Cloud SDK include:

  • gcloud – called default gcloud CLI command is the tool for interacting with Google Cloud. It works with Google Compute Engine and can be compared to AWS EC2)
  • bq (BigQuery Command Line tool) – is the tool that enables working with data in Google BigQuery. Can be compared to AWS Redshift
  • gsutil (Cloud storage Command Line) – Used with any operations to do with Google Cloud storage just like AWS S3.
  • alpha (gcloud CLI alpha commands) – gcloud CLI commands at the alpha release level.
  • beta (gcloud CLI beta commands) – gcloud CLI commands at the alpha release level.

You can then proceed to install additional tools that you may require using ‘apt-get install‘. Some of the important tool you may need are as listed:

  • google-cloud-sdk-app-engine-python
  • google-cloud-sdk-app-engine-python-extras
  • google-cloud-sdk-app-engine-java
  • google-cloud-sdk-app-engine-go
  • google-cloud-sdk-bigtable-emulator
  • google-cloud-sdk-cbt
  • google-cloud-sdk-cloud-build-local
  • google-cloud-sdk-datalab
  • google-cloud-sdk-datastore-emulator
  • google-cloud-sdk-firestore-emulator
  • google-cloud-sdk-pubsub-emulator
  • kubectl

For exampe:

sudo apt-get install google-cloud-sdk-app-engine-python

Install Google Cloud SDK using Snap

Another easy way to install Google cloud SDk on Ubuntu 20.04 and Linux Mint 20 is to use snap package. Simply run the below single command:

sudo snap install google-cloud-sdk --classic

Install Google Cloud SDK using a .tar file

On general Linux x86_64, you can simply download an archived file of Google Cloud SDK and install as below.

#Linux 64bit
wget https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-347.0.0-linux-x86_64.tar.gz
tar xvf google-cloud-sdk-347.0.0-linux-x86_64.tar.gz

#64-bit arm
curl -O https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-348.0.0-linux-arm.tar.gz

#32-bit 
curl -O https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-348.0.0-linux-x86.tar.gz

Proceed to install Google Cloud SDK on Linux mint 20 | Ubuntu 20.04 as below:

$ cd google-cloud-sdk
$ ./install.sh
Welcome to the Google Cloud SDK!

To help improve the quality of this product, we collect anonymized usage data
and anonymized stacktraces when crashes are encountered; additional information
is available at <https://cloud.google.com/sdk/usage-statistics>. This data is
handled in accordance with our privacy policy
<https://cloud.google.com/terms/cloud-privacy-notice>. You may choose to opt in this
collection now (by choosing 'Y' at the below prompt), or at any time in the
future by running the following command:

    gcloud config set disable_usage_reporting false

Do you want to help improve the Google Cloud SDK (y/N)?  y


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

┌────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                 Components                                                 │
├───────────────┬──────────────────────────────────────────────────────┬──────────────────────────┬──────────┤
│     Status    │                         Name                         │            ID            │   Size   │
├───────────────┼──────────────────────────────────────────────────────┼──────────────────────────┼──────────┤
│ Not Installed │ App Engine Go Extensions                             │ app-engine-go            │  4.9 MiB │
│ Not Installed │ Appctl                                               │ appctl                   │ 21.0 MiB │
│ Not Installed │ Cloud Bigtable Command Line Tool                     │ cbt                      │  7.7 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.4 MiB │
│ Not Installed │ Cloud SQL Proxy                                      │ cloud_sql_proxy          │  7.6 MiB │
│ Not Installed │ Cloud Spanner Emulator                               │ cloud-spanner-emulator   │ 21.8 MiB │
│ Not Installed │ Emulator Reverse Proxy                               │ emulator-reverse-proxy   │ 14.5 MiB │
│ Not Installed │ Google Cloud Build Local Builder                     │ cloud-build-local        │  6.3 MiB │
│ Not Installed │ Google Container Registry's Docker credential helper │ docker-credential-gcr    │  1.8 MiB │
│ Not Installed │ Kustomize                                            │ kustomize                │ 25.9 MiB │
│ Not Installed │ Minikube                                             │ minikube                 │ 25.5 MiB │
│ Not Installed │ Nomos CLI                                            │ nomos                    │ 25.6 MiB │
│ Not Installed │ On-Demand Scanning API extraction helper             │ local-extract            │ 13.6 MiB │
│ Not Installed │ Skaffold                                             │ skaffold                 │ 17.1 MiB │
│ Not Installed │ anthos-auth                                          │ anthos-auth              │ 17.6 MiB │
│ Not Installed │ config-connector                                     │ config-connector         │ 48.7 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.4 MiB │
│ Not Installed │ gcloud app Python Extensions                         │ app-engine-python        │  7.7 MiB │
│ Not Installed │ gcloud app Python Extensions (Extra Libraries)       │ app-engine-python-extras │ 26.4 MiB │
│ Not Installed │ kpt                                                  │ kpt                      │ 11.7 MiB │
│ Not Installed │ kubectl                                              │ kubectl                  │  < 1 MiB │
│ Not Installed │ kubectl-oidc                                         │ kubectl-oidc             │ 17.6 MiB │
│ Not Installed │ pkg                                                  │ pkg                      │          │
│ Installed     │ BigQuery Command Line Tool                           │ bq                       │  < 1 MiB │
│ Installed     │ Cloud SDK Core Libraries                             │ core                     │ 19.2 MiB │
│ Installed     │ Cloud Storage Command Line Tool                      │ gsutil                   │  3.9 MiB │
└───────────────┴──────────────────────────────────────────────────────┴──────────────────────────┴──────────┘
To install or remove components at your current SDK version [347.0.0], run:
  $ gcloud components install COMPONENT_ID
  $ gcloud components remove COMPONENT_ID

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


Modify profile to update your $PATH and enable shell command 
completion?

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

The Google Cloud SDK installer will now prompt you to update an rc 
file to bring the Google Cloud CLIs into your environment.

Enter a path to an rc file to update, or leave blank to use 
[/home/lorna/.bashrc]:  
Backing up [/home/lorna/.bashrc] to [/home/lorna/.bashrc.backup].
[/home/lorna/.bashrc] has been updated.

==> Start a new shell for the changes to take effect.


For more information on how to get started, please visit:
  https://cloud.google.com/sdk/docs/quickstarts

Close your current terminal or start another one to realize the SDK changes.

Initialize Google Cloud SDK on Ubuntu | Linux Mint

Once you have installed Google Cloud SDK using any of the above described methods, initialize it by running the command below:

$ gcloud init
Welcome! This command will take you through the configuration of gcloud.

Your current configuration has been set to: [default]

You can skip diagnostics next time by using the following flag:
  gcloud init --skip-diagnostics

Network diagnostic detects and fixes local network connection issues.
Checking network connection...done.                                            
Reachability Check passed.
Network diagnostic passed (1/1 checks passed).

You must log in to continue. Would you like to log in (Y/n)? 

Enter Y to accept and head to your browser and login to your Google cloud user account. Once you login, you will be asked to choose the cloud project to use. You can opt to create a new one. Enter the appropriate number and press Enter

You are logged in as: [[email protected]].

Pick cloud project to use: 
 [1] keeweb-294218
 [2] myproject-01-181910
 [3] skilled-tangent-319513
 [4] Create a new project
Please enter numeric choice or text value (must exactly match list 
item):

Using Google Cloud SDK on Ubuntu | Linux Mint

There are various operations that you can perform with Google Cloud SDK to manage Google Cloud resources. Check the examples below:

To list all the installed components:

$ gcloud components list

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

┌────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                 Components                                                 │
├───────────────┬──────────────────────────────────────────────────────┬──────────────────────────┬──────────┤
│     Status    │                         Name                         │            ID            │   Size   │
├───────────────┼──────────────────────────────────────────────────────┼──────────────────────────┼──────────┤
│ Not Installed │ App Engine Go Extensions                             │ app-engine-go            │  4.9 MiB │
│ Not Installed │ Appctl                                               │ appctl                   │ 21.0 MiB │
│ Not Installed │ Cloud Bigtable Command Line Tool                     │ cbt                      │  7.7 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.4 MiB │
│ Not Installed │ Cloud SQL Proxy                                      │ cloud_sql_proxy          │  7.6 MiB │
│ Not Installed │ Cloud Spanner Emulator                               │ cloud-spanner-emulator   │ 21.8 MiB │
│ Not Installed │ Emulator Reverse Proxy                               │ emulator-reverse-proxy   │ 14.5 MiB │
│ Not Installed │ Google Cloud Build Local Builder                     │ cloud-build-local        │  6.3 MiB │
│ Not Installed │ Google Container Registry's Docker credential helper │ docker-credential-gcr    │  1.8 MiB │
│ Not Installed │ Kustomize                                            │ kustomize                │ 25.9 MiB │
│ Not Installed │ Minikube                                             │ minikube                 │ 25.5 MiB │
│ Not Installed │ Nomos CLI                                            │ nomos                    │ 25.6 MiB │
│ Not Installed │ On-Demand Scanning API extraction helper             │ local-extract            │ 13.6 MiB │
│ Not Installed │ Skaffold                                             │ skaffold                 │ 17.1 MiB │
│ Not Installed │ anthos-auth                                          │ anthos-auth              │ 17.6 MiB │
│ Not Installed │ config-connector                                     │ config-connector         │ 48.7 MiB │
│ Not Installed │ gcloud Alpha Commands                                │ alpha                    │  < 1 MiB │
│ Not Installed │ gcloud Beta Commands                                 │ beta 

List accounts whose credentials are stored locally

gcloud auth list

To install a component, use the syntax ‘gcloud components install <component name>‘. Example, if you want to install kubectl, use the command as shown:

gcloud components install kubectl

To update all the installed components to the latest available version of Cloud SDK

gcloud components update

To create a VM using gcloud command line, you will need to pass the specifications for the VM such as instance type, name and image. Check the example below:

export IMAGE_FAMILY="tf-latest-cu92"
export ZONE="us-west1-b"
export INSTANCE_NAME="my-instance"
export INSTANCE_TYPE="n1-standard-8"

And proceed to create the instance

gcloud compute instances create $INSTANCE_NAME \
        --zone=$ZONE \
        --image-family=$IMAGE_FAMILY \
        --image-project=mytestproject \
        --maintenance-policy=TERMINATE \
        --accelerator="type=ndivia-tesla-v100,count=8" \
        --machine-type=$INSTANCE_TYPE \
        --boot-disk-size=100GB \
        --metadata="install-"install-ndivia-driver=True"

To list created virtual machines, use the command below:

gcloud compute instances list 

To view the status of a specific instance, use the below command:

gcloud compute instances describe <INSTANCE_NAME>

That’s about the installation of Goolge Cloud SDK on Linux Mint 20 / Ubuntu 20.04 and some examples on how to use. I you already have a Google Cloud account, there is a lot you can benefit from using the SDK. I hope the few example will help you get started as you continue to explore the use of the SDK. Enjoy and don’t forget to check more interesting guides below:

Best Video Courses To Learn Google Cloud Computing

LEAVE A REPLY

Please enter your comment!
Please enter your name here