为了CI/CD的目的,该项目正在维护2个kustomization.yaml文件
- 常规部署-kustomization_deploy.yaml
- 回滚部署-kustomization_Rollback.yaml
要运行kustoize build;kustomation.yaml";在当前目录中是必需的。如果项目想要使用kustomization_rollback.yaml而不是kustomiization.yaml,这怎么可能呢?kustosize是否接受文件名作为参数?文档对此没有任何说明。
目前不可能更改kustomize
的行为以支持以下文件名之外的其他文件名(通过使用预编译的二进制文件(:
kustomization.yaml
kustomization.yml
Kustomization
以下所有情况都将产生相同的错误输出:
kubectl kustomize dir/
kubectl apply -k dir/
kustomize build dir/
Error: unable to find one of 'kustomization.yaml', 'kustomization.yml' or 'Kustomization' in directory 'FULL_PATH/dir'
根据CI/CD平台/解决方案/工具,您应该尝试其他方法,例如:
- 将
Deployment
拆分为两个目录kustomization_deploy
/kustomization_rollback
和kustomization.yaml
作为旁注!
kustosize使用的文件名放在:中
/kubernetes/vendor/sigs.k8s.io/kustomize/pkg/constants/constants.go
// Package constants holds global constants for the kustomize tool. package constants // KustomizationFileNames is a list of filenames that can be recognized and consumbed // by Kustomize. // In each directory, Kustomize searches for file with the name in this list. // Only one match is allowed. var KustomizationFileNames = []string{ "kustomization.yaml", "kustomization.yml", "Kustomization", }
选择
Kustomization
文件的逻辑位于:
/kubernetes/vendor/sigs.k8s.io/kustomize/pkg/target/kusttarget.go
附加参考:
- Github.com:Kubernetes sigs:Kustomize
- Kubernetes.io:文档:任务:管理Kubernetes对象:Kustomization