kubectl apply -k: Usage, Options & Common CI Errors
Render a kustomize overlay and apply it in a single command.
kubectl apply -k builds a kustomize directory (base plus overlay) and applies the result, the standard way to deploy environment-specific config without templating. In CI you point -k at the right overlay per environment.
What it does
kubectl apply -k DIR runs the embedded kustomize build on DIR's kustomization.yaml - merging the base, applying patches, image tags, name prefixes, and common labels - then applies the rendered manifests. It is equivalent to kustomize build DIR | kubectl apply -f -.
Common usage
kubectl apply -k overlays/prod
kubectl apply -k overlays/staging --server-side
kustomize build overlays/prod | kubectl diff -f - # preview the change
kubectl kustomize overlays/prod # render without applyingCommon errors in CI
"error: accumulating resources ... no such file or directory" means a path in resources: is wrong or the referenced base moved - kustomize paths are relative to the kustomization.yaml. "must build at directory: not a valid directory" means you pointed -k at a file, not the folder containing kustomization.yaml. A subtle one: kubectl's built-in kustomize can lag the standalone kustomize binary, so a newer field (e.g. a transformer) may parse with kustomize build but error under apply -k - pin the kubectl version or pipe the standalone binary instead.