在 helm 的替代依赖项之间进行选择
Choosing between alternative dependencies in helm
我有一个需要某种数据库的应用程序的控制图。
mysql 或 postgresql 都可以。
我想为图表用户提供安装其中一个作为依赖项的选项,如下所示:
dependencies:
- name: mysql
version: 0.10.2
repository: https://kubernetes-charts.storage.googleapis.com/
condition: mysql.enabled
- name: postgresql
version: 3.11.5
repository: https://kubernetes-charts.storage.googleapis.com/
condition: postgresql.enabled
然而,这使得同时启用它们成为可能。
有没有简单的方法来确保只选择一个?
我正在考虑选择 [mysql, postgres, manual]
之一的单个变量,如果选择它则取决于特定的数据库。 - 有办法吗?
我认为没有直接的方法可以做到这一点。特别是, requirements.yaml
condition:
字段看起来只采用布尔值(或它们的列表)而不是任意表达式。来自 the Helm documentation:
The condition field holds one or more YAML paths (delimited by commas). If this path exists in the top parent’s values and resolves to a boolean value, the chart will be enabled or disabled based on that boolean value. Only the first valid path found in the list is evaluated and if no paths exist then the condition has no effect.
(下面描述的标签机制非常相似,并没有真正帮助。)
归结为实际编写您的部署规范时,您有一个更正常的条件系统,并且可以测试是否只设置了一个值;所以我不认为你可以阻止安装冗余数据库,但你至少只使用其中一个。您还可以在 NOTES.txt
文件中对此进行事后警告。
{{ if and .Values.mysql.enabled .Values.postgresql.enabled -}}
WARNING: you have multiple databases enabled in your Helm values file.
Both MySQL and PostgreSQL are installed as part of this chart, but only
PostgreSQL is being used. You can update this chart installation setting
`--set mysql.enabled=false` to remove the redundant database.
{{ end -}}
我有一个需要某种数据库的应用程序的控制图。 mysql 或 postgresql 都可以。
我想为图表用户提供安装其中一个作为依赖项的选项,如下所示:
dependencies:
- name: mysql
version: 0.10.2
repository: https://kubernetes-charts.storage.googleapis.com/
condition: mysql.enabled
- name: postgresql
version: 3.11.5
repository: https://kubernetes-charts.storage.googleapis.com/
condition: postgresql.enabled
然而,这使得同时启用它们成为可能。
有没有简单的方法来确保只选择一个?
我正在考虑选择 [mysql, postgres, manual]
之一的单个变量,如果选择它则取决于特定的数据库。 - 有办法吗?
我认为没有直接的方法可以做到这一点。特别是, requirements.yaml
condition:
字段看起来只采用布尔值(或它们的列表)而不是任意表达式。来自 the Helm documentation:
The condition field holds one or more YAML paths (delimited by commas). If this path exists in the top parent’s values and resolves to a boolean value, the chart will be enabled or disabled based on that boolean value. Only the first valid path found in the list is evaluated and if no paths exist then the condition has no effect.
(下面描述的标签机制非常相似,并没有真正帮助。)
归结为实际编写您的部署规范时,您有一个更正常的条件系统,并且可以测试是否只设置了一个值;所以我不认为你可以阻止安装冗余数据库,但你至少只使用其中一个。您还可以在 NOTES.txt
文件中对此进行事后警告。
{{ if and .Values.mysql.enabled .Values.postgresql.enabled -}}
WARNING: you have multiple databases enabled in your Helm values file.
Both MySQL and PostgreSQL are installed as part of this chart, but only
PostgreSQL is being used. You can update this chart installation setting
`--set mysql.enabled=false` to remove the redundant database.
{{ end -}}