misconfigured.net

Peter McInerney - Technology Leader (DevOps/SRE/Infrastructure/Platforms/Release Engineering)

Providing a consistent Developer Experience on Windows: Kubernetes + Tilt

Earlier this year I had a question asked of me to help provide a solution to help align process and tooling across their teams and platforms. The core teams were building a brand new platform with Cloud Native approach and with that the process to release small and release often.

However, for a segment of their assets they had a sole developer who they wanted to help bring into the same process and tooling as the rest of the development group.

The challenge: Provide a consistent and cohesive experience to everyone in the development organization

I had introduced the core development team to Tilt; something I’d been rolling out at my former employer to bring a production like environment to the local developers with a vision of failing fast and a tight feedback loop.

While the core team used OSX and leveraged a workflow of Gerrit and Jenkins with their applications finally being deployed in Kubernetes [GKE], this sole developer managed their code in git but did not have CI feedback or infrastructure as code applied to their applications. They also used Windows for their local development environment.

Luckily, they were on Windows 10 Pro, which meant we could run Docker Desktop (as this requires Hyper-V). We enabled the Linux Subsystem and with a few minutes of trickery provided the same flow and tooling as the remainder of the team.

Below we will invoke the tilt demo running on Windows

Enable Subsystem for Linux (WSL)

Open Powershell as administrator

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

Enter Y to restart Windows (when prompted)

Install Ubuntu

Invoke-WebRequest -Uri https://aka.ms/wsl-ubuntu-1804 -OutFile Ubuntu.appx -UseBasicParsing
Ubuntu.appx

When prompted – enter a username and password for this Ubuntu instance

Generate a ssh-key for this new machine (You may need to enable QuickEdit to be able to copy/paste, Right click on the top bar > Properties > Check QuickEdit)

ssh-keygen
cat ~/.ssh/id_rsa.pub´╗┐

Install Linuxbrew

The core team has instructions to leverage Homebrew: an amazing toolset for managing your OSX hardware. To ensure the instructions provided will run cross platform , I opted to use the newly provided Linuxbrew

sudo apt-get -y install build-essential curl file git
sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"
echo "eval \$($(brew --prefix)/bin/brew shellenv)" >> ~/.profile
source ~/.profile´╗┐

Install Docker Desktop (Windows)
Download and install the Docker Installer

Switch to the Ubuntu Terminal

sudo apt-get update
sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get -y install docker-ce
echo "export DOCKER_HOST=tcp://localhost:2375" >> ~/.bash_profile
source ~/.bash_profile

Kubernetes CLI

curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
ln -s /mnt/c/Users/USERNAME/.kube/ ~/
kubectl config use-context docker-for-desktop

Install Tilt (On Ubuntu)

curl -sL https://github.com/windmilleng/tilt/releases/download/v0.8.1/tilt.0.8.1.linux.x86_64.tar.gz | tar -xz tilt
sudo mv tilt /usr/local/bin/tilt

Because Tilt is an amazingly neat project and analytics aren’t enabled by default I strongly urge you to enable them to help out the development team.

tilt analytics opt in

The Windows user is now able to run the tilt command from their Ubuntu shell, consuming Kubernetes running on Windows natively. Code editedVisual Studio, as well as files saved/edited and processed via tilt automatically rebuild and restart the application.

tilt demo

Take advantage of their new UI for preview/logs and errors available at http://localhost:10350/ whilst Tilt is running!

Video Demo
Watch the video below for a demonstration of Tilt running on Windows leveraging the Windows Linux Subsystem (WSL).

Protected: The state of CI in 2019 (aka Jenkins is dead, long live Jenkins)

This content is password protected. To view it please enter your password below:

© 2019 misconfigured.net

Theme by Anders NorenUp ↑