朋友们
我正在编写一个包含 postgres 数据库名称数组的 configMap。方法 1 会抛出一个错误,例如 postgres.db.name 中需要标量值
apiVersion: v1
kind: ConfigMap
metadata:
name: postgres-init
data:
postgres.host: "postgreshost"
postgres.db.name: {"postgredb1","postgredb1", "postgredb3"}
Run Code Online (Sandbox Code Playgroud)
这是方法 2,即 postgres.db.name 的数据库名称以逗号分隔
----
apiVersion: v1
kind: ConfigMap
metadata:
name: postgres-init
data:
postgres.host: postgreshost
postgres.db.name: postgredb1,postgredb1,postgredb3
Run Code Online (Sandbox Code Playgroud)
将数据库名称实现为数组的正确方法是什么?
编辑:正如@ShawnFumo 和@HuBeZa 指出的,我的旧答案是不正确的。Configmap 数据键/值对期望值采用字符串格式,因此不可能提供字典/列表作为值。
注意:第二个示例的开头有 4 个“-”,这将使 YAML 文档无效。新的 YAML 文档以 3 个“-”开头。:)
---
apiVersion: v1
kind: ConfigMap
metadata:
name: postgres-init
data:
postgres.host: postgreshost
# Note the "|" after the key - this indicates a multiline string in YAML,
# hence we provide the values as strings.
postgres.db.name: |
- postgredb1
- postgredb2
- postgredb3
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3808 次 |
| 最近记录: |