To install the Google Cloud SDK on CentOS 8, you can follow these steps:
This walkthrough uses the tarball rather than a package repository, and that is a deliberate choice worth explaining. A tarball install pins you to one version until you decide otherwise, and it lets gcloud manage its own components. A package install hands both of those jobs to the system package manager instead. For a workstation where you want the SDK updating quietly alongside everything else, the repository is easier. For a build box or anywhere a version bump appearing on its own would be unwelcome, this is the better option.
Update the Package Repository:
Before installing any software, it’s a good practice to ensure that your package repository is up to date. Open a terminal and run the following command:
$ sudo dnf update Dependencies resolved. Nothing to do. Complete!
Nothing to do here, which is what a freshly updated system looks like. On a machine that has been sitting a while this takes considerably longer.
Download and Install the Google Cloud SDK:
You can download and install the Google Cloud SDK using the following commands:
# Create a directory for the installation (optional)
mkdir -p ~/Downloads
cd ~/Downloads
# Download the Google Cloud SDK installer
$ curl -O https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-447.0.0-linux-x86_64.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 179M 100 179M 0 0 3516k 0 0:00:52 0:00:52 --:--:-- 3594k
# Extract the downloaded archive
tar zxvf google-cloud-sdk-447.0.0-linux-x86_64.tar.gz
# Run the installer
$ ./google-cloud-sdk/install.sh
Welcome to the Google Cloud CLI!
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 CLI (y/N)? y
179MB, which surprises people. That is the full SDK: gcloud itself, gsutil for Cloud Storage, bq for BigQuery, and a bundled Python runtime so it does not depend on whatever version the system happens to ship.
Note that the extracted directory is the installation. Nothing gets copied into /usr, so wherever you unpack it is where it lives permanently. Somewhere sensible like your home directory or /opt is a better long-term home than a Downloads folder you might tidy up in six months.
The installer’s real job is the shell setup. It offers to add the SDK to your PATH and to enable command completion, both of which it does by appending to your shell profile. That is also why gcloud is not found immediately afterwards in the same terminal: the profile has not been re-read yet. Open a new shell, or source the profile, and it appears.
Replace the URL in the curl command with the latest version’s URL if a new version is available. You can find the latest version on the Google Cloud SDK Downloads page.
Initialize the Google Cloud SDK:
After installing, you’ll need to initialize the Google Cloud SDK by running the following command:
$ 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)? y
Go to the following link in your browser:
https://accounts.google.com/o/oauth2/.....
Enter authorization code: mPj9OzRzZLcbSrcrvzaBKOcrrhLZrObG-adhUA2
You are logged in as: [sample@gmail.com].
Pick cloud project to use:
[1] project-3311
[2] Enter a project ID
[3] Create a new project
Please enter numeric choice or text value (must exactly match list item): 1
Your current project has been set to: [kindy-34411].
Do you want to configure a default Compute Region and Zone? (Y/n)? y
This command will guide you through the setup process, including authentication and configuration.
Notice the flow there. Because a server has no browser, gcloud prints a URL, you authenticate somewhere that does, and paste the resulting code back. That is the standard way to authenticate a headless machine and it is worth remembering the first time you meet it.
The named configuration it creates, [default], is a bundle of account, project and region. You can create more and switch between them, which is the sane way to work across several projects without repeatedly checking which one is currently active.
For anything unattended, use a service account rather than a personal login. Automation authenticating as a human breaks when that human’s access changes, and it almost always carries broader permissions than the task requires.
(Optional) Install Additional Components:
Depending on your specific needs, you may want to install additional components or update the SDK. You can use the gcloud components command to manage components. For example, to install the kubectl command for Kubernetes, you can run:
$ gcloud components install kubectl Your current Google Cloud CLI version is: 447.0.0 Installing components from version: 447.0.0 ┌─────────────────────────────────────────────┐ │ These components will be installed. │ ├────────────────────────┬─────────┬──────────┤ │ Name │ Version │ Size │ ├────────────────────────┼─────────┼──────────┤ │ gke-gcloud-auth-plugin │ 0.5.6 │ 7.9 MiB │ │ kubectl │ 1.27.5 │ 98.0 MiB │ │ kubectl │ 1.27.5 │ < 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 ╔════════════════════════════════════════════════════════════╗ ╠═ Creating update staging area ═╣ ╠════════════════════════════════════════════════════════════╣ ╠═ Installing: gke-gcloud-auth-plugin ═╣ ╠════════════════════════════════════════════════════════════╣ ╠═ Installing: gke-gcloud-auth-plugin ═╣ ╠════════════════════════════════════════════════════════════╣ ╠═ Installing: kubectl ═╣ ╠════════════════════════════════════════════════════════════╣ ╠═ Installing: kubectl ═╣ ╠════════════════════════════════════════════════════════════╣ ╠═ Creating backup and activating new installation ═╣ ╚════════════════════════════════════════════════════════════╝ Performing post processing steps...done. Update done!
This is the part a package install cannot do, and the main practical argument for the tarball. Components live inside the SDK directory and gcloud manages them itself.
The gke-gcloud-auth-plugin coming along with kubectl is not incidental. Connecting kubectl to a GKE cluster needs that plugin to handle the authentication handshake, and installing kubectl through gcloud gets you both together rather than leaving you to work out why cluster access fails afterwards.
You can also update the SDK and its components with:
$ gcloud components update Beginning update. This process may take several minutes. All components are up to date.
Verify Installation:
You can verify that the Google Cloud SDK is correctly installed by running:
$ gcloud --version Google Cloud SDK 447.0.0 bq 2.0.98 bundled-python3-unix 3.9.16 core 2023.09.15 gcloud-crc32c 1.0.0 gke-gcloud-auth-plugin 0.5.6 gsutil 5.25 kubectl 1.27.5
Every component and its version, which is more useful than it looks. When something misbehaves, this output is the first thing to check, and it is what to quote if you end up asking anyone else about it.
The bundled-python3-unix line is worth noticing too. The SDK ships its own Python rather than using the system one, which is exactly why a distribution Python upgrade does not break gcloud.
This should display the installed version of the Google Cloud SDK.
Now you have the Google Cloud SDK installed on your CentOS 8 system, and you can use it to interact with Google Cloud Platform services and manage your cloud resources.
One last thing on the platform. CentOS 8 itself reached end of life at the end of 2021, so a machine still running it is not getting security updates. The SDK install here is unaffected and works the same way, but if this is a system you plan to keep, moving it to a supported successor is the more pressing job.
On a Debian or Ubuntu machine the apt repository is the easier path, and it hands updates to the system package manager: installing the Google Cloud SDK on Ubuntu 22.04.


