在子级中使用依赖图中的数值。

huangapple go评论59阅读模式
英文:

Use value from dependency chart in child

问题

我正在编写一个Helm图表,利用存储在图表仓库中的依赖图表。以下是我的Chart.yaml:

appVersion: "1.2"
description: 用于安装和维护测试图表的Helm图表。
name: child-chart
version: 0.2.0

dependencies:
- name: parent-chart
  version: 1.0.9
  repository: https://testrepo.com/

我的parent-chart的values.yaml文件中有以下条目:

testboard:
  enabled: true
  replicaCount: "1"
  appName: "test-operator"

我尝试在子图表中使用{{.Values.testboard.appName}}来使用此名称,但这个值为null。当我尝试{{.Values.parent-chart.testboard.appName}}时,它失败并显示错误"bad character U+002D '-'"。

我应该如何修改我的Helm模板以从依赖图表中获取正确的值?

英文:

I'm writing a helm chart by making use of a dependency chart available in a chart repository.
Below is my Chart.yaml

appVersion: "1.2"
description: Helm chart for installation and maintenance of Test charts.
name: child-chart
version: 0.2.0

dependencies:
- name: parent-chart
  version: 1.0.9
  repository: https://testrepo.com/
  enter code here

The values.yaml of my parent-chart is having the below entry

testboard:
  enabled: true
  replicaCount: "1"
  appName: "test-operator"

I tried to use this name in my child chart by making use of {{.Values.testboard.appName}}, but this value is coming as null. When I gave {{.Values.parent-chart.testboard.appName}} it is failing with an error bad character U+002D '-'

How I should modify my helm template to get the correct values from my dependency chart

答案1

得分: 1

首先,我想指出,通常我们把我们的“父”图表依赖的图表称为“子”图表。为了更清楚,让我们称这些为subcharts

回答你的问题,如果你在子图表的values.yaml中有这样的内容:

testboard:
  appName: something

在父图表中有这样的内容:

dependencies:
- name: subchart
  version: x.x.x
  repository: https://does-not-matter
  alias: alias-for-subchart # << 这是可选的!

你可以像这样覆盖父图表中的testboard.appName

alias-for-subchart:
  testboard:
    appName: something-else

如果你提供了一个别名,或者像这样:

subchart:
  testboard:
    appName: something-else

如果你没有提供别名。

更多解释请参考链接的文档。

英文:

First, I'd like to point out that usually we refer to child charts as the ones our parent chart depends on. To be more clearer, let's call those subcharts

To answer your question, if you have something like this in the subchart values.yaml:

testboard:
  appName: something

this in the parent chart:

dependencies:
- name: subchart
  version: x.x.x
  repository: https://does-not-matter
  alias: alias-for-subchart # &lt;&lt; this is optional!

you can override testboard.appName from the parent chart like this:

alias-for-subchart:
  testboard:
    appName: something-else

if you provide an alias or

subchart:
  testboard:
    appName: something-else

if you don't.

More explanations in the linked documentation.

huangapple
  • 本文由 发表于 2023年6月19日 15:48:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/76504599.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定