Back to Blog
    8 min read

    Rapid K8s Deployment in Local with Tilt

    Hardik Shah
    Hardik ShahCloud Architect & AWS Expert
    KubernetesDevOpsMicroservicesDevelopmentTiltDockerLocal DevelopmentHot ReloadLive UpdatesContainer OrchestrationDeveloper ExperienceCI/CD
    Rapid K8s Deployment in Local with Tilt

    Most applications today aren't one service. They are several microservices, a database, a message queue and a pile of dependencies, all running on Kubernetes. That setup works well in production. On a laptop it makes every code change slow.

    The microservices development problem

    Where the time goes

    Every change to one service means some or all of these steps:

    • Build and rebuild container images for each service
    • Push images to registries
    • Apply Kubernetes manifests
    • Set up port forwarding for each service
    • Monitor logs across multiple terminals
    • Restart services when dependencies change
    • Maintain consistency between local dev and production environments

    That can take minutes for each code change, which kills the quick feedback loop developers rely on. It gets worse with 4, 5 or 10+ microservices in the stack.

    Tilt: the development environment as code

    Tilt automates the code-build-deploy-test cycle for teams deploying to Kubernetes. It treats your development environment as code: you define, version and share the whole dev stack in one configuration file called a Tiltfile.

    How Tilt works

    Smart rebuilds and dependency tracking

    Tilt doesn't rebuild everything on every change. It tracks dependencies between your services, images and Kubernetes resources, so a change to a frontend file rebuilds only the frontend service and leaves the backend alone.

    Live updates: hot reload for Kubernetes

    Tilt's biggest time saver is live updates. Instead of rebuilding the image and redeploying pods for every change, Tilt syncs changed files straight into running containers. Feedback drops from minutes to seconds.

    With Python or JavaScript, changes show up almost instantly. With a compiled language like Go, Tilt syncs the binary and restarts the process inside the existing container, which is still much faster than a full rebuild.

    One dashboard for every service

    Tilt has a web dashboard for the whole environment. Instead of a terminal window per service, you get status, logs and errors for every service on one page.

    Understanding Tiltfiles

    Tiltfile basics

    A Tiltfile is written in Starlark, a Python-like dialect, so it reads like a short script. The basic building blocks are:

    • docker_build(): how to build container images
    • k8s_yaml(): which Kubernetes manifests to deploy
    • k8s_resource(): per-service settings like port forwarding
    • live_update: rules for fast in-place updates

    ShopZone example: a real configuration

    Here is how ShopZone uses Tilt for its microservices. The main Tiltfile just pulls in the others:

    python
    # Main Tiltfile for ShopZone E-commerce Store
    
    # MySQL Database
    include('./helm/mysql/Tiltfile')
    
    # Frontend
    include('./frontend/Tiltfile')
    
    # Backend Services
    include('./backend/products/Tiltfile')
    include('./backend/cart/Tiltfile')
    include('./backend/orders/Tiltfile')
    include('./backend/users/Tiltfile')

    Each service has its own focused Tiltfile. For example, the frontend service:

    python
    docker_build('shopzone-frontend', '.',
      dockerfile='./Dockerfile',
      live_update=[
        sync('./src', '/app/src'),
        sync('./public', '/app/public'),
      ]
    )
    k8s_yaml(helm('./helm'))
    k8s_resource('frontend', port_forwards=8080)

    This configuration:

    • Builds the frontend container image
    • Sets up live updates for source and public files
    • Deploys using Helm templates
    • Configures port forwarding on port 8080

    Advanced Tiltfile patterns

    Because a Tiltfile is code, you can do more than list resources.

    For example, a conditional can pick manifests per environment:

    python
    config.define_string('environment')
    cfg = config.parse()
    
    if cfg.get('environment') == 'staging':
        k8s_yaml('staging-manifests.yaml')
    else:
        k8s_yaml('dev-manifests.yaml')

    Live updates in detail

    How live updates work

    Live updates are defined as a list of steps that Tilt executes when files change. The steps run in order:

    1. fall_back_on(): files that trigger a full rebuild when changed
    2. sync(): files to copy directly into containers
    3. run(): commands to run after syncing

    Tilt vs. Alternatives: Why Choose Tilt?

    Choose Tilt over Skaffold when you want a live web UI and a config file you can program. The Tiltfile is Starlark, so conditionals and loops replace copy-pasted YAML, and Tilt's live updates sync individual files and run commands inside the container instead of rebuilding the image.

    FeatureTiltSkaffold
    InterfaceWeb UI + Real-time updatesCLI-focused
    ConfigurationStarlark (Programmable)YAML (Static)
    Live UpdatesNative / GranularFile sync only

    Setting up your environment

    Quick start:

    bash
    # Install via curl
    curl -fsSL https://raw.githubusercontent.com/tilt-dev/tilt/master/scripts/install.sh | bash
    
    # Start development
    tilt up
    Tilt Dashboard UI showing microservices status
    The Tilt dashboard: all your services on one screen

    Is Tilt worth it?

    If your inner loop is build, push, apply and wait, yes. Tilt rebuilds only what changed, syncs files into running containers, and puts every service's logs on one dashboard. One Tiltfile replaces the dozen manual steps you used to run per change, and new teammates get the same stack with a single tilt up command.

    "Want to see Tilt in action? Check out the ShopZone E-commerce Store repository for a complete example of Tilt managing a real-world microservices application."
    Hardik Shah

    About Hardik Shah

    Hardik works with development teams whose inner loop involves a container build, a registry push and a wait. Tilt is one of the tools he reaches for when that loop is the actual bottleneck.