Skip to content
Latchkey

ytt: Render YAML Templates With Data Values

ytt renders YAML templates using Starlark annotations and a typed set of data values, producing Kubernetes-ready manifests.

ytt (part of Carvel) is YAML-aware templating: it understands the document structure instead of treating it as text, which avoids indentation bugs common in string templaters.

What it does

ytt reads one or more files with -f (templates plus a data-values schema), overlays and computes them with embedded Starlark, and prints the resulting YAML. Data values are declared in a @data/values document and overridden on the command line or from a values file.

Common usage

Terminal
ytt -f config/ > manifest.yaml
# override a single data value
ytt -f config/ --data-value image=nginx:1.27 > manifest.yaml
# supply overrides from a file
ytt -f config/ --data-values-file prod-values.yaml > manifest.yaml

Options

FlagWhat it does
-f, --file <path>Template file or directory (repeatable)
--data-value <k=v>Override a single data value (string)
--data-value-yaml <k=v>Override with a YAML-typed value (int, bool, list)
--data-values-file <path>Load overrides from a YAML file
--data-values-env <PREFIX>Pull overrides from env vars with a prefix
-o, --output-files <dir>Write results to a directory

In CI

ytt enforces that every data value you override is declared in the schema, which catches typos that string templaters would silently ignore. Use --data-value-yaml for non-string values (a plain --data-value replicas=3 is the string "3"). Render to an artifact and diff before kapp/kubectl apply.

Common errors in CI

"Trying to set a value for missing data values in the schema: Unknown data value 'image'" means you passed --data-value for a key not declared in @data/values; declare it or fix the name. "Expected number, but was string" comes from --data-value where the schema wants an int; use --data-value-yaml. Template panics surface as "Struct does not have attribute" for a typo in a data.values reference.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →