GCP101 Chapter 16 Using Gcloud from your local machine

Previous chapter | TOC | GCP | Next chapter

© Copyright 2018 Nickantony Quach. All rights reserved.

1 About the Google Cloud SDK

Google Cloud SDK is a set of tools that you can use to manage resources and applications hosted on Google Cloud Platform. These include the gcloud, gsutil, and bq command line tools. Tell me more

In the previous chapter, you used gcloud tool from your cloud shell, not from your local machine. In this chapter, you use gcloud tool from your local machine.

This page contains instructions for downloading and installing Google Cloud SDK. You should first install it on your local machine.

If you’re using Windows, ensure that you install using Windows 64-bit with Python bundled:

2 Using local Gcloud

The gcloud tool allows you to interact with your cloud resources. Do the following to experience its use on your local machine.

    1. From your local machine, run gcloud as an administrator.
    2. In the local shell console, if not already done, run the command, gcloud init, to initialize the tool.
    3. Run the shell command, gcloud config list, to access gcloud config info.
    4. Under the section, [core], the variable project should be set to your current project name.
    5. If not, run the shell command, gcloud config set project tb4gcp18a, where tb4gcp18a is the name of your current project.
    6. Run the shell command, gcloud config list, again to verify that its project value has been set correctly.
    7. Run the shell command as specified in the next line.
gcloud beta functions call datastore_setvalue --data={\"kind\":\"mytable1\",\"key\":\"myrow2\",\"value\":{\"mycolumn3\":\"mydata78\"}}
  1. If gcloud beta was not installed, you would get the message as shown in Appendix A, below.
  2. In that case, wait for the beta install to finish, then follow the instruction to try again. The gcloud beta install result message is shown in Appendix B, below.
  3. If the result is, “error: Endpoint read failed”, do it again and run the same shell command as specified in the previous line.
  4. The resulting output should be: “Entity mytable1/myrow2 saved.”
  5. Go to the Google Cloud Datastore.
  6. Search for mytable1. Myrow2 under mycolumn3 should now be: mydata78

Appendix A Gloud Beta Missing

You do not currently have this command group installed. Using it
requires the installation of components: [beta]

Restarting command:
$ gcloud components install beta

Installing component in a new window.

Please re-run this command when installation is complete.
$ C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\bin\..\lib\gcloud.py beta functions call datastore_setvalue --data '{kind:mytable1, key:myrow2, value:{mycolumn3:mydata78} }'

Appendix B Gcloud Beta Install Result Message

*** End of Chapter ***

Next chapter


© Copyright 2018 Nickantony Quach. All rights reserved. | Other books | Edit

Advertisements