Google Chromebooks and Cloud Shell for Classrooms

Workshops are about half of what we do here at SuperOrbital – building and consulting on cloudy infrastructure makes up the other half. One of the most overlooked aspects of making a smooth and enjoyable training experience is the student development environment. Making sure the student’s workstations and cloud environments are identical, fully compatible with the workshop labs, and are easy to use isn’t an easy task.

We participated in a series of hour long workshops at the most recent Cloud Foundry Summit, where this challenge was even more interesting. We had to come up with a mobile classroom that could be quickly and easily wiped and recreated during the five minute break between workshops. Casey West (Google’s resident yoga expert) was kind enough to lend us a dozen Chromebooks. Combined with the Google Cloud Shell, these proved the perfect solution.

Why Chromebooks

Chromebooks present a number of advantages when used in a classroom setting:

  • They’re close to disposable.
  • They’re lightweight, which is useful for bringing to in-house classrooms.
  • They use google for authentication, meaning students logged into the Chromebook are automatically logged into the GCP console.
  • The models we use have touch screens, which is a surprisingly useful feature for the instructor when giving a student a quick pointer to get them going on a lab.

Combine them with the Google Cloud Shell, and you have a really slick student experience.

What’s the Google Cloud Shell?

Every Google Cloud Account comes with a free persistent terminal built right into your GCP Console. You launch it by clicking on the Activate Google Cloud Shell icon at the top right corner of your console:

Start Cloud Shell

Clicking that icon brings up a panel at the bottom of your console with a running bash prompt:

Cloud Shell

Let’s go over some great and subtle aspects about this terminal.

Tmux

For one, tmux is launched for you automatically. For those who aren’t yet familiar with this tool, it’s a terminal multiplexer that enables terminals to be created, accessed, and controlled from a single screen. This means you can create vertical and horizontal splits, multiple windows and more. It’s also designed to be detached from the controlling screen, which means your terminal session will survive if you close the browser tab, put your laptop to sleep, or suffer from an airplane WiFi connection.

Tmux

Adding tmux was a great move on Google’s part, but they made it even better. If you click the plus sign on the terminal tab bar, then you’ll get a new tab with a second bash prompt, which is integrated into tmux as another window.

Again, since tmux is designed to survive when detached, your tabs will survive as well.

Orion Cloud Editor

For those who aren’t died-in-the-wool terminal junkies, the Cloud Shell also comes with the Eclipse Orion editor integrated as a beta feature. You launch it by clicking on the pencil icon on the terminal tab bar:

Orion Launch

Doing that brings up a more than serviceable IDE with syntax highlighting, splits, previews and more:

Orion

Easy Authorization

The final feature that’s incredibly useful for our workshops is that the terminals come pre-authorized against GCP. That means you can run the gcloud command line tool without first doing the OAuth dance. Just one more hoop that our students don’t have to jump through.

We’ll stop there, but feel free to read about the rest of the Cloud Shell features.

Persistence

It’s important to point out that the Cloud Shell terminal and all of the data in your home directory is persistent, but the running VM behind the terminal is not. What does that mean? When you launch the Cloud Shell terminal, GCP provisions a VM, mounts the persistent disk that contains your home directory, and launches bash. You can see this for yourself by running the mount command:

$ mount | grep /home
/dev/sdb1 on /home type ext4 (rw,relatime,discard,data=ordered)

$ df -h | grep /home
/dev/sdb1       4.8G  240M  4.3G   6% /home

GCP reserves the right to re-provision the underlying VM at any time (it does this, for example, when you request a 24 hour speed boost). When the VM is re-provisioned, any software or modifications you’ve made disappear. The upshot is that any custom software should be installed in your home directory. You can also see above that you only get 5GB of space in your home directory, so you should exercise some amount of restraint in what you install.

Provisioning

We can combine the above with a git-backed home directory to provide our students with a fully configured terminal environment and a quick and easy way to reset it in case they get in a bind.

First, we need a private git repository that contains all of the training material and the student dotfiles such as .bashrc and .profile. The repo should also include a bin directory, which is placed at the front of the student’s $PATH, and which contains all of the statically compiled binaries the students might need (such as kubectl, cf, bosh, terraform, etc). These binaries can get quite large, so we use git-lfs to store them (we’ll write about that more in a later post).

We also provide a nuke script, which will use git to completely reset the student’s home directory, and pull down any new changes from Github:

#!/usr/bin/env bash

set -euo pipefail

if [[ ! -v CLOUD_SHELL ]]; then
  echo "This script removes all changes from a git-backed"
  echo "cloud-shell home directory."
  echo
  echo "Since I don't see the \$CLOUD_SHELL variable"
  echo "defined, I don't believe we're in a Cloud Shell."
  echo
  echo "Cowardly refusing to proceed."
  exit 1
fi

export GIT_SSH_COMMAND='ssh -o StrictHostKeyChecking=no'

git clean -df
git reset --hard
git lfs install
git pull
git lfs checkout

This script can be run by the student, or by an instructor who has access to all of the GCP accounts. This makes it easy to reset all of the accounts in between classes:

#!/usr/bin/env bash

set -euo pipefail

for i in $(seq 20); do
  gcloud --account="student$i@superorbit.al" \
         --project="project$i" \
         alpha cloud-shell ssh --command="nuke" &
done
wait

Git Workflow

All of this has the added bonus of allowing students to use familiar git commands and workflows during the workshops. Students can snapshot their progress and checkout branches while they experiment, giving them even more of a safety net.

Other Cloud Providers

While we’re huge fans of the Google Cloud Platform for a number of reasons, we often give training on AWS and other clouds as well. In those situations, we end up provisioning our own infrastructure and recreating a lot of the work that the GCP engineers have already provided for us.

Closing Thoughts and Future Directions

While this workflow has proven itself in our classrooms, there is room for improvement.

For one, we’d like to see Orion upgraded and expanded. As far as we can tell, GCP provides us with version 8, while 17 is the latest release.

Another improvement, of course, would be to allow customization of the underlying VM, which would remove the need to keep software in the home directory.

Similarly, we’d like to see an option to increase the home directory size beyond 5GB.

Even without these changes, we’re very happy with the combination of Google Chromebooks and the Google Cloud Shell for an outstanding student experience in our workshops.

Let us know if your team would like to experience a SuperOrbital workshop, or if you’re in need of Kubernetes, Terraform or Cloud Foundry engineering expertise.

Get these articles and more right in your inbox.
That doesn't look like a valid email.
Please provide a name.

I'll never share your information with anyone else, and unsubscribing is easy and reliable.