The Development Environment#
There are many ways to build a cloud development environment. Using Ubuntu on the desktop gives you the most power and flexibility.
The development environment for the cloud is complex because Docker and Kubernetes work differently on the major OS platforms and because of the need to install tools from the cloud vendors. In this lab you will have to choose the environment for yourself based on your machine and level of setup effort. There are tradeoffs that I will discuss so that you can make the best choice. You are not locked in. You can change your mind at any time.
Google Cloud Shell and Editor#
Once you have access to Google Cloud Console you’ll be able to access the Cloud Shell Editor as shown in class. As you can see from the picture below the Cloud Shell Editor is similar to vscode. It’s based on Apache Thea, a close cousin of vscode.
The editor runs on a Linux VM with all of the software installed. The editor is all you need for the course and has some real advantages, like being available wherever you need it. The disadvantage of the cloud shell editor is that it’s slower and less responsive than running vscode on your own machine. The VM that runs the cloud shell editor is quite limited so you may not be able to build and run larger Docker containers.
Resetting the Cloud Shell Environment#
If you have used the Cloud Shell before and you want to start fresh you can reset your home directory in the Cloud Shell. This operation cannot be undone!
Developing using a VM#
Developing on your own computer is the most flexible and fastest way to use the cloud. Unless you’re using Ubuntu (or another Debian derivative) you will also need an Ubuntu VM. On your own computer install:
Create an Ubuntu VM#
Note
In class I demonstrate how to do this using Google Cloud Console.
An Ubuntu VM is a good choice as a development machine. Setting up a VM to use on Google is easy. Google Compute Engine has a free tier that allows you to run an e2-micro
instance with a 30 GB
disk for free.
Run this gcloud
command to quickly create a dev VM:
$ gcloud compute instances create devbox \
--zone us-central1-a \
--machine-type=e2-micro \
--create-disk=device-name=devbox,size=30 \
--image-project=ubuntu-os-cloud --image-family=ubuntu-2204-lts
After your machine has been created make sure you have SSH keys installed:
$ gcloud compute config-ssh
You should now be able to use ssh/scp with your instances.
For example, try running:
$ ssh devbox.us-central1-a.cis-92-21434
Connect with vscode#
After setting up SSH check the remote systems explorer in vscode. You should see “devbox”. You might have to press the “reload” button. Selecting the devbox will open a new vscode window. That’s your development environment! Follow the instructions for setting up Ubuntu in this document.
Configure Ubuntu#
Follow these steps after connecting to your Ubuntu VM with vscode.
Authenticate your VM#
You have to authenticate your VM just like you authenticated your own computer. Do this with the gcloud
command:
$ gcloud auth login
Follow the instructions.
Create a Project and Enable Billing#
Follow the instructions to create a project using the console (not the command line). The GUI will prompt you for a billing account, be sure to select your “Billing Account for Education” so that you use the credits you received through class.
Set the Default Project, Region and Zone#
It helps to have a default regions and zone. If you don’t have one set there has to be a --region
and --zone
argument to most gcloud
commands. Here’s an inexpensive choice:
$ gcloud config set project your-project-id
$ gcloud config set compute/region us-central1
$ gcloud config set compute/zone us-central1-b
Make Sure curl
is Installed#
The curl
program must be installed and is used by the next steps.
$ sudo apt update
$ sudo apt install curl
Install Pip#
$ sudo apt install -y python3-pip
Install GIT#
$ sudo apt install git
Install Docker#
$ sudo apt install docker.io
In order to use Docker you need to add yourself to the docker
group:
$ sudo usermod -aG docker $USER
Note
You have to logout and login again to assume the docker
group.
Install Podman (Optional)#
Podman is a replacement for Docker that doesn’t need special privileges. Podman works differently than Docker so not every docker
command has an equivalent podman
command, but most commands are compatible.
$ sudo apt install podman