Software engineering notes

Google Cloud workstation

Assumptions

Create project

We need a Google Cloud project to own workstation VM instances. It’s helpful to make it independent of other projects.

Create instance

In Google Cloud console:

  1. Nav to Compute Engine and create new micro instance
  2. Name “ubuntu”
  3. Region “us-west”
  4. Size “custom (1 vCPU, 4 GB memory)”, so we have enough memory to install things like Ruby and IntelliJ
  5. OS Ubuntu LTS
  6. Start instance
  7. Copy external IP address

SSH access

Enable laptop to connect to cloud instance, as described in the project-wide SSH keys documentation. In Google Cloud console:

  1. Search for “SSH key” and select “metadata”
  2. Copy public key contents from local machine using Text and paste into Cloud console
  3. Open Secure Shell on local machine, select key, paste IP address and connect

GitHub

Define an SSH key pair to enable communication with GitHub:

  1. Define SSH key pair, per github SSH key generation docs:
    ssh-keygen -t rsa -b 4096 -C '<project>.<instance>@<cloud provider>'
  2. Copy public key contents into GitHub settings

Vim

  1. Copy over `.vimrc` from dotfiles repo
  2. Launch vim and install plugins defined in vimrc: `:PlugInstall`

Desktop

The Chrome Remote Desktop (CRD) docs are pretty good, but assume you already have a desktop with Chrome running. For a cloud VM, we need a way to bootstrap without a desktop. A couple (12) Chrome support threads were helpful. Steps:

  1. Install lightweight window manager:
    sudo apt install -y xubuntu-desktop
  2. Download CRD:
    wget https://dl.google.com/linux/direct/chrome-remote-desktop_current_amd64.deb
  3. Install CRD:
    sudo dpkg -i chrome-remote-desktop_current_amd64.deb
  4. Define ~/.chrome-remote-desktop:
    exec /usr/sbin/lightdm-session "startxfce4"
    Note: misconfiguration of this file (including misnaming) results in “… Session process terminated … ” errors.
  5. Restart CRD to load the config:
    sudo /etc/init.d/chrome-remote-desktop restart
  6. Use http://remotedesktop.google.com/headless to generate the command required to register a host and set an access pin (credit), and then run this command on the workstationNote: we used to have to edit the Compute Engine instance firewall to enable udp:all and tcp:443,5222 open for ingress and egress, but this no longer seems required
  7. On the netbook, launch CRD app, select the host created above and enter the access pin you defined

Written by Erik

March 2, 2019 at 2:02 pm

Posted in tool

%d bloggers like this: