【问题标题】:How to render only selected template in Helm?如何在 Helm 中仅渲染选定的模板?
【发布时间】:2020-07-30 01:20:10
【问题描述】:

我的 helm 图表中有大约 20 个 yamls + 大量依赖项,我想检查特定的渲染输出。 helm template 渲染所有 yaml 并生成一百行代码。有没有办法(即使有一个正则表达式也会很好)只呈现选定的模板(通过文件或例如名称)。

【问题讨论】:

    标签: kubernetes-helm


    【解决方案1】:

    来自helm template documentation

    -s, --show-only stringArray 仅显示从给定模板呈现的清单

    如果只渲染一种资源,请使用helm template -s templates/deployment.yaml .

    【讨论】:

    • 一张小纸条。不要在“模板”文件夹之前使用任何东西。例如如果您运行helm template -s ./templates/deployment.yaml .,它将失败并出现错误Error: could not find template ./templates/deployment.yaml in chart
    • @V.S.是的,这取决于实际的 helm 目录结构,从 Charts.yml 目录开始
    • 还要注意,在 helm2 中,空白模板将呈现为空白,但在 helm3 中它会抛出错误为Error: could not find template ./templates/deployment.yaml in chart,因此当模板中有 if 检查时需要小心。参考:github.com/helm/helm/issues/7295#issuecomment-631151740
    • 如何为子图表 yaml 文件执行此操作?
    猜你喜欢
    • 1970-01-01
    • 2016-11-13
    • 1970-01-01
    • 1970-01-01
    • 2021-02-04
    • 2016-08-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多