How to develop with Tilt

How to use Tilt to leverage developing towards Bifrost

Linux/MacOS Installation

Prerequisites

Make sure the following is installed

  • Docker Desktop
  • Python 3

Installing Dependencies

Brew - MacOS/Linux
PacMan - Linux
brew install derailed/k9s/k9s kind python mutagen-io/mutagen/mutagen tilt-dev/tap/ctlptl

Needed for Linux (if not using brew):

sudo apt-get install python3 python3-pip & sudo pip3 install mutagen

Windows Installation

Prerequisites

Make sure the following is installed:

  • Scoop
  • Python3
  • Docker Desktop

Set the execution policy for Windows, by opening Windows Powershell and running:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned

Install Dependencies

Make sure scoop is up to date:

cmd
scoop bucket add main

Add Tilt bucket to scoop:

cmd
scoop bucket add tilt-dev https://github.com/tilt-dev/scoop-bucket

Install dependencies:

cmd
scoop install main/kind tilt-dev/ctlptl k9s main/mutagen

Installing Tilt

Tilt isn't available for scoop, so you have to download it directly from source:

powershell
iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/tilt-dev/tilt/master/scripts/install.ps1'))
#### Prerequisites
::alert
Make sure the following is installed:
- Scoop
- Python
- Docker Desktop
::

#### Install
Set the execution policy for Windows,by opening `Windows Powershell` and run `Set-ExecutionPolicy -ExecutionPolicy RemoteSigned`
Things needed to set up on Windows
TLDR to install all packages;
1. Make sure Scoop, Python and Docker Desktop
2. Open application `Windows Powershell` and run `Set-ExecutionPolicy -ExecutionPolicy RemoteSigned`
3. `scoop bucket add main
scoop install main/kind ctlptl k9s main/mutagen`
4. Install Tilt `iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/tilt-dev/tilt/master/scripts/install.ps1'))`
5. Make sure to restart all terminals/IDE's so the installed packages are recognised
6. Set up cluster: ctlptl create cluster kind --registry=ctlptl-registry 
7. Set up Git repository (read the final stretch part further down)

Detailed instructions with doc links:

  • Scoop package manager https://scoop.sh/ (remember to run scoop bucket add main to add package registry)
  • Docker Desktop https://www.docker.com/products/docker-desktop
  • Python 3 (needed for Tilt): Usually it's scoop install main/python however, scoop didn't set up the command properly on Windows, so best is just to use the desktop installer for Python
  • Kind

Scoop: scoop bucket add main scoop install main/kind

docs: https://github.com/kubernetes-sigs/kind/releases releases: https://kind.sigs.k8s.io/docs/user/quick-start/

To set up Kind, you can do (make sure to restart/refresh the terminal after installing tools to prevent path errors): ctlptl create cluster kind --registry=ctlptl-registry

Use k9s or kubectl to check cluster scoop install k9s (when running the k9s command, press 0 to see all pods`

  • Tilt: For Tilt you need to set a ExecutionPolicy in Windows, open the Windows Powershell app and run Set-ExecutionPolicy -ExecutionPolicy RemoteSignediex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/tilt-dev/tilt/master/scripts/install.ps1')) https://docs.tilt.dev/

(don't listen to this, I got several errors after trying to switch back, you might be able to do it after installing everything) After running the command, you can switch back to using a more restrictive policy Set-ExecutionPolicy -ExecutionPolicy Restricted (default for Windows)

Final stretch:

Install the relevant Git repository, set up an application secret ( https://frost.code.bitkraken.no/user/settings/applications ) to pull down the repository. Save the secret (i.e your private 1pass, don't share with other team members, they can create their own and we should keep them separated) so you can use it on other things later.

You probably need pnpm (and node) installed Invoke-WebRequest https://get.pnpm.io/install.ps1 -UseBasicParsing | Invoke-Expression https://pnpm.io/installation Remember to restart your IDE (vscode at least) after installing pnpm so it's recognized in the terminal

Make sure that you've logged in to the package registry docker login frost.code.bitkraken.no (some of the Tilt config uses the credentials on your host machine, not the ones passed into Tilt)

Recommended vscode extensions:

  • Tilt id: Tchoupinax.tilt

Finally you can run Tilt up in the folder of a project. The current version at the time of the Tilt project doesn't wait for everything to come up/might miss some resources like CRDs from Mariadb, secrets etc. so you might have to restart the wordpress deployment a few times, expect some errors object is being deleted: users.k8s.mariadb.com "default-wordpress-user" already exists, just wait for the object to be deleted before restarting. This can be fixed by separating out db handling.

In prod it's a non-issue since all the required resources already exists. It can be fixed for Tilt as well, but the current local dev is more intended a prototype/see if the workflow works, kinks can be fixed later.