$linuxjunkies
>

kustomize(1)

Kustomize lets you customize Kubernetes object configurations without modifying the original YAML files.

UbuntuDebianFedoraArch

Synopsis

kustomize [command] [flags]

Description

Kustomize is a template-free customization tool for Kubernetes manifests. It uses a declarative approach with a kustomization.yaml file to patch, overlay, and compose multiple Kubernetes resources from a base directory, enabling you to manage variants (dev, staging, prod) without duplicating YAML.

Rather than using template variables, Kustomize applies structural edits like adding prefixes/suffixes, merging configs, and strategic merge patches. The output is standard Kubernetes YAML that can be piped to kubectl apply.

Common options

FlagWhat it does
buildBuild a kustomization target; prints the generated manifests to stdout
-o, --outputOutput format (json, yaml); used with build to write to a specific format
editEdit the kustomization.yaml file in the target directory
versionPrint the kustomize version
--enable-alpha-pluginsEnable alpha plugins when building (for experimental features)
--load-restrictorRestrict file loading (none, LoadRestrictionsNone, LoadRestrictionsRootOnly)
createCreate a new kustomization.yaml with scaffolding
--namespaceSet the namespace for all resources in the kustomization

Examples

Build the kustomization in ./base and apply the resulting manifests to the cluster

kustomize build ./base | kubectl apply -f -

Build the production overlay and save the rendered output to a file

kustomize build ./overlays/production > prod-manifest.yaml

Build current directory in JSON format and extract all resource names

kustomize build . -o json | jq '.items[].metadata.name'

Update the namespace in the kustomization.yaml to mynamespace

kustomize edit set namespace mynamespace

Generate a kustomization.yaml by auto-detecting resources in ./manifests

kustomize create --autodetect ./manifests

Preview what would change in the cluster without applying

kustomize build ./base | kubectl diff -f -

Add another kustomization as a resource to the current one

kustomize edit add resource ./other-base

Build with experimental plugin support enabled

kustomize build --enable-alpha-plugins ./custom

Related commands