Skip to content

Kustomize for Mere Mortals

You have one small web application and three places it must run: a staging copy for trying things, a production copy that must not break, maybe a customer's copy with their name on it. The Kubernetes manifests — the YAML files that describe the application — are almost the same in every place. Almost. The image tag differs, the replica count differs, a label differs, one setting differs.

The usual fixes all rot. Copy the folder three times and the copies drift apart. Sprinkle a templating language through the YAML and the files stop being YAML you can read, diff or hand to another tool. Kustomize takes a third road: write the shared manifests once, in plain YAML, call that the base, and for each place write a small overlay that says only what is different — a name prefix, some labels, a new image tag, a patch. Running kustomize build folds base and overlay together and prints the finished manifests to your screen. Nothing is installed, nothing is sent anywhere: it is a text transformation you can run, read and diff before anything goes near a cluster.

This guide explains how that folding works, builds a base and two overlays for a small fictional application, generates its ConfigMap and Secret instead of writing them by hand, applies both kinds of patch, copies a value from one resource into another with replacements, and drives the whole thing both by editing files and with kustomize edit commands. Every claim is proven the way you will prove your own work: by building and reading the diff.

Two rules govern everything here. First: your configuration, your clusters — the lab customises manifests for an invented application and never applies anything anywhere; what you do with the output is yours to decide, on systems that are yours to change. Second, the honesty rule for generated Secrets: the values a secretGenerator holds are base64-encoded, not encrypted, and this guide decodes one on the page to prove it. Anything readable by anyone with the file is not a secret from them; chapter 6 covers what to do instead of committing real values.

The lab behind this guide ran the real tool: kustomize v5.8.3, the official standalone binary, checksum-verified against the project's published checksums, on a small Linux machine, alongside kubectl v1.37.2 so the two could be compared. No cluster was involved at any point — there is nothing for a build to talk to. The transcripts are kept in the repository as the evidence.

How to use this guide

Read chapter 1 for the model, and chapter 2 for the names of the parts, before writing any YAML — most confusion later is a part you met without a name. Chapter 4 builds the lab's base in the same sitting as the install, and chapter 5 layers the first overlay over it; do those two with your hands on the keyboard. Chapter 6 is not the optional chapter: understand what a generated Secret really contains before you let one near a real password. Chapter 10 is the habit that makes the rest safe — never apply a build you have not diffed. The lab's files live in kustomize-lab/app/; its transcripts are kustomize-lab/transcripts/; its notes are examples/lab-notes.txt.


Part of the series

This guide is one of the For Mere Mortals guides: plain-language guides to the tools programmers and makers use.

Related guides:

License

The writing in this guide is licensed under CC BY 4.0. Code examples and lab scripts are licensed under the MIT License.