Skip to main content
This lesson explains what kustomize build produces and how to apply those manifests to your Kubernetes cluster. What kustomize build does
  • Collects every resource referenced by a kustomization.yaml (bases, resources, patches, etc.).
  • Applies configured transformations (patches, namePrefix, namespace, image tags, commonLabels, etc.).
  • Writes the fully rendered YAML manifests to stdout (the console).
Important: kustomize build only generates the final manifests — it does not create, modify, or delete any resources in your cluster. If you run kustomize build and then check the cluster with kubectl get pods (or kubectl get deployments, kubectl get services), you will see no changes until you apply those manifests. How to apply the manifests produced by kustomize Use a shell pipe to send the generated YAML from kustomize build into kubectl apply. The pipe (|) forwards stdout of the left-hand command as stdin to the right-hand command. Example — generate and apply:
How this works:
  • kustomize build k8s/ renders the combined manifests and prints them to stdout.
  • The pipe (|) forwards that YAML to kubectl apply.
  • kubectl apply -f - tells kubectl to read manifests from stdin (the single dash -).
  • kubectl then creates or updates the resources in the cluster.
Use kubectl’s built-in kustomize support If you prefer a single command, kubectl can build and apply a kustomization.yaml directly using the -k flag:
This instructs kubectl to read kustomization.yaml from the k8s/ directory, run kustomize, and apply the resulting manifests — combining the build and apply steps above.
-f - means “read manifests from stdin”. Using kustomize build k8s/ | kubectl apply -f - is equivalent to kubectl apply -k k8s/ when applying a local kustomization.
Note: kubectl includes bundled kustomize support, but its kustomize version may lag behind the standalone kustomize binary. If you rely on the latest kustomize features, prefer the standalone binary or verify compatibility with your kubectl version.
Deleting resources produced by a kustomization Deletion follows the same pattern: build the manifests and pipe them into kubectl delete. Example — delete via pipe:
Or use kubectl’s -k flag directly:
Quick reference: commands and intent Tips and troubleshooting
  • Ensure a kustomization.yaml file exists in the target directory (k8s/ in the examples).
  • If kubectl apply -k fails, check your kubectl version and consider using the standalone kustomize binary.
  • Use kustomize build k8s/ > manifests.yaml if you want to inspect the combined output before applying.
Summary
  • kustomize build only prints the final manifests; it does not interact with the cluster.
  • Pipe the output into kubectl to create/update/delete resources:
    • Apply: kustomize build k8s/ | kubectl apply -f - or kubectl apply -k k8s/
    • Delete: kustomize build k8s/ | kubectl delete -f - or kubectl delete -k k8s/
  • Use kubectl apply -k / kubectl delete -k when you want kubectl itself to run kustomize; prefer the standalone binary if you need the latest kustomize features.
Links and references

Watch Video