How do I actually get the output of kubectl kustomize into my cluster?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
kubectl kustomize only builds and prints the rendered manifests. It does not send anything to the cluster by itself. To actually deploy the generated resources, you must either pipe that output into kubectl apply -f - or use the built-in shortcut kubectl apply -k.
That distinction is the whole answer to the confusion. Rendering and applying are two separate steps unless you explicitly choose the command that combines them.
The Two Correct Apply Patterns
If your kustomization is in ./overlays/prod, these commands are the practical options:
The second form is usually cleaner for normal deployment. The first is useful when you want to inspect or post-process the rendered YAML in the middle of a shell pipeline.
What kubectl kustomize Actually Does
This command:
reads the kustomization.yaml, resolves resources, patches, generators, and overlays, and writes the final YAML to standard output. That is all. It does not modify the cluster.
Think of it as "show me the final manifests," not "apply this configuration."
Use apply -k for the Normal Workflow
For ordinary cluster deployment, kubectl apply -k is usually the best choice:
It keeps the intent clear: build the kustomization from that directory and apply it to the cluster.
That is generally preferable to storing rendered YAML files in your repository, because the kustomization stays the source of truth.
Useful Preview Commands
Before applying, it is often helpful to inspect or compare the rendered output:
A common workflow is:
kubectl kustomizeto inspect the generated manifestskubectl diff -kto compare them with the live clusterkubectl apply -kto deploy
That gives you both visibility and a clean apply step.
Typical Directory Layout
Kustomize usually works with a base plus one or more overlays:
A simple overlay might look like this:
Then you apply the overlay directory, not one of the individual YAML files:
When the Piped Form Is Useful
The pipe form still has real value. For example, you may want to save the rendered output for review:
Or pass it through another tool before applying. The important part is that the final step still has to be apply.
Common Pitfalls
The biggest mistake is assuming kubectl kustomize deploys automatically. It does not. It only renders.
Another common issue is pointing -k at the wrong directory. The target should be the directory containing the relevant kustomization.yaml, not a raw manifest file.
Developers also sometimes mix -f and -k conceptually. -f applies files or stdin, while -k tells kubectl to build a kustomization directory first.
Finally, if the cluster result looks wrong, inspect the rendered YAML with kubectl kustomize before blaming Kubernetes. The problem is often in the kustomization output rather than in apply itself.
Summary
- '
kubectl kustomizerenders manifests but does not apply them.' - Use
kubectl apply -k <dir>for the normal build-and-deploy workflow. - The equivalent piped form is
kubectl kustomize <dir> | kubectl apply -f -. - Use
kubectl diff -kto preview changes before applying them. - Point
-kat the directory containing thekustomization.yamlyou actually want to deploy.

