cherba
cherba

Reputation: 8980

Can I install and run multiple versions of gcloud (google cloud sdk) on the same machine?

Features and options in gcloud are sometimes deprecated/removed. If CI depends on it and refactoring is not an option while at the same time we need to use new features which come out in later releases can we have multiple versions of gcloud installed on same machines and used concurrently?

Upvotes: 4

Views: 1264

Answers (1)

cherba
cherba

Reputation: 8980

There are multiple ways to install Cloud SDK on your machine. For this probably simplest would be to download versioned package from https://cloud.google.com/sdk/downloads#versioned.

For example you can do

gsutil cp gs://cloud-sdk-release/google-cloud-sdk-VERSION-linux-x86_64.tar.gz .

where VERSION is you want to get (for example "161.0.0"). You could also use wget or curl or simply use browser to download the package for your platform.

Then unzip/untar into your desired location for example

mkdir -p ~/cloudsdk/161.0.0
tar xzf google-cloud-sdk-161.0.0-linux-x86_64.tar.gz -C ~/cloudsdk/161.0.0

repeat for some different version:

mkdir -p ~/cloudsdk/130.0.0
tar xzf google-cloud-sdk-130.0.0-linux-x86_64.tar.gz -C ~/cloudsdk/130.0.0

Now you can run gcloud via

~/cloudsdk/161.0.0/google-cloud-sdk/bin/gcloud components list

or

~/cloudsdk/130.0.0/google-cloud-sdk/bin/gcloud components list

Note both version will share same config directory. This is generally undesirable, because there could have been changes between versions in how they treat configuration. To force different Cloud SDK versions use different gcloud configurations set CLOUDSDK_CONFIG environment variable to point to different gcloud config directory. For example:

$ CLOUDSDK_CONFIG=~/.config/gcloud-legacy ~/cloudsdk/130.0.0/google-cloud-sdk/bin/gcloud

Upvotes: 6

Related Questions