舵-以编程方式覆盖子图表values.yaml [英] helm - programmatically override subchart values.yaml
问题描述
我正在写一个使用稳定/redis 图表作为子图表.
I'm writing a helm chart that uses the stable/redis chart as a subchart.
我需要覆盖图表中和Redis图表中用于两种微服务的存储类名称.
I need to override the storage class name used for both microservices within my chart, and within the redis chart.
我正在使用头盔2.12.3
I'm using helm 2.12.3
我希望能够像这样指定模板来指定redis.master.persistence.storageClass
I would like to be able to specify redis.master.persistence.storageClass in terms of a template, like so
storage:
storageClasses:
name: azurefile
redis:
usePassword: false
master:
persistence:
storageClass: {{ $.Values.storage.storageClasses.name }}
据我了解,values.yaml中不支持模板
Except, as I understand, templates aren't supported within values.yaml
As this is a public chart, I'm not able to modify it to depend on a global value as described here in the documentation
我考虑在图表的其他位置使用{{ $.Values.redis.master.persistence.storageClass }}
而不是{{ $.Values.storage.storageClasses.name }}
,但这将:
I considered using {{ $.Values.redis.master.persistence.storageClass }}
elsewhere in my chart rather than {{ $.Values.storage.storageClasses.name }}
, but this would:
- 不掩盖我图表的依赖关系的复杂性
- 如果要添加另一个子图依赖项,则无法缩放
在我的values.yaml文件中,我有:
In my values.yaml file I have:
storage:
storageClasses:
name: azurefile
redis:
master:
persistence:
storageClass: azurefile
我想在values.yaml中指定一个值,该值可以在图表部署时覆盖.
I would like to specify a single value in values.yaml that can be overwritten at chart deploy time.
例如像这样
helm install --set storage.storageClasses.name=foo mychart
而不是
helm install --set storage.storageClasses.name=foo --set redis.master.persistence.storageClass mychart
推荐答案
正如您正确提到的那样,掌舵值文件是纯Yaml文件,不能包含任何模板.对于您的用例,您还需要对价值文件使用模板系统,这基本上意味着您还在旅途中生成价值文件.我建议您看看 helmfile .这使您可以在多个图表和应用程序环境之间共享值文件.
As you correctly mentioned, helm value files are plain yaml files which cannot contain any templates. For your use case, you'd need to use a templating system for your values files also which basically means you are also generating your value files on the go. I'd suggest taking a look at helmfile. This lets you share values file across multiple charts and application environments.
这篇关于舵-以编程方式覆盖子图表values.yaml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!