Kubernetes

Kustomize CLI

Kustomize commands for Kubernetes configuration management.

32 commands
Windows MacOS Linux
#configuration #deployment

Build & Apply

Build kustomization in current directory
kustomize build .
Build and apply to cluster
kustomize build . | kubectl apply -f -
Apply kustomization directly with kubectl
kubectl apply -k .
Apply a specific overlay
kubectl apply -k overlays/production
Build and write to file
kustomize build . -o output.yaml
Delete resources from kustomization
kubectl delete -k .

Overlays

Create overlay referencing base
kustomize create --resources ../base
kustomize edit add resource deployment.yaml # Add resource to kustomization
Set namespace for all resources
kustomize edit set namespace production
Add name prefix to all resources
kustomize edit set nameprefix prod-
Add name suffix to all resources
kustomize edit set namesuffix -v2

Patches

kustomize edit add patch --path patch.yaml --kind Deployment # Add strategic merge patch
kustomize edit add patch --path json-patch.yaml --kind Service --name my-svc # Add JSON patch for specific resource
kustomize build . --enable-alpha-plugins # Build with alpha plugin support
kustomize edit add patch --path replicas.yaml # Add patch file to kustomization

Config & Secrets

kustomize edit add configmap my-config --from-literal=key=value # Create configmap from literal
kustomize edit add configmap my-config --from-file=config.properties # Create configmap from file
kustomize edit add secret my-secret --from-literal=password=abc123 # Create secret from literal
kustomize edit add secret my-secret --from-file=tls.crt # Create secret from file
kustomize edit add configmap my-config --from-env-file=.env # Create configmap from env file

Images

kustomize edit set image nginx=nginx:1.25 # Override image tag
kustomize edit set image myapp=registry.io/myapp:v2 # Change image registry and tag
kustomize edit set image old-image=new-image:latest # Replace image name and tag
kustomize edit set replicas my-deployment=5 # Set replica count for deployment

Transformers

Add label to all resources
kustomize edit add label app:myapp
kustomize edit add annotation team:backend # Add annotation to all resources
Fix kustomization file issues
kustomize edit fix
kustomize build . --load-restrictor none # Build without file loading restrictions
Show kustomize version
kustomize version

Quick Commands

Build and apply kustomization to cluster
kustomize build . | kubectl apply -f -
Override image tag in kustomization
kustomize edit set image nginx=nginx:1.25
Create configmap generator from file
kustomize edit add configmap my-config --from-file=config.properties