Linux command
kustomize 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Build kustomization
kustomize build .
Build from specific directory
kustomize build [path/to/overlay]
Build from git repository
kustomize build [https://github.com/org/repo//path]
Create new kustomization
kustomize create
Create with autodetected resources
kustomize create --autodetect
Edit to add a resource
kustomize edit add resource [deployment.yaml]
Edit to set namespace
kustomize edit set namespace [my-namespace]
Edit to set image tag
kustomize edit set image [nginx:1.25]
说明
kustomize customizes Kubernetes YAML configurations without templates. It uses a kustomization.yaml file to declaratively specify base resources and overlay modifications like patches, labels, namespaces, and image tags. The tool follows a base/overlay pattern: bases contain common resources, overlays customize them for specific environments (dev, staging, prod). This approach avoids duplication while maintaining environment-specific differences. Kustomize is built into kubectl (since v1.14) as kubectl kustomize and kubectl apply -k. The standalone CLI provides the latest features and is recommended for advanced use cases. Key concepts include resources (YAML files to include), patches (strategic merge or JSON patches), configMapGenerator and secretGenerator (generate ConfigMaps/Secrets from files), and vars (variable substitution).
参数
- --enable-helm
- Enable Helm chart inflator generator.
- --enable-alpha-plugins
- Enable alpha kustomize plugins.
- --as-current-user
- Use uid and gid of command executor.
- --load-restrictor _value_
- Control file loading: LoadRestrictionsRootOnly or LoadRestrictionsNone.
- -o, --output _path_
- Write output to file instead of stdout.
- --stack-trace
- Print stack trace on error.
- -h, --help
- Show help information.
FAQ
What is the kustomize command used for?
kustomize customizes Kubernetes YAML configurations without templates. It uses a kustomization.yaml file to declaratively specify base resources and overlay modifications like patches, labels, namespaces, and image tags. The tool follows a base/overlay pattern: bases contain common resources, overlays customize them for specific environments (dev, staging, prod). This approach avoids duplication while maintaining environment-specific differences. Kustomize is built into kubectl (since v1.14) as kubectl kustomize and kubectl apply -k. The standalone CLI provides the latest features and is recommended for advanced use cases. Key concepts include resources (YAML files to include), patches (strategic merge or JSON patches), configMapGenerator and secretGenerator (generate ConfigMaps/Secrets from files), and vars (variable substitution).
How do I run a basic kustomize example?
Run `kustomize build .` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --enable-helm do in kustomize?
Enable Helm chart inflator generator.