kubernetes development for the impatient
Switch branches/tags
Nothing to show
Clone or download
Permalink
Failed to load latest commit information.
.circleci integration: upgrade the cluster (#627) Oct 25, 2018
cmd cmd: make tilt binary compatible with goreleaser (#612) Oct 24, 2018
docs demo: update narration text color (#714) Nov 14, 2018
integration integration: turn up timeouts a bit (#701) Nov 9, 2018
internal demo: update narration text color (#714) Nov 14, 2018
scripts Makefile: abstract out protobuf compilation into a separate repo (#668) Nov 2, 2018
synclet synclet: speed up the synclet build a lot and make synclet-dev work o… Oct 1, 2018
vendor tilt: add action logging (#704) Nov 12, 2018
.dockerignore synclet: speed up the synclet build a lot and make synclet-dev work o… Oct 1, 2018
.gitignore cmd: make tilt binary compatible with goreleaser (#612) Oct 24, 2018
.gitmodules Makefile: abstract out protobuf compilation into a separate repo (#668) Nov 2, 2018
.goreleaser.yml goreleaser: add macos binaries (#674) Nov 6, 2018
.python-version timing: a few simple tilt up cases (#116) Aug 21, 2018
DEVELOPING.md docs: intro page, space for more docs (#713) Nov 13, 2018
Dockerfile.base upgrade to go 1.11 (#601) Oct 23, 2018
Dockerfile.docs docs: intro page, space for more docs (#713) Nov 13, 2018
Dockerfile.docserver tilt: add a live-reloading docserver (#715) Nov 14, 2018
Dockerfile.synclet synclet: script to deploy synclet, dummy app (#287) Sep 11, 2018
Gopkg.lock tilt: add action logging (#704) Nov 12, 2018
Gopkg.toml vendor: update k8s libraries to 1.12.1 (#616) Oct 25, 2018
LICENSE readme: add license, badges (#17) Aug 8, 2018
Makefile docs: intro page, space for more docs (#713) Nov 13, 2018
README.md demo: update narration text color (#714) Nov 14, 2018
Tiltfile tilt: add a live-reloading docserver (#715) Nov 14, 2018
docserver.yaml tilt: add a live-reloading docserver (#715) Nov 14, 2018
hide_tbd_warning synclet: deploy as sidecar (#400) Sep 25, 2018
tilt-test.yaml tilt: I'm in ur tiltfile, tilting your tilt tests (#185) Aug 27, 2018

README.md

Tilt

Build Status GoDoc

Iterate on your microservice app

See it when it’s happy

See the problem when it isn’t

Click below to see a video of Tilt in action:

asciicast

Installing Tilt

Tilt binaries are available for MacOS and Linux

Download the latest Tilt command for your platform

Compiling from source

If you'd prefer to install Tilt from source,

  • Install go 1.11
  • Run go get -u github.com/windmilleng/tilt

Using Tilt

tilt up <service_name> starts a service and watches for changes.

tilt up --watch=false <service_name> starts the service once.

Tilt reads from a Tiltfile. A simple Tiltfile is below:

def backend():
  img = static_build('Dockerfile', 'gcr.io/companyname/backend')
  yaml = read_file('backend.yaml')
  return k8s_service(img, yaml=yaml)

Optimizing Tilt

Building with the Tiltfile above may be slow because it builds a new image each time.

With a Tiltfile that uses start_fast_build, Tilt is able to optimize your build so that it only runs the steps that have changed.

def backend():
  start_fast_build('Dockerfile', 'gcr.io/companyname/backend', '/go/bin/server')
  repo = local_git_repo('.')
  add(repo, '/go/src/github.com/companyname/backend')
  run('cd /go/src/github.com/companyname/backend && npm install .',
      trigger=['package.json'])
  run('go install github.com/companyname/backend/server')
  img = stop_build()
  img.cache('/root/.cache/go-cache')

  yaml = read_file('backend.yaml')
  s = k8s_service(img, yaml=yaml)
  s.port_forward(8080, 80)
  return s

Mill

written in a Mill, a dialect of python. It's based on starlark, using the implementation in go.

Mill Builtins

Mill comes with built-in functions.

static_build(dockerfile, ref, build_args?, context?)

Builds a docker image.

def static_build(dockerfile: str, ref: str, build_args: Dict[str, str] = {}, context: str = "") -> Image:
      """Builds a docker image.

    Args:
      dockerfile: The path to a Dockerfile
      ref: e.g. a blorgdev/backend or gcr.io/project-name/bucket-name
      build_args?: the build-time variables that are accessed like regular environment variables in the `RUN` instruction of the Dockerfile. See https://docs.docker.com/engine/reference/commandline/build/#set-build-time-variables---build-arg
      context?: The path to use as the Docker build context. Defaults to the Dockerfile directory.
    Returns:
      Image
    """

local_git_repo

Creates a repo from the git repo at path.

def local_git_repo(path: str) -> Repo

Repo

Represents a local code repository

class Repo:
  def path(path: str) -> localPath:
    """Returns the absolute path to the file specified at `path` in the repo.
    path must be a relative path.

    Args:
      path: relative path in repository
    Returns:
      A localPath resource, representing a local path on disk.
    """

start_fast_build

Initiates a docker image build that supports adds and runs, and that uses a cache for subsequent builds.

TODO(dmiller): explain how this is fast, and image vs container builds?

TODO(dmiller): explain the concept of the active build

def start_fast_build(dockerfile_path: str, img_name: str, entrypoint: str = "") -> None

add

Adds the content from src into the image at path dest.

def add(src: Union[localPath, Repo], dest: str) -> None

run

Runs cmd as a build step in the image. If the trigger argument is specified, the build step is only run on changes to the given file(s).

def run(cmd: str, trigger: Union[List[str], str] = []) -> None

Service

Represents a Kubernetes service that Tilt can deploy and monitor.

class Service
  def port_forward(local: int, remote: int = 0):
    """Sets up port-forwarding for the deployed container when it's ready.

    Args:
      local: The local port
      remote: The container port. If not specified, we will forward to the first port in the container
    """

global_yaml

Call this on the top level of your Tiltfile with a string of YAML.

We will infer what (if any) of the k8s resources defined in your YAML correspond to Services defined elsewhere in your Tiltfile (matching based on the DockerImage ref and on pod selectors). Any remaining YAML is global YAML, i.e. YAML that Tilt applies to your k8s cluster independently of any Service you define.

def global_yaml(yaml: string) -> None

k8s_service

Creates a kubernetes service that tilt can deploy using the the image passed in. Optionally, you may also pass the Kubernetes resource YAML. If the YAML is not passed, we expect to be able to extract it from global_yaml (see above).

def k8s_service(img: Image, yaml: string="") -> Service

Image

Represents a built Docker image

class Image
  def cache(path: string) -> None:
    """Caches the given path between image builds.

    Popular directories to cache include:
    - Go projects: /root/.cache/go-cache
    - NodeJS projects: /src/node_modules, /src/yarn.lock

    Args:
      path: The path to cache. May be a file or a directory.
    """

composite_service

Creates a composite service; tilt will deploy (and watch) all services returned by the functions in service_fns.

def composite_service(List[Callable[[], Service]]) -> Service

local

Runs cmd, waits for it to finish, and returns its stdout.

def local(cmd: str) -> str

read_file

Reads file and returns its contents.

def read_file(file_path: str) -> str

stop_build()

Closes the currently active build and returns a container Image that has all of the adds and runs applied.

def stop_build() -> Image

kustomize()

Run kustomize on a given directory and return the resulting YAML.

def kustomize(pathToDir: str) -> str

Developing

See DEVELOPING.md

Privacy

This tool can send usage reports to https://events.windmill.build, to help us understand what features people use. We only report on which tilt commands run and how long they run for.

You can enable usage reports by running

tilt analytics opt in

(and disable them by running tilt analytics opt out.)

We do not report any personally identifiable information. We do not report any identifiable data about your code.

We do not share this data with anyone who is not an employee of Windmill Engineering. Data may be sent to third-party service providers like Datadog, but only to help us analyze the data.

License

Copyright 2018 Windmill Engineering

Licensed under the Apache License, Version 2.0