【问题标题】:Passing list object into configMap data section将列表对象传递到 configMap 数据部分
【发布时间】:2020-12-14 04:18:11
【问题描述】:

我想在应用程序 YAML 文件的 configMap 的数据部分中传递一个列表对象。

我在属性文件中有以下列表:

abc.management.provider[0].url=https://example.com
 abc.management.provider[0].username=John
 abc.management.provider[1].url=https://example2.com
 abc.management.provider[1].username=Targerian

YAML 文件:

data:
    abc_management:
      provider:
        - url: "https://example.com"
          username: "John"
        - url: "https://example2.com"
          username: "Targerian"

我收到此错误:版本“v1”中的 ConfigMap 无法作为 ConfigMap 处理:v1.ConfigMap: Data: ReadString: expects " or n,.

我该怎么办?

【问题讨论】:

    标签: kubernetes yaml kubernetes-helm


    【解决方案1】:

    我该怎么办?

    这主要取决于您的应用程序如何读取配置。

    如果它对您有用,您可以使用 create the ConfigMap directly 和您的属性文件:

    kubectl create configmap app-config --from-file=app.properties
    

    【讨论】:

      【解决方案2】:

      我认为这个问题指向了 ConfigMap 对象的本质。在幕后,ConfigMaps 似乎没有明确处理列表,所以最终它只取决于您如何阅读该内容。

      数据字段被设计为包含 UTF-8 字节序列 ...

      数据或 binaryData 字段下的每个键必须由 字母数字字符、-、_ 或 .. 存储在数据中的键不得 与 binaryData 字段中的键重叠。

      https://kubernetes.io/docs/concepts/configuration/configmap/#configmap-object

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2015-08-03
        • 2012-08-28
        • 2013-11-30
        • 1970-01-01
        • 1970-01-01
        • 2013-04-15
        • 1970-01-01
        相关资源
        最近更新 更多