loading...
Cover image for Setting Up Google Cloud SDK For GCP On Arch/Manjaro Linux

Setting Up Google Cloud SDK For GCP On Arch/Manjaro Linux

nabbisen profile image Heddi Nabbisen Updated on ・4 min read

Intro

Manjaro Linux, based on Arch Linux, is my favorite Linux distribution for development.
This is because of its rolling release and AUR [Arch User Repository] -- a pretty large repository and useful packages.

GCP [Google Cloud Platform] is also wonderful for cloud computing.
It gives both service power and cost validity to startups.

Summary

In order to manage GCP from the command line, Google provides Google Cloud SDK.

This article shows how to set up GCP management environment on Arch/Manjaro Linux.

* note : The official Linux packages are available on Debian/Ubuntu and Redhat/CentOS (except Fedora).

✿ ✿ ✿

Step 1: Account Activation

First of all, we must have a Google Cloud account.
Free trial is available.
Its free service is listed here.

* note : we can/needn't create a project at this time.

Step 2: google-cloud-sdk Installation

Next, we need to install "google-cloud-sdk" package.
AUR package is available.

* note : Or we can choose manual installation by following the official quickstart tutorial of Google Cloud SDK for Linux. The tool version might be fixed this way.

Open terminal and type like this:

$ git clone https://aur.archlinux.org/google-cloud-sdk.git

$ cd google-cloud-sdk/
$ # pkgbuild is necessary
$ makepkg -si
$ # authenticate for installation if required

$ # remove resource after installation
$ cd ../
$ rm -rf google-cloud-sdk/

Step 3: Initialization

Here, just type gcloud init and a couple of the following steps on terminal will bring us to completion 😉

Like this:

$ 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.
The Reachability Check passed.
Network diagnostic (1/1 checks) passed.

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

...

# authorization via web browser will be required

...

You are logged in as: [{% your@account %}].

Pick cloud project to use: 
 [1] {% your-project if exists %}
 [2] Create a new project
$ Please enter numeric choice or text value (must exactly match list 
item):  1 # or you can create a new project by selecting "2"

Your current project has been set to: [{% your-existing-project %}].

$ Do you want to configure a default Compute Region and Zone? (Y/n)?  n

Created a default .boto configuration file at [/home/{% your-name %}/.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 {% your@account %} by default
* Commands will reference project `{% your-project %}` 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 -h` to learn about advanced features of the SDK like arg files and output formatting
✿ ✿ ✿

Conclusion

Now gloud / gsutil commands are in our hands 😆

Basic Commands & References

Let's use gcloud basic commands:

$ # show some info
$ gcloud auth list
$ gcloud config list
$ gcloud info

$ # show help
$ gcloud help

gcloud reference is here.

And then, let's go ahead to gsutil:

$ # show some info
$ gsutil ls

$ # show help
$ gsutil help

gsutil reference is here.

Usage Example #1

One of the most simple command examples is perhaps managing vm instances.

$ gcloud compute instances start {% instanc-name %}
$ gcloud compute instances stop {% instanc-name %}

Their details are here: start and stop.

Usage Example #2

Now we can manage project objects.
For example, when creating custom vm image, these commands are useful:

$ # to add resource
$ gsutil cp -a public-read {% local-image.tar.gz %} gs://{% bucket-name %}/{% server-image %}.tar.gz
$ # to remove resource
$ gsutil rm gs://{% bucket-name %}/{% server-image %}.tar.gz

$ # to create vm image
$ gcloud compute --project {% project-name %} images create {% vm-name %} --source-uri gs://{% bucket-name %}/{% server-image %}.tar.gz
$ # to delete vm image
$ gcloud compute --project {% project-name %} images delete {% vm-name %}

Their details are here: gsutil cp, gsutil rm and gcloud compute.

There are also a gsutil quickstart.

✿ ✿ ✿

Thank you very much for your reading.
Happy coding 😃

Discussion

pic
Editor guide
Collapse
clarkmcc profile image
Collapse
nabbisen profile image
Heddi Nabbisen Author

Hi, Clark
You are welcome 😉
Thank you, too, for your comment.