Friends
Im writing a configMap containing an array of postgres db names. Approach 1 throws an error like scalar value is expected at postgres.db.name
apiVersion: v1
kind: ConfigMap
metadata:
name: postgres-init
data:
postgres.host: "postgreshost"
postgres.db.name: {"postgredb1","postgredb1", "postgredb3"}
Here is Approach 2 ie postgres.db.name having db names separated by comma
----
apiVersion: v1
kind: ConfigMap
metadata:
name: postgres-init
data:
postgres.host: postgreshost
postgres.db.name: postgredb1,postgredb1,postgredb3
Which is the correct way to achieve db names as an array ?
CodePudding user response:
arrays (or lists) can be provided in JSON or YAML format, because YAML is a superset of JSON.
note: you have 4 "-" at the start of your second example, which would make the YAML document invalid. new YAML docs start with 3 "-". :)
JSON format:
---
apiVersion: v1
kind: ConfigMap
metadata:
name: postgres-init
data:
postgres.host: postgreshost
postgres.db.name: ["postgredb1", "postgredb2", "postgredb3"]
YAML format:
---
apiVersion: v1
kind: ConfigMap
metadata:
name: postgres-init
data:
postgres.host: postgreshost
postgres.db.name:
- postgredb1
- postgredb2
- postgredb3