Learn how to – How to install gcloud GCP cli on Apple M1 macOS.
In this brief tutorial, we are going to setup “gloud” in our local macOS M1 laptop so that we can find it easy to administer Google Cloud Platform without getting out of the terminal where warm blood always runs with pleasure. Searching and clicking all over the the GCP console can be quite exhausting and time consuming. If you feel the same way, then installing “gcloud” is our panacea. It comes with other tools as well such as “gsutil” to manage your Google Storage buckets, “kubectl” to manage your Kubernetes cluster (GKE) as well as “bq” to manage Big Query.
Hoping that that was enough motivation, we can start provisioning our tool so that we can go forward and start utilising it right away. Let us begin the installation.
Step 1: Fetch Google Cloud SDK
Google Cloud SDK are tools and libraries for interacting with Google Cloud products and services. Examples include: “gcloud”, “gsutil”, and “bq” among others. To get them installed, let us fetch them first in this step then we can comfortably proceed with the installation. Make sure you have wget installed.
macOS Apple M1
wget https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-374.0.0-darwin-arm.tar.gz
After the tarball has been dropped in our home directory or elsewhere, extract it as follows.
tar -xvzf google-cloud-sdk-*-darwin-arm.tar.gz
macOS Intel 64-bit
Download archive file
wget https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-374.0.0-darwin-x86_64.tar.gz
Extract the file
tar -xvzf google-cloud-sdk-*-darwin-x86_64.tar.gz
Step 2: Install the GCP SDK on Apple M1 macOS
Navigate into the new directory created after extracting the files in the previous step. Therein there is a script known as “install.sh” by google that we can leverage to place the binary in PATH.
cd google-cloud-sdk
./install.sh
Once you execute the script, you will get the following prompt
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
You can choose to say yes or no by typing in y or n.
You will get the following after that. Some sort of a chart that displays the components that have been installed and others that you can consider installing.
Your current Cloud SDK version is: 374.0.0
The latest available version is: 374.0.0
┌────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Components │
├───────────────┬──────────────────────────────────────────────────────┬──────────────────────────┬──────────┤
│ Status │ Name │ ID │ Size │
├───────────────┼──────────────────────────────────────────────────────┼──────────────────────────┼──────────┤
│ Not Installed │ App Engine Go Extensions │ app-engine-go │ 4.8 MiB │
│ Not Installed │ Appctl │ appctl │ 18.5 MiB │
│ Not Installed │ Cloud Bigtable Command Line Tool │ cbt │ 7.5 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.7 MiB │
│ Not Installed │ Cloud SQL Proxy │ cloud_sql_proxy │ 7.4 MiB │
│ Not Installed │ Emulator Reverse Proxy │ emulator-reverse-proxy │ 14.5 MiB │
│ Not Installed │ Google Cloud Build Local Builder │ cloud-build-local │ 6.2 MiB │
│ Not Installed │ Google Container Registry's Docker credential helper │ docker-credential-gcr │ │
│ Not Installed │ Kustomize │ kustomize │ 7.6 MiB │
│ Not Installed │ Minikube │ minikube │ 25.9 MiB │
│ Not Installed │ Nomos CLI │ nomos │ 24.4 MiB │
│ Not Installed │ On-Demand Scanning API extraction helper │ local-extract │ 12.5 MiB │
│ Not Installed │ Skaffold │ skaffold │ 17.1 MiB │
│ Not Installed │ anthos-auth │ anthos-auth │ 18.0 MiB │
│ Not Installed │ config-connector │ config-connector │ 45.2 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.7 MiB │
│ Not Installed │ gcloud app PHP Extensions │ app-engine-php │ 21.9 MiB │
│ Not Installed │ gcloud app Python Extensions │ app-engine-python │ 7.8 MiB │
│ Not Installed │ gcloud app Python Extensions (Extra Libraries) │ app-engine-python-extras │ 26.4 MiB │
│ Not Installed │ kpt │ kpt │ 12.8 MiB │
│ Not Installed │ kubectl │ kubectl │ < 1 MiB │
│ Not Installed │ kubectl-oidc │ kubectl-oidc │ 18.0 MiB │
│ Not Installed │ pkg │ pkg │ │
│ Installed │ BigQuery Command Line Tool │ bq │ < 1 MiB │
│ Installed │ Cloud SDK Core Libraries │ core │ 20.7 MiB │
│ Installed │ Cloud Storage Command Line Tool │ gsutil │ 8.1 MiB │
└───────────────┴──────────────────────────────────────────────────────┴──────────────────────────┴──────────┘
To install or remove components at your current SDK version [374.0.0], run:
$ gcloud components install COMPONENT_ID
$ gcloud components remove COMPONENT_ID
To update your SDK installation to the latest version [374.0.0], run:
$ gcloud components update
Modify profile to update your $PATH and enable shell command completion?
## Enter a y here
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.
## You can choose a different PATH here or just use the default
Enter a path to an rc file to update, or leave blank to use [/Users/johnkibet/.zshrc]:
Backing up [/Users/johnkibet/.zshrc] to [/Users/johnkibet/.zshrc.backup].
[/Users/johnkibet/.zshrc] 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
As you have been advised in the prompt above, start a new terminal session so that changes we have made so far can take effect and we can proceed to start using “gcloud”.
NOTE: You can install other components thereafter. For example for us, we need kubectl. To install kubectl, proceed as follows
$ gcloud components install kubectl
WARNING: The ARM versions of the following components are not available yet, using x86_64 versions instead: [kubectl].
Your current Cloud SDK version is: 374.0.0
Installing components from version: 374.0.0
┌─────────────────────────────────────────────┐
│ These components will be installed. │
├────────────────────────┬─────────┬──────────┤
│ Name │ Version │ Size │
├────────────────────────┼─────────┼──────────┤
│ gke-gcloud-auth-plugin │ 0.1.1 │ 3.3 MiB │
│ kubectl │ 1.20.8 │ < 1 MiB │
│ kubectl │ 1.20.8 │ 89.0 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!
Step 3: Initialize gcloud cli on Apple M1 macOS
Then after that, initialise “gcloud” by running the “gcloud init” command. The command will ask you to login to your GCP account. Key in a “y” if you already have an account. After that you will be redirected to your default browser where you will enter your GCP Account credentials for login. Ensure that you give “gcloud” the permissions it needs by hitting “Allow” as shared in the screenshot below.
This will be the sample terminal output.
$ 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
Your browser has been opened to visit:
https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=34556941664.apps.googleusercontent.com&redirect_uri=http%4A%2F%4Flocalhost%4A8085%2F&scope=openid+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fappengine.admin+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcompute+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Faccounts.reauth&state=5Yx7fKbUhGbVOus8RfwUhRMxbDFQNn&access_type=offline&code_challenge=XXXX-FFFGGDBSGBXXXXpWCi5DFGSEGSBFSGHERGNWO_XXX&code_challenge_method=S256
You are logged in as: [john.kibet@xxx.com].
Pick cloud project to use:
[1] project-demo
[2] Create a new project
Please enter numeric choice or text value (must exactly match list item): 1
Your current project has been set to: [project-demo].
Your project default Compute Engine zone has been set to [us-central1-a].
You can change it by running [gcloud config set compute/zone NAME].
Your project default Compute Engine region has been set to [us-central1].
You can change it by running [gcloud config set compute/region NAME].
Created a default .boto configuration file at [/Users/johnkibet/.boto]. See this file and
[https://cloud.google.com/storage/docs/gsutil/commands/config] for more
information about configuring Google Cloud Storage.
Your Google Cloud SDK is configured and ready to use!
* Commands that require authentication will use john.kibet@XXXX.com by default
* Commands will reference project `project-demo` by default
* Compute Engine commands will use region `us-central1` by default
* Compute Engine commands will use zone `us-central1-a` by default
Run `gcloud help config` to learn how to change individual settings
This gcloud configuration is called [default]. You can create additional configurations if you work with multiple accounts and/or projects.
Run `gcloud topic configurations` to learn more.
Some things to try next:
* Run `gcloud --help` to see the Cloud Platform services you can interact with. And run `gcloud help COMMAND` to get help on any gcloud command.
* Run `gcloud topic --help` to learn about advanced features of the SDK like arg files and output formatting
If everything goes on well, you should now be able to run “gcloud”, “gsutil”, and other installed commands against your GCP project that you selected from the initial prompts above. As an example, we can generally list buckets as follows
gsutil ls
Step 4: Test your installation by running commands
gcloud provides a comprehensive cli tool to view, create, delete and manage GCP resources. You no longer need to move out of you terminal to check your cloud resources anymore. Some few commands you can run to see hoe it works are listed below:
gcloud sql instances list
End Notes
Now we have the capability of running commands in our local machine and get things moving in the cloud. It is way convenient, aligns to how you work and the good part is that you no longer need to move away from your terminal just to see resources in your project.
Lastly, we hope it worked for you and better ways of implementing the same is highly welcome. We appreciate your continued generosity, comments, readership and frequent visitation. Keep the conversation going as you continue to keep safe. Enjoy the rest of your day!
Other guides you will find interesting include:
- Best Google Cloud Certification Guides & Books
- Be aware: Examining Cloud Backup Solutions by AWS vs. Azure vs. Google Cloud
- Best Books To Learn Cloud Computing
- Best Books To Master Azure Cloud Platform
Leave a Reply
You must be logged in to post a comment.