gpt4 book ai didi

java - 如何转换复杂对象列表并将其表示在值 yaml 图表中

转载 作者:行者123 更新时间:2023-12-02 10:39:11 28 4
gpt4 key购买 nike

我有以下 spring YAML 结构:

catalogParamter:
- name: kota
street: xxx
- name: yyy
street: kkkk

现在我希望这些值来自 helm 图表中的 YAML 值

在 Spring YAML 目录参数中:${CATALOG_PARAMETER}并在部署yaml和配置yaml中定义它

以及来自值 YAML 的值

如何在值 YAML 中表示 CatalogParamter。

最佳答案

这里有不同的选项。我建议把 application.yaml in a ConfigMap 。然后,您可以使用以下方式公开值文件中的属性:

properties:
catalogParamter:
- name: kota
street: xxx
- name: yyy
street: kkkk

并使用以下内容填充 ConfigMap 的数据部分:

data:
application.yaml: |-
{{ toYaml .Values.properties | indent 4 }}

您可以then mount that ConfigMap进入 /config 目录,以便 Spring Boot 应用程序 automatically read it .

如果您使用环境变量,那么您可以使用 Spring boot 的 relaxed binding 将复杂属性映射到环境变量。 。在图表中编码转换可能很棘手,但您的情况似乎是名称-值对,所以我认为可以使用 helm 的 range 函数来完成。

另一种不同的模式是公开 option to set env vars directly to the user 。但这样做的缺点是用户必须了解环境变量格式,这对于宽松的绑定(bind)可能不直观。

关于java - 如何转换复杂对象列表并将其表示在值 yaml 图表中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53059268/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com