Skip to content

Checking Your Work

Outcome: a working method, not a feature — build to files, diff before you apply, and let the build's determinism do the auditing. This is the chapter the rest of the guide has been rehearsing.

The build is the test

A kustomize build is pure: same files in, same YAML out, no cluster consulted, no clock or network involved. That purity is a testing superpower most tools cannot offer. Everything an overlay claims to do is fully visible in its output, so the verification of a change is not "apply it and watch" — it is "build the old, build the new, and read every line that moved."

The lab's transcripts t05 is that method, recorded: base diffed against staging, base diffed against production. Every hunk in both diffs has a named cause in a kustomization file — a prefix, a tag, a patch. When you make a change of your own, the same diff is your review:

$ kustomize build app/overlays/production > /tmp/before.yaml
# ... edit something ...
$ kustomize build app/overlays/production > /tmp/after.yaml
$ diff /tmp/before.yaml /tmp/after.yaml

Changed the image tag? The diff should show one line. If it shows forty, the other thirty-nine are a surprise you are about to ship, and the diff just paid for itself. Changed a generated literal? Expect the hash, the name, and every reference — and nothing else.

Habits that scale

  • Commit builds beside changes in review. Teams that keep the rendered output of each overlay in the pull request — or generate it in CI and fail the check if it differs from the committed render — catch both accidental edits and base changes that ripple into overlays nobody opened. The build is fast enough (the lab's builds are milliseconds) that running it on every commit costs nothing.
  • Build every overlay, not the one you touched. A base edit lands in all of them. for d in app/overlays/*/; do kustomize build $d > /dev/null || echo "BROKEN: $d"; done is a whole test suite in one line, and chapter 14's failures are the kind it catches.
  • Pin the version. Chapter 3's two builds agreed byte for byte across a minor version gap — this time. A pinned binary in CI keeps "agreed" a fact instead of a habit.

The door to the cluster

Applying is deliberately not a kustomize feature. The output goes to whatever applies manifests: kubectl apply -f over the stream, kubectl apply -k <overlay> (which runs the bundled build first), or a GitOps controller that watches the repository and applies what it renders. This guide does not exercise any of them — the lab has no cluster, and applying output to a cluster is out of its scope, stated here rather than implied. What the guide insists on is the order of operations: the build and its diff happen first, where mistakes are free, and the apply consumes a stream you have already read.

A last small check, worth the habit: build output is YAML, and YAML is not self-validating. A rendered stream can still contain a value Kubernetes will reject — a malformed quantity, an unknown field under strict checking. Schema validators exist for exactly that pass (chapter 12 names them, unbenchmarked), and kubectl apply --dry-run=server asks the cluster itself, once you have one. Neither replaces reading the diff; both follow it.