Big News!  Tilt is joining Docker
Photo by Nathalie SPEHNER on Unsplash

Are You My Kustomize?

Commit of the Month / January 2020

Every commit has a story behind it.

Every month, the Tilt team picks a Commit of the Month, and tells its story.

January’s commit of the month is a doozy:

“tiltfile: make kustomize fallback more clear with log statement”

To understand it, you need some background.

What is Kustomize?

The brilliant idea behind Kubernetes is “infrastructure as data”. Obligatory Kelsey Hightower tweet:

When I want to adapt my Kubernetes configs for local development, I need a way to apply small patches so that they work locally.

Kustomize and Helm are popular solutions. Both are reasonable choices.

Where is Kustomize?

Kustomize is available as a standalone binary.

Kustomize is also available as kubectl kustomize, as of Kubernetes v1.14. Kubectl is the all-in-one CLI for interacting with Kubernetes. Now that config-modification is a standard part of the Kubernetes ecosystem, the Kubernetes CLI team decided it made sense to support a solution natively.

But here’s the rub.

The latest version of Kustomize is v3.5.4.

The Kustomize in Kubectl is v2.0.3.

Attempts to upgrade Kustomize in Kubectl appear to have stalled. To make matters worse, kubectl kustomize doesn’t report any identifying version info about what version of Kustomize it’s using. It would be so nice if it did!

How do I Kustomize?

A Tiltfile is like a Makefile for local Kubernetes development. Tilt keeps track of your configs. It also keeps track of where those configs come from.

Kustomize users add a line like this to their Tiltfile:

k8s_yaml(kustomize('./path/to/config/dir'))

Tilt will re-run kustomize every time you edit the config dir or kustomization.yaml.

But which Kustomize should it use? Please tell us because we’re not sure!

Are you my Kustomize?

Currently, Tilt’s strategy is to check:

  • Do you have kustomize? If so, use that.
  • Do you have kubectl ? If so, try kubectl kustomize.

Oh and by the way! kustomize might be v2 or v3. kubectl kustomize can only be v2.

Ugh, I’m making myself dizzy just writing this.

We don’t have a good answer. Commit 8984eac240be1948b1719d1b9f90f91a9efb64ab adds some extra logging to tell you which path Tilt is taking.

Further Reading:

Related

Already have a Dockerfile and a Kubernetes config?

You’ll be able to setup Tilt in no time and start getting things done. Check out the docs! 

Having trouble developing your servers in Kubernetes?