Skip to content
Latchkey

kustomize build Command Reference

Render a kustomize overlay into final Kubernetes manifests.

kustomize build evaluates a kustomization directory (base plus overlays) and prints the fully rendered manifests to stdout. In CI you validate, diff, or pipe that output into kubectl apply.

What it does

kustomize build resolves a kustomization.yaml, applying patches, name prefixes, images, and generators, and emits the final YAML. It performs no cluster calls, so it is a pure, deterministic rendering step ideal for review and validation.

Common flags and usage

  • DIR: the overlay directory to build (e.g. overlays/prod)
  • --enable-helm: render embedded Helm charts during the build
  • --load-restrictor: control reading files outside the root
  • -o FILE: write output to a file instead of stdout
  • pipe to kubectl apply -f - to deploy the rendered output

Example

shell
- name: Render and apply manifests
  run: |
    kustomize build overlays/prod > rendered.yaml
    kubectl apply -f rendered.yaml --dry-run=server
    kubectl apply -f rendered.yaml

In CI

Render with kustomize build, then run kubectl apply --dry-run=server as a validation gate before the real apply so server-side schema errors surface early. Committing or artifacting rendered.yaml gives reviewers the exact manifests, and GitOps tools can sync the same output.

Key takeaways

  • kustomize build renders base plus overlays into final manifests, no cluster calls.
  • Pipe the output into kubectl apply, gated by --dry-run=server first.
  • Artifact the rendered YAML so reviewers see exactly what will deploy.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →