繁体   English   中英

使用不同名称的 kustomization.yaml

[英]Use different name of the kustomization.yaml

出于 CI/CD 的目的,该项目正在维护 2 个 kustomization.yaml 文件

  1. 常规部署 - kustomization_deploy.yaml
  2. 回滚部署 - kustomization_rollback.yaml

要运行 kustomize build,当前目录中需要一个名为“kustomization.yaml”的文件。 如果项目想要使用 kustomization_rollback.yaml 而不是 kustomization.yaml,这怎么可能? kustomize 是否接受文件名作为参数? 文档对此没有指定任何内容。

目前无法更改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成2个目录kustomization_deploy / kustomization_rollbackkustomization.yaml

作为旁注!

kustomize 使用的文件名放置在:

  • /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

补充参考:

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM