ultramcu - Fotolia


Crack open Google Cloud Shell for infrastructure management

Shell commands and Bash scripts have been a staple of system administration, and for those who still prefer that management approach, Cloud Shell on GCP might be worth a look.

Google Cloud Shell is considered the retro admin interface for Google Cloud Platform that works within your browser as an extension to the GCP management GUI. Although it won't be the preference of all cloud admins, there are reasons to use it.

Here's a look at the key features of Google Cloud Shell, how and where to use it and its connection to other GCP management tools.

Core features

Admins access Google Cloud Shell through the browser-based GCP GUI, not a client-side terminal application. Although traditionalists may balk at having to use the browser, a single click on the Google Cloud Shell icon sets up an entire environment, performing these tasks:

  • prompts GCP to spin up a temporary Google Compute Engine (GCE) instance to run commands, complete with 5 GB of persistent storage and automatic authorization for access to all your GCP Console projects and resources;
  • starts a command-line shell with a built-in code editor and preinstalled Google Cloud software development kit (SDK) that supports Java, Go, Python, Node.js, PHP and Ruby;
  • links to other tools, such as Bash shell, Emacs and Vim editors, as well as build and source code management utilities; and
  • provides a web preview feature that enables admins to run and view the output of web apps on the temporary GCE instance.

Quick Start

To launch Google Cloud Shell, log in to the GCP console, and click the Cloud Shell icon in the top toolbar. This opens a new frame and terminal console at the bottom of the browser window (see Figure 1).

Google cloud shell
Figure 1. Launch Google Cloud Shell from the GCP console.

Google Cloud Shell automatically creates a g1-small GCE instance -- a shared, non-dedicated core with 0.5 virtual CPU and 1.7 GB RAM -- to run the shell and other programs. It then terminates the instance after an hour of inactivity. The 5 GB persistent storage is used for a $HOME directory that holds configuration files, like .bashrc , any installed software and custom scripts that remain available between sessions and across GCP projects.

For tasks that require more CPU or memory, admins can temporarily accelerate the shell environment by using boost mode. However, excessive use of system or network resources can result in immediate termination of a shell session without warning.

Admins can invoke several Google Cloud Shell tools, like boost mode, via icons on its internal toolbar. Although it includes standard Unix text editors, the code editor (see Figure 2) is a relatively new feature that creates a development environment, based on Eclipse Orion, that provides convenient access to local files and directories. Admins can also use the web preview to view the output from locally instantiated web applications that output to a particular HTTP port.

Cloud Shell code editor
Figure 2. Access the Cloud Shell code editor

Relationship to the SDK and other tools

Google Cloud Shell includes the Google Cloud SDK, a set of command-line tools, including gcloud, to access and control GCP services. The SDK can be used with client libraries for languages, like Go, Java, Node.js, Python and Ruby, and to call GCP APIs in programs that can automate routine admin tasks.

If admins don't want to use a browser-based shell, they can install the SDK locally on Linux, Mac OS X and Windows systems with Python 2.7.x or greater. Then, they can connect to a GCE instance via Secure Socket Shell (SSH) to remotely manage a GCP environment. To reduce complications, admins should study documentation before they set up SSH access, particularly around key management, identity and access managemnt user rights and firewall rules.

Practical applications

Google Cloud Shell is useful for both developers and admins, particularly for testing code and scripts intended for cloud deployment. For example, programmers can clone a software repository in Git to a local shell for editing and testing. Other practical applications include:

  • Applying manual or programmatic deployments using the shell to create and manage GCE instances, Google Cloud SQL databases or Google cloud storage data.
  • Performing routine admin tasks with the Google Cloud SDK gcloud command-line tool. For example, a 10-line Bash script can list all the keys associated with the various projects in your service accounts -- something that would take a lot of manual pointing and clicking in the GUI console.
  • Acting as a testing and deployment platform for Google App Engine applications. For example, developers can use the shell to create a Ruby on Rails environment and application, test it using the web preview and deploy it to Google App Engine.

Google Cloud Shell is free for all GCP users but has a few limitations, such as usage caps, supported browsers and open ports for outgoing connections. Ensure that these limitations do not affect your enterprise.

Dig Deeper on Cloud infrastructure design and management

Data Center